From b9ced5e520f30c1972507293db9d58782d2d2f23 Mon Sep 17 00:00:00 2001 From: betaqi <3188864257@qq.com> Date: Wed, 5 Feb 2025 18:41:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 4 +-- src/api/server/axiosInstance.ts | 4 +-- src/components/dashboard/Edfs-exception.vue | 2 +- .../fileDoc/components/markdownDrawer.vue | 1 - src/pages/layout.vue | 10 +++---- src/pages/system/login/index.vue | 4 +-- src/router/index.ts | 26 +++++++++++++------ 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/.env.development b/.env.development index e8eb91d..d335511 100644 --- a/.env.development +++ b/.env.development @@ -1,2 +1,2 @@ -VITE_BASE_URL = 'http://192.168.1.3:48080' -VITE_SOCKET_SERVER = 'http://192.168.1.3:48080' +VITE_BASE_URL = 'http://192.168.1.3:48081' +VITE_SOCKET_SERVER = 'http://192.168.1.3:48081' diff --git a/src/api/server/axiosInstance.ts b/src/api/server/axiosInstance.ts index 2d53f0a..31aa402 100644 --- a/src/api/server/axiosInstance.ts +++ b/src/api/server/axiosInstance.ts @@ -183,7 +183,7 @@ const createAxiosInstance = (module: APIConfigKeys, config: Config) => { const unKnowError = `连接出错(${error.response.status})!` if (status === 401) { localStorage.removeItem(Keys.STORAGE_TOKEN) - router.push('/file/document') + router.push('/login') } const msg = networkErrMap[status] ? networkErrMap[status] : unKnowError @@ -229,7 +229,7 @@ async function logout() { removeToken() isShowLogout = false deleteUserCache() - window.location.href = '/file/document' + window.location.href = '/login' } export default createAxiosInstance diff --git a/src/components/dashboard/Edfs-exception.vue b/src/components/dashboard/Edfs-exception.vue index 9dd3ed3..d54d32c 100644 --- a/src/components/dashboard/Edfs-exception.vue +++ b/src/components/dashboard/Edfs-exception.vue @@ -10,7 +10,7 @@ type="primary" @click=" () => { - router.push('/file/document') + router.push('/login') } " >返回首页 { - debugger // document.getElementById('exportButton').addEventListener('click', () => { // const content = vditor.getValue() // 获取编辑器内容 // const filename = 'my-exported-document.md' // 定义文件名 diff --git a/src/pages/layout.vue b/src/pages/layout.vue index 254c8d5..c60c0c6 100644 --- a/src/pages/layout.vue +++ b/src/pages/layout.vue @@ -77,7 +77,7 @@ style="--el-switch-on-color: #2c2c2c; --el-switch-off-color: #f2f2f2" @change="toggle" /> - + 退出登录 - --> +
@@ -259,7 +259,7 @@ async function loginOut() { type: 'warning', }) await userStore.loginout() - push('/file/document') + push('/login') } catch {} } diff --git a/src/pages/system/login/index.vue b/src/pages/system/login/index.vue index eed40df..5cc5d38 100644 --- a/src/pages/system/login/index.vue +++ b/src/pages/system/login/index.vue @@ -24,7 +24,7 @@ /> - 登录 @@ -231,7 +231,7 @@ onMounted(() => { color: #333333; margin-bottom: 48px; } - :deep(.el-form-item) { + :deep(.el-form-item) { margin-bottom: 26px; } :deep(.el-input) { diff --git a/src/router/index.ts b/src/router/index.ts index 8a48f47..640f4fe 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -4,6 +4,7 @@ import { useUserStore } from '../stores/user' import { usePermissionStore } from '@/stores/permission' import { useDictStore } from '@/stores/dict' import { getToken } from '@/utils/auth' +import { pa } from 'element-plus/es/locale/index.mjs' export const defaultRoute = [ { @@ -15,6 +16,15 @@ export const defaultRoute = [ title: '404', }, }, + { + path: '/login', + name: 'Login', + component: () => import('@/pages/system/login/index.vue'), + meta: { + hidden: true, + title: '登录', + }, + }, { path: '/file', @@ -59,14 +69,14 @@ const router = createRouter({ const whiteList = ['/login'] router.beforeEach(async (to, from, next) => { - // if (!getToken()) { - // if (whiteList.indexOf(to.path) !== -1) { - // next() - // } else { - // next('/file/document') - // } - // return - // } + if (!getToken()) { + if (whiteList.indexOf(to.path) !== -1) { + next() + } else { + next('/login') + } + return + } if (to.path === '/OnlineDocument') { next('/file/document') return