diff --git a/src/main.js b/src/main.js index a771cd7..82fd1fe 100644 --- a/src/main.js +++ b/src/main.js @@ -3,7 +3,6 @@ import App from "./App.vue"; import uviewPlus from "uview-plus"; import globalComponents from "./components"; import VConsole from "vconsole"; -import permission from "../utils/permission.js"; if (import.meta.env.VITE_APP_MODE === "dev") { new VConsole(); @@ -11,7 +10,6 @@ if (import.meta.env.VITE_APP_MODE === "dev") { export function createApp() { const app = createSSRApp(App); globalComponents(app); - permission(app); app.use(uviewPlus); return { app, diff --git a/src/pages/detail/index.vue b/src/pages/detail/index.vue index 66c4808..327cd32 100644 --- a/src/pages/detail/index.vue +++ b/src/pages/detail/index.vue @@ -74,7 +74,7 @@ diff --git a/utils/index.js b/utils/index.js index 1b7e97d..b09d9a3 100644 --- a/utils/index.js +++ b/utils/index.js @@ -24,3 +24,11 @@ export const OAorMc = () => { return ""; } }; +export const hasPermission = (userPermission) => { + let userPermissionList = Array.isArray(userPermission) + ? userPermission + : [userPermission]; + // 当前用户的权限列表 + let permissionList = Local.get("ruleBtn") ? Local.get("ruleBtn") : []; + return userPermissionList.some((e) => permissionList.includes(e)); +}; diff --git a/utils/permission.js b/utils/permission.js deleted file mode 100644 index d35738a..0000000 --- a/utils/permission.js +++ /dev/null @@ -1,22 +0,0 @@ -export default (app) => { - // 按钮权限/show-btn - app.directive("permission", { - beforeMount(el, binding) { - const btnList = uni.getStorageSync("ruleBtn") - ? uni.getStorageSync("ruleBtn") - : []; - if ( - (binding.value && - btnList.length > 0 && - !btnList.includes(binding.value)) || - btnList.length == 0 - ) { - // 解决进入页面按钮会闪一下再消失问题 - el.style.display = "none"; - setTimeout(() => { - el.parentNode.removeChild(el); - }, 0); - } - }, - }); -};