From 081f582f7fc7ad40ab1bbb40caa36beee9f6038c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Mon, 20 Nov 2023 00:00:02 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E6=8C=89=E9=92=AE=E7=9A=84=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E4=BB=8E=E7=99=BB=E5=BD=95=E9=80=BB=E8=BE=91=E6=8C=AA?= =?UTF-8?q?=E5=88=B0=E7=99=BB=E5=BD=95=E4=B9=8B=E5=90=8E=E7=9A=84=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=EF=BC=88=E4=BC=98=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jshERP-web/src/components/page/GlobalHeader.vue | 8 +------- jshERP-web/src/permission.js | 5 ++++- jshERP-web/src/store/modules/user.js | 13 ++++++++++++- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/jshERP-web/src/components/page/GlobalHeader.vue b/jshERP-web/src/components/page/GlobalHeader.vue index 6f9321f3..ae5164ba 100644 --- a/jshERP-web/src/components/page/GlobalHeader.vue +++ b/jshERP-web/src/components/page/GlobalHeader.vue @@ -45,9 +45,8 @@ import UserMenu from '../tools/UserMenu' import SMenu from '../menu/' import Logo from '../tools/Logo' - import { getCurrentSystemConfig, getUserBtnByCurrentUser } from '@/api/api' + import { getCurrentSystemConfig } from '@/api/api' import { mixin } from '@/utils/mixin.js' - import Vue from 'vue' export default { name: 'GlobalHeader', @@ -166,11 +165,6 @@ this.companyName = res.data.companyName } }) - getUserBtnByCurrentUser().then((res) => { - if(res.code === 200 && res.data){ - Vue.ls.set('winBtnStrList', res.data.userBtn, 7 * 24 * 60 * 60 * 1000) - } - }) }, //update-begin--author:sunjianlei---date:20190508------for: 顶部导航栏过长时显示更多按钮----- } diff --git a/jshERP-web/src/permission.js b/jshERP-web/src/permission.js index c599210f..46a61399 100644 --- a/jshERP-web/src/permission.js +++ b/jshERP-web/src/permission.js @@ -3,7 +3,6 @@ import router from './router' import store from './store' import NProgress from 'nprogress' // progress bar import 'nprogress/nprogress.css' // progress bar style -import notification from 'ant-design-vue/es/notification' import { USER_ID,INDEX_MAIN_PAGE_PATH } from '@/store/mutation-types' import { generateIndexRouter } from "@/utils/util" @@ -25,6 +24,10 @@ router.beforeEach((to, from, next) => { if (menuData === null || menuData === "" || menuData === undefined) { return; } + // 缓存用户的按钮权限 + store.dispatch('GetUserBtnList').then(res => { + Vue.ls.set('winBtnStrList', res.data.userBtn, 7 * 24 * 60 * 60 * 1000) + }) let constRoutes = []; constRoutes = generateIndexRouter(menuData); // 添加主界面路由 diff --git a/jshERP-web/src/store/modules/user.js b/jshERP-web/src/store/modules/user.js index 4c7f363e..81ca0e67 100644 --- a/jshERP-web/src/store/modules/user.js +++ b/jshERP-web/src/store/modules/user.js @@ -2,7 +2,7 @@ import Vue from 'vue' import { login, logout } from "@/api/login" import { ACCESS_TOKEN, USER_NAME,USER_INFO,UI_CACHE_DB_DICT_DATA,USER_ID,USER_LOGIN_NAME,CACHE_INCLUDED_ROUTES } from "@/store/mutation-types" import { welcome } from "@/utils/util" -import { queryPermissionsByUser } from '@/api/api' +import { queryPermissionsByUser, getUserBtnByCurrentUser } from '@/api/api' import { getAction } from '@/api/manage' const user = { @@ -104,6 +104,17 @@ const user = { }) }, + // 获取用户的按钮权限 + GetUserBtnList({ commit }) { + return new Promise((resolve, reject) => { + getUserBtnByCurrentUser().then(response => { + resolve(response) + }).catch(error => { + reject(error) + }) + }) + }, + // 登出 Logout({ commit, state }) { return new Promise((resolve) => {