From 0704c6da0ca340a579cf9131ac5a1cbe7d7c5994 Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Wed, 9 Oct 2024 16:18:48 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/boot/axios.ts | 19 ++++++++++++++++ src/router/routes.ts | 7 ++---- src/stores/auth-store.ts | 48 ++++++++++++++++++++-------------------- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 5ded5ed..9f28b69 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -67,6 +67,7 @@ export class ApiError { // for each client) const api = axios.create({ baseURL: getHttpBase() }); let isOpenDialog = false; // 认证弹窗是否打开 +let quanXianDialog = false; // 权限提示弹窗是否打开 const CancelToken = axios.CancelToken; const source = CancelToken.source(); @@ -107,6 +108,24 @@ export default boot(({ app, router }) => { .onCancel(() => { isOpenDialog = false; }); + } else if ( + err.response && + err.response.status === 403 && + !quanXianDialog + ) { + quanXianDialog = true; + Dialog.create({ + title: '无权限', + message: '你没有改页面访问权限', + persistent: true, + }) + .onOk(() => { + router.push({ name: 'login' }); + quanXianDialog = false; + }) + .onCancel(() => { + quanXianDialog = false; + }); } return Promise.reject(ApiError.from(err)); } diff --git a/src/router/routes.ts b/src/router/routes.ts index 0e80000..40ec965 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -1,7 +1,7 @@ import { RouteRecordRaw } from 'vue-router'; -export const admin = '1'; // 超级管理员 -export const user = '2'; // 普通用户 +// export const admin = '1'; // 超级管理员 +// export const user = '2'; // 普通用户 export const routes: RouteRecordRaw[] = [ { @@ -35,7 +35,6 @@ export const asyncRoutes: RouteRecordRaw[] = [ name: 'sysManage', component: () => import('layouts/MainLayout.vue'), meta: { - roles: [admin], label: '系统管理', icon: 'dataset', }, @@ -74,7 +73,6 @@ export const asyncRoutes: RouteRecordRaw[] = [ name: 'dataManage', component: () => import('layouts/MainLayout.vue'), meta: { - roles: [admin], label: '数据管理', icon: 'list_alt', }, @@ -140,7 +138,6 @@ export const asyncRoutes: RouteRecordRaw[] = [ name: 'testManage', component: () => import('layouts/MainLayout.vue'), meta: { - roles: [admin, user], label: '测试管理', icon: 'format_list_bulleted', }, diff --git a/src/stores/auth-store.ts b/src/stores/auth-store.ts index 820149d..efd354b 100644 --- a/src/stores/auth-store.ts +++ b/src/stores/auth-store.ts @@ -1,8 +1,8 @@ import { defineStore } from 'pinia'; import { PathItem } from 'src/api/AuthApi'; import { AuthInfo, getCurrentUserInfo } from 'src/api/UserApi'; -import { MethodType } from 'src/components/AuthData'; -import { asyncRoutes, admin } from 'src/router/routes'; +// import { MethodType } from 'src/components/AuthData'; +import { asyncRoutes } from 'src/router/routes'; import { RouteRecordRaw } from 'vue-router'; export const useAuthStore = defineStore('auth', { @@ -43,28 +43,28 @@ export const useAuthStore = defineStore('auth', { }); }); }, - getHasAuth(path: string, method: MethodType): boolean { - if (this.currentRolesList.includes(admin)) { - return true; - } - let s = false; - const someP = this.currentPathsList.some((item) => { - const p = '^' + item.path; - const regP = new RegExp(p); - const hasP = regP.test(path); - let hasM = false; - if (item.method == '*') { - hasM = true; - } else { - hasM = item.method.includes(method); - } - return hasP && hasM; - }); - if (someP) { - s = true; - } - return s; - }, + // getHasAuth(path: string, method: MethodType): boolean { + // // if (this.currentRolesList.includes(admin)) { + // // return true; + // // } + // let s = false; + // const someP = this.currentPathsList.some((item) => { + // const p = '^' + item.path; + // const regP = new RegExp(p); + // const hasP = regP.test(path); + // let hasM = false; + // if (item.method == '*') { + // hasM = true; + // } else { + // hasM = item.method.includes(method); + // } + // return hasP && hasM; + // }); + // if (someP) { + // s = true; + // } + // return s; + // }, GenerateRoutes() { // 生成动态路由 function hasPermission(metaRoles: string[], roles: string[]): boolean { From 0882a88c0ab31e093da250f909793dcdf3586a9e Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Wed, 9 Oct 2024 16:56:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=9D=83=E9=99=90=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/boot/axios.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 9f28b69..ef4b92f 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -116,11 +116,10 @@ export default boot(({ app, router }) => { quanXianDialog = true; Dialog.create({ title: '无权限', - message: '你没有改页面访问权限', + message: '你没有该页面访问权限', persistent: true, }) .onOk(() => { - router.push({ name: 'login' }); quanXianDialog = false; }) .onCancel(() => { From dacebbc9ff4e88186cfc783fdb3db729ccbd4c08 Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Wed, 9 Oct 2024 17:46:51 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/line-app/dialogs/ConnectInfoDialog.vue | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/line-app/dialogs/ConnectInfoDialog.vue b/src/components/line-app/dialogs/ConnectInfoDialog.vue index f98c20a..7a9bd9f 100644 --- a/src/components/line-app/dialogs/ConnectInfoDialog.vue +++ b/src/components/line-app/dialogs/ConnectInfoDialog.vue @@ -43,6 +43,8 @@ enum Type { '动力学', '半实物列车', '列车PC仿真', + '联锁通信服务', + '计轴区段通信服务', } const columns: QTable['columns'] = [ {