使用 Buession ShiroJs 必须先对其初始化,创建 Shiro 类实例。在实例化 Shiro 类 之前,需定义 Principal
示例:
原生 JavaScript
<script type="text/javascript">
var principal = new Principal() | null;
var shiro = new Shiro(principal);
</script>
或
<script type="text/javascript">
var shiro = new Shiro({
id: 'id',
roles: [],
permissions: []
});
</script>
vue 在 main.js 中实例化 Shiro 类,并挂载到 Vue 全局中
<script type="ts">
import '@buession/shiro';
const principal = new Principal() | null;
const shiro = new Shiro(principal);
app.config.globalProperties.shiro = shiro;
</script>
或
<script type="ts">
import '@buession/shiro';
const shiro = new Shiro({
id: 'id',
roles: [],
permissions: []
});
app.config.globalProperties.shiro = shiro;
</script>