refactor: 增加一个v-xpack指令
This commit is contained in:
parent
04a41e22f8
commit
5491eac52e
|
@ -11,7 +11,7 @@ import YanProgress from 'yan-progress';
|
|||
import './permission' // permission control
|
||||
import i18n from "../i18n/i18n";
|
||||
import store from "./store";
|
||||
import {permission, roles} from './permission'
|
||||
import {permission, roles, xpack} from './permission'
|
||||
import chart from "../common/js/chart";
|
||||
import CalendarHeatmap from "../common/js/calendar-heatmap";
|
||||
import '../common/css/menu-header.css';
|
||||
|
@ -37,6 +37,8 @@ Vue.directive('permission', permission);
|
|||
// v-roles
|
||||
Vue.directive('roles', roles);
|
||||
|
||||
Vue.directive('xpack', xpack);
|
||||
|
||||
new Vue({
|
||||
el: '#app',
|
||||
router,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import router from './components/common/router/router'
|
||||
import {TokenKey} from '@/common/js/constants';
|
||||
import {LicenseKey, TokenKey} from '@/common/js/constants';
|
||||
import {hasRolePermissions, hasRoles} from "@/common/js/utils";
|
||||
import NProgress from 'nprogress' // progress bar
|
||||
import 'nprogress/nprogress.css' // progress bar style
|
||||
|
@ -19,6 +19,20 @@ export const roles = {
|
|||
}
|
||||
};
|
||||
|
||||
export const xpack = {
|
||||
inserted(el, binding) {
|
||||
checkLicense(el, binding);
|
||||
}
|
||||
};
|
||||
|
||||
function checkLicense(el, binding, type) {
|
||||
let v = localStorage.getItem(LicenseKey);
|
||||
|
||||
if (v !== 'valid') {
|
||||
el.parentNode && el.parentNode.removeChild(el)
|
||||
}
|
||||
}
|
||||
|
||||
function checkRolePermission(el, binding, type) {
|
||||
const {value} = binding;
|
||||
if (value && value instanceof Array && value.length > 0) {
|
||||
|
|
Loading…
Reference in New Issue