From bb37b51088dffdfb493906de541b5251e1d969d1 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期一, 08 七月 2024 15:07:00 +0800 Subject: [PATCH] 移除权限 --- src/layout/navBars/breadcrumb/user.vue | 10 - src/utils/request.ts | 50 ++++++------ src/router/frontEnd.ts | 2 src/api/login/menuData.ts | 92 +++++++++++++++++++++++ src/router/backEnd.ts | 12 -- src/router/index.ts | 42 ++++------ src/api/login/index.ts | 9 - 7 files changed, 143 insertions(+), 74 deletions(-) diff --git a/src/api/login/index.ts b/src/api/login/index.ts index 2867914..c4ed305 100644 --- a/src/api/login/index.ts +++ b/src/api/login/index.ts @@ -1,3 +1,4 @@ +import { menuData } from './menuData'; import request, { authRequest } from '/@/utils/request'; /** @@ -232,12 +233,8 @@ /** * @summary 鑾峰彇褰撳墠鐢ㄦ埛鍦ㄥ綋鍓嶈蒋浠朵腑鎵�鏈夌殑鍚庣鑿滃崟閰嶇疆(鏍戠粨鏋�) */ -export const GetUserMenuTree = async (params) => { - return authRequest({ - url: '/Auth/Menu/Authority/GetMenuTreeList@V1.0', - method: 'GET', - params: params, - }); +export const GetUserMenuTree = async () => { + return Promise.resolve(menuData); }; /** diff --git a/src/api/login/menuData.ts b/src/api/login/menuData.ts new file mode 100644 index 0000000..95edb91 --- /dev/null +++ b/src/api/login/menuData.ts @@ -0,0 +1,92 @@ +export const menuData = { + Code: 0, + Error: null, + Message: '璇锋眰鎴愬姛', + Data: [ + { + Children: [ + { + Children: [ + { + Children: [], + ID: '1782264030812049408', + ParentID: '1782264030250012672', + Type: 2, + Name: '杩愯鐐瑰垎鏋�', + Path: '/home', + Permission: '', + Icon: 'ele-Clock', + IsIframe: false, + OutLink: '', + IsHide: false, + Weight: 0, + SortCode: 1, + Description: '', + }, + { + Children: [], + ID: '1790921981332426752', + ParentID: '1782264030250012672', + Type: 2, + Name: '璋冨害鍒嗘瀽', + Path: '/efficiencyAnalysis/schedulingAnalysis', + Permission: '', + Icon: 'ele-MessageBox', + IsIframe: false, + OutLink: '', + IsHide: false, + Weight: 0, + SortCode: 2, + Description: '', + }, + { + Children: [], + ID: '1810189296141996032', + ParentID: '1782264030250012672', + Type: 2, + Name: '妯″瀷楠岃瘉', + Path: '/dispatch/hydraulicModel', + Permission: '', + Icon: 'ele-DocumentChecked', + IsIframe: false, + OutLink: '', + IsHide: false, + Weight: 0, + SortCode: 3, + Description: '', + }, + ], + ID: '1782264030250012672', + ParentID: '1782264029847359488', + Type: 1, + Name: '鑺傝兘鍒嗘瀽', + Path: '', + Permission: '', + Icon: 'iconfont icon-zhongduancanshuchaxun', + IsIframe: false, + OutLink: '', + IsHide: false, + Weight: 0, + SortCode: 1, + Description: '', + }, + ], + ID: '1782264029847359488', + ParentID: '0', + Type: 1, + Name: '鑳芥晥鍒嗘瀽', + Path: '', + Permission: '', + Icon: 'ele-ChromeFilled', + IsIframe: false, + OutLink: '', + IsHide: false, + Weight: 0, + SortCode: 1, + Description: '', + }, + + ], + Extras: null, + Timestamp: '2024-07-08 14:50:06', +}; diff --git a/src/layout/navBars/breadcrumb/user.vue b/src/layout/navBars/breadcrumb/user.vue index b0d847c..90d3965 100644 --- a/src/layout/navBars/breadcrumb/user.vue +++ b/src/layout/navBars/breadcrumb/user.vue @@ -64,7 +64,7 @@ :class="!state.isScreenfull ? 'icon-fullscreen' : 'icon-tuichuquanping'" ></i> </div> - <el-dropdown :show-timeout="70" :hide-timeout="50" @command="onHandleCommandClick"> + <!-- <el-dropdown :show-timeout="70" :hide-timeout="50" @command="onHandleCommandClick"> <span class="layout-navbars-breadcrumb-user-link"> <img :src="userInfos.photo" class="layout-navbars-breadcrumb-user-link-photo mr5" /> {{ userInfos.userName === '' ? 'common' : userInfos.userName }} @@ -74,16 +74,12 @@ </span> <template #dropdown> <el-dropdown-menu> - <!-- <el-dropdown-item command="/home">{{ $t('message.user.dropdown1') }}</el-dropdown-item> --> - <!-- <el-dropdown-item command="wareHouse">{{ $t('message.user.dropdown6') }}</el-dropdown-item> - - <el-dropdown-item command="/404">{{ $t('message.user.dropdown3') }}</el-dropdown-item> - <el-dropdown-item command="/401">{{ $t('message.user.dropdown4') }}</el-dropdown-item> --> + <el-dropdown-item command="/platformManage/personalCenter">{{ $t('message.user.dropdown2') }}</el-dropdown-item> <el-dropdown-item divided command="logOut">{{ $t('message.user.dropdown5') }}</el-dropdown-item> </el-dropdown-menu> </template> - </el-dropdown> + </el-dropdown> --> <Search ref="searchRef" /> </div> </template> diff --git a/src/router/backEnd.ts b/src/router/backEnd.ts index 12e2b62..eb30967 100644 --- a/src/router/backEnd.ts +++ b/src/router/backEnd.ts @@ -40,7 +40,7 @@ // 鐣岄潰 loading 鍔ㄧ敾寮�濮嬫墽琛� if (window.nextLoading === undefined) NextLoading.start(); // 鏃� token 鍋滄鎵ц涓嬩竴姝� - if (!Local.get(accessTokenKey)) return false; + // if (!Local.get(accessTokenKey)) return false; // 瑙﹀彂鍒濆鍖栫敤鎴蜂俊鎭� pinia // https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP // await useUserInfo().setUserInfos(); @@ -127,14 +127,8 @@ */ export async function getBackEndControlRoutes() { // 妯℃嫙 admin 涓� test - const stores = useUserInfo(); - let userInfo = (await stores.getUserInfo()) as any; - const { - SoftWare: { ID: SoftwareID }, - User: { ID: UserID }, - } = userInfo; - const params = { SoftwareID, UserID }; - return menuApi.getAdminMenu(params); + + return menuApi.getAdminMenu(); // const auth = userInfos.value.roles[0]; // 绠$悊鍛� admin // if (auth === 'admin') return menuApi.getAdminMenu(); diff --git a/src/router/frontEnd.ts b/src/router/frontEnd.ts index eab6722..31d2351 100644 --- a/src/router/frontEnd.ts +++ b/src/router/frontEnd.ts @@ -23,7 +23,7 @@ // 鐣岄潰 loading 鍔ㄧ敾寮�濮嬫墽琛� if (window.nextLoading === undefined) NextLoading.start(); // 鏃� token 鍋滄鎵ц涓嬩竴姝� - if (!Local.get(accessTokenKey)) return false; + // if (!Local.get(accessTokenKey)) return false; // 瑙﹀彂鍒濆鍖栫敤鎴蜂俊鎭� pinia // https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP // await useUserInfo(pinia).setUserInfos(); diff --git a/src/router/index.ts b/src/router/index.ts index a792e8f..7ce9613 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -98,36 +98,26 @@ router.beforeEach(async (to, from, next) => { NProgress.configure({ showSpinner: false }); if (to.meta.title) NProgress.start(); - const token = Local.get(accessTokenKey); - if (to.path === '/login' && !token) { - next(); + if (to.path === '/login') { + next('/'); NProgress.done(); } else { - if (!token) { - next(`/login?redirect=${to.path}¶ms=${JSON.stringify(to.query ? to.query : to.params)}`); - clearAccessTokens(); - NProgress.done(); - } else if (token && to.path === '/login') { - next('/'); - NProgress.done(); - } else { - const storesRoutesList = useRoutesList(pinia); - const { routesList } = storeToRefs(storesRoutesList); - if (routesList.value.length === 0) { - if (isRequestRoutes) { - // 鍚庣鎺у埗璺敱锛氳矾鐢辨暟鎹垵濮嬪寲锛岄槻姝㈠埛鏂版椂涓㈠け - await initBackEndControlRoutes(); - // 瑙e喅鍒锋柊鏃讹紝涓�鐩磋烦 404 椤甸潰闂锛屽叧鑱旈棶棰� No match found for location with path 'xxx' - // to.query 闃叉椤甸潰鍒锋柊鏃讹紝鏅�氳矾鐢卞甫鍙傛暟鏃讹紝鍙傛暟涓㈠け銆傚姩鎬佽矾鐢憋紙xxx/:id/:name"锛塱sDynamic 鏃犻渶澶勭悊 - next({ path: to.path, query: to.query }); - } else { - // https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP - await initFrontEndControlRoutes(); - next({ path: to.path, query: to.query }); - } + const storesRoutesList = useRoutesList(pinia); + const { routesList } = storeToRefs(storesRoutesList); + if (routesList.value.length === 0) { + if (isRequestRoutes) { + // 鍚庣鎺у埗璺敱锛氳矾鐢辨暟鎹垵濮嬪寲锛岄槻姝㈠埛鏂版椂涓㈠け + await initBackEndControlRoutes(); + // 瑙e喅鍒锋柊鏃讹紝涓�鐩磋烦 404 椤甸潰闂锛屽叧鑱旈棶棰� No match found for location with path 'xxx' + // to.query 闃叉椤甸潰鍒锋柊鏃讹紝鏅�氳矾鐢卞甫鍙傛暟鏃讹紝鍙傛暟涓㈠け銆傚姩鎬佽矾鐢憋紙xxx/:id/:name"锛塱sDynamic 鏃犻渶澶勭悊 + next({ path: to.path, query: to.query }); } else { - next(); + // https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP + await initFrontEndControlRoutes(); + next({ path: to.path, query: to.query }); } + } else { + next(); } } }); diff --git a/src/utils/request.ts b/src/utils/request.ts index d608c7f..f851b2f 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -40,33 +40,33 @@ // } // 鑾峰彇鏈湴鐨� token - const accessToken = Local.get(accessTokenKey); - if (accessToken) { - // 灏� token 娣诲姞鍒拌姹傛姤鏂囧ご涓� - config.headers!['Authorization'] = `Bearer ${accessToken}`; + // const accessToken = Local.get(accessTokenKey); + // if (accessToken) { + // // 灏� token 娣诲姞鍒拌姹傛姤鏂囧ご涓� + // config.headers!['Authorization'] = `Bearer ${accessToken}`; - // 鍒ゆ柇 accessToken 鏄惁杩囨湡 - const jwt: any = decryptJWT(accessToken); - const exp = getJWTDate(jwt.exp as number); - const isExpired = new Date() >= exp; - // token 宸茬粡杩囨湡 - if (isExpired) { - // 鑾峰彇鍒锋柊 token - const refreshAccessToken = Local.get(refreshAccessTokenKey); + // // 鍒ゆ柇 accessToken 鏄惁杩囨湡 + // const jwt: any = decryptJWT(accessToken); + // const exp = getJWTDate(jwt.exp as number); + // const isExpired = new Date() >= exp; + // // token 宸茬粡杩囨湡 + // if (isExpired) { + // // 鑾峰彇鍒锋柊 token + // const refreshAccessToken = Local.get(refreshAccessTokenKey); - // 鎼哄甫鍒锋柊 token - if (refreshAccessToken) { - config.headers!['X-Authorization'] = `Bearer ${refreshAccessToken}`; - } - } - // get璇锋眰鏄犲皠params鍙傛暟 - if (config.method?.toLowerCase() === 'get' && config.data) { - let url = config.url + '?' + tansParams(config.data); - url = url.slice(0, -1); - config.data = {}; - config.url = url; - } - } + // // 鎼哄甫鍒锋柊 token + // if (refreshAccessToken) { + // config.headers!['X-Authorization'] = `Bearer ${refreshAccessToken}`; + // } + // } + // // get璇锋眰鏄犲皠params鍙傛暟 + // if (config.method?.toLowerCase() === 'get' && config.data) { + // let url = config.url + '?' + tansParams(config.data); + // url = url.slice(0, -1); + // config.data = {}; + // config.url = url; + // } + // } return config; }, (error) => { -- Gitblit v1.9.3