Fix MainContainer beforeRouteEnter missing try-catch and next() call

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 07:43:17 +08:00
parent 2768b5d052
commit fba2efe21e
2 changed files with 103 additions and 3 deletions

View File

@@ -23,7 +23,7 @@ import Loading from '@/components/Loading.vue';
import { leaveFilter, leaveConformance } from '@/module/alertModal.js';
import PageAdminStore from '@/stores/pageAdmin.js';
import LoginStore from "@/stores/login.ts";
import { getCookie } from "@/utils/cookieUtil.js";
import { getCookie, setCookie } from "@/utils/cookieUtil.js";
import ModalContainer from './AccountManagement/ModalContainer.vue';
export default {
@@ -109,8 +109,19 @@ export default {
if (!getCookie("isLuciaLoggedIn")) { //這裡不要用pinia的isLoggedIn來檢查因為會有重新整理時撈不到Persisted value的值的bug
if (getCookie('luciaRefreshToken')) {
await loginStore.refreshToken();
loginStore.setIsLoggedIn(true);
try {
await loginStore.refreshToken();
loginStore.setIsLoggedIn(true);
setCookie("isLuciaLoggedIn", "true");
next();
} catch(error) {
next({
path: '/login',
query: {
'return-to': btoa(window.location.href),
}
});
}
} else {
next({
path: '/login',