From e787fb4fab3527ca927d78ef922b06fc2fcd98f6 Mon Sep 17 00:00:00 2001 From: sunzhuangzhuang <961120009@qq.com> Date: Mon, 25 Aug 2025 17:04:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=B4=E6=8A=A4=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/router/index.js b/src/router/index.js index 69975ee..39671eb 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,6 +1,7 @@ import { createRouter, createWebHistory } from 'vue-router' import { useUserStore } from '@/stores/user' import NProgress from 'nprogress' +import api from '@/utils/api' const routes = [ { @@ -262,6 +263,31 @@ router.beforeEach(async (to, from, next) => { document.title = `${to.meta.title} - 炬融圈` } + // 检查维护模式 + try { + const {data} = await api.get('/system/maintenance-status', { showLoading: false }) + console.log(data,'data'); + + if (data.success) { + if (data.data.maintenance_mode) { + // 维护模式开启,且不在维护页面,跳转到维护页面 + if (to.name !== 'Loading') { + next({ name: 'Loading' }) + return + } + } else { + // 维护模式关闭,且在维护页面,跳转到首页 + if (to.name === 'Loading') { + next({ name: 'MainPage' }) + return + } + } + } + } catch (error) { + // 如果检查维护状态失败,继续正常流程 + console.warn('检查维护状态失败:', error) + } + // 检查是否需要认证 if (to.meta.requiresAuth) { // 检查是否是代理页面