明树Git Lab

Commit 10974de1 authored by zhanghan's avatar zhanghan

加上全局loading状态

parent ba4efeac
Pipeline #109752 passed with stage
in 20 seconds
......@@ -7,6 +7,13 @@
<title>葛洲坝交投</title>
</head>
<body>
<div id="app-loading" style="display:none;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(255,255,255,0.7);z-index:9999;justify-content:center;align-items:center;">
<div style="display:flex;flex-direction:column;align-items:center;gap:12px;">
<div style="width:36px;height:36px;border:3px solid #e0e0e0;border-top-color:#409eff;border-radius:50%;animation:spin .6s linear infinite;"></div>
<span style="color:#666;font-size:14px;">页面加载中...</span>
</div>
</div>
<style>@keyframes spin{to{transform:rotate(360deg)}}</style>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
......
......@@ -8,6 +8,10 @@ const router = createRouter({
// 路由守卫 - 登录验证
router.beforeEach((to, from, next) => {
// 显示 loading
const loadingEl = document.getElementById('app-loading');
if (loadingEl) loadingEl.style.display = 'flex';
const userStore = useUserStore();
let token = userStore.authToken || sessionStorage.getItem("authToken") || "";
if (!token) {
......@@ -25,4 +29,10 @@ router.beforeEach((to, from, next) => {
}
})
router.afterEach(() => {
// 隐藏 loading
const loadingEl = document.getElementById('app-loading');
if (loadingEl) loadingEl.style.display = 'none';
})
export default router
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment