From 77615cddef5f08d334591bf5e0108c7eb6290d1c Mon Sep 17 00:00:00 2001 From: liaoboping <344114999@qq.com> Date: Sat, 13 Sep 2025 18:19:33 +0800 Subject: [PATCH] =?UTF-8?q?openThirdLogin=EF=BC=8C=E8=AF=84=E4=BC=B0?= =?UTF-8?q?=E5=BC=B9=E7=AA=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- src/config/defaultSettings.js | 2 +- src/permission.js | 15 ++++++++++++--- src/store/modules/user.js | 2 +- src/utils/openThirdLogin.js | 2 +- src/utils/request.js | 7 ++++++- .../instructor/system/evaluation/index.vue | 13 +++++++++++++ .../trainer/system/evaluation/index.vue | 15 ++++++++++++++- 8 files changed, 49 insertions(+), 9 deletions(-) diff --git a/public/index.html b/public/index.html index de700f6..c4fb356 100644 --- a/public/index.html +++ b/public/index.html @@ -5,7 +5,7 @@ - 数字化试验训练系统 + 某仿真分析方法工具 diff --git a/src/config/defaultSettings.js b/src/config/defaultSettings.js index b6e3541..df3d8ee 100644 --- a/src/config/defaultSettings.js +++ b/src/config/defaultSettings.js @@ -23,7 +23,7 @@ export default { menu: { locale: true }, - title: '数字化试验训练系统', + title: '某仿真分析方法工具', pwa: false, iconfontUrl: '', production: process.env.NODE_ENV === 'production' && process.env.VUE_APP_PREVIEW !== 'true' diff --git a/src/permission.js b/src/permission.js index b47ceab..340d02c 100644 --- a/src/permission.js +++ b/src/permission.js @@ -7,12 +7,13 @@ import NProgress from 'nprogress' // progress bar import storage from 'store' import router from './router' import store from './store' +import openThirdLogin from './utils/openThirdLogin' NProgress.configure({ showSpinner: false }) // NProgress Configuration const allowList = ['thirdLogin', 'login', 'register', 'registerResult'] // no redirect allowList const loginRoutePath = '/user/login' -const defaultRoutePath = '/simulationScene' +const defaultRoutePath = '/user/thirdLogin' router.beforeEach((to, from, next) => { NProgress.start() // start progress bar @@ -58,7 +59,11 @@ router.beforeEach((to, from, next) => { }) // 失败时,获取用户信息失败时,调用登出,来清空历史保留信息 store.dispatch('Logout').then(() => { - next({ path: loginRoutePath, query: { redirect: to.fullPath } }) + if (process.env.NODE_ENV === 'production') { + openThirdLogin() + } else { + next({ path: loginRoutePath, query: { redirect: to.fullPath } }) + } }) }) } else { @@ -70,7 +75,11 @@ router.beforeEach((to, from, next) => { // 在免登录名单,直接进入 next() } else { - next({ path: loginRoutePath, query: { redirect: to.fullPath } }) + if (process.env.NODE_ENV === 'production') { + openThirdLogin() + } else { + next({ path: loginRoutePath, query: { redirect: to.fullPath } }) + } NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it } } diff --git a/src/store/modules/user.js b/src/store/modules/user.js index be202ff..7f8be0d 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -59,7 +59,7 @@ const user = { } if (result.roles && result.permissions.length > 0) { const role = result.roles - role.permissions = result.permissions + role.permissions = result.permissions.filter(item => item) role.permissions.map(per => { if (per.actionEntitySet != null && per.actionEntitySet.length > 0) { const action = per.actionEntitySet.map(action => { return action.action }) diff --git a/src/utils/openThirdLogin.js b/src/utils/openThirdLogin.js index ae8d028..fdd5771 100644 --- a/src/utils/openThirdLogin.js +++ b/src/utils/openThirdLogin.js @@ -1,5 +1,5 @@ export default () => { - const redirectUri = window.location.origin + window.location.pathname + const redirectUri = window.location.origin + '/user/thirdLogin' window.location.href = window._CONFIG.thirdLoginUrl + '?response_type=code&active_type=user&state=' + diff --git a/src/utils/request.js b/src/utils/request.js index 4dfd455..68278c2 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -5,6 +5,7 @@ import storage from 'store' import notification from 'ant-design-vue/es/notification' import { VueAxios } from './axios' import { ACCESS_TOKEN } from '@/store/mutation-types' +import openThirdLogin from './openThirdLogin' // 创建 axios 实例 const request = axios.create({ @@ -34,7 +35,11 @@ const errorHandler = (error) => { if (token) { store.dispatch('Logout').then(() => { setTimeout(() => { - window.location.reload() + if (process.env.NODE_ENV === 'production') { + openThirdLogin() + } else { + window.location.reload() + } }, 1500) }) } diff --git a/src/views/simulationScene/instructor/system/evaluation/index.vue b/src/views/simulationScene/instructor/system/evaluation/index.vue index 3e433ce..e64e6a3 100644 --- a/src/views/simulationScene/instructor/system/evaluation/index.vue +++ b/src/views/simulationScene/instructor/system/evaluation/index.vue @@ -10,10 +10,23 @@ export default { data() { return { src: window._CONFIG.evaluationSrc, + child: null, } }, created() { this.$bus.$emit('set-instructor-system-title', '评估子系统') + this.child = window.open( + this.src, + 'newwindow', + 'height=' + + window.screen.height + + ', width=' + + window.screen.width + + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no' + ) + }, + beforeDestroy() { + this.child && this.child.close() }, } diff --git a/src/views/simulationScene/trainer/system/evaluation/index.vue b/src/views/simulationScene/trainer/system/evaluation/index.vue index e3389fa..bef161d 100644 --- a/src/views/simulationScene/trainer/system/evaluation/index.vue +++ b/src/views/simulationScene/trainer/system/evaluation/index.vue @@ -1,6 +1,6 @@ @@ -10,10 +10,23 @@ export default { data() { return { src: window._CONFIG.evaluationSrc, + child: null, } }, created() { this.$bus.$emit('set-trainer-system-title', '评估子系统') + this.child = window.open( + this.src, + 'newwindow', + 'height=' + + window.screen.height + + ', width=' + + window.screen.width + + ', top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=n o, status=no' + ) + }, + beforeDestroy() { + this.child && this.child.close() }, }