From 5491eac52ec217d7f72a6dc6cb28bb83e66180e8 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Mon, 30 Nov 2020 17:41:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E4=B8=AAv-xpack=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/business/main.js | 4 +++- frontend/src/business/permission.js | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/frontend/src/business/main.js b/frontend/src/business/main.js index af8546ab0e..cf25f4cf37 100644 --- a/frontend/src/business/main.js +++ b/frontend/src/business/main.js @@ -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, diff --git a/frontend/src/business/permission.js b/frontend/src/business/permission.js index 3583af3baf..4bd1d9c654 100644 --- a/frontend/src/business/permission.js +++ b/frontend/src/business/permission.js @@ -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) {