mirror of https://github.com/halo-dev/halo-admin
refactor: refactoring the logic for get the setup state of the system (#686)
#### What type of PR is this? /kind improvement /milestone 2.0 #### What this PR does / why we need it: 重构获取系统初始化状态的方式,之前会在每个路由切换前获取,在一定程度上会导致路由切换时卡顿。此 PR 改为仅在首次加载页面的时候调用接口获取,并保留状态由 pinia 管理。 #### Special notes for your reviewer: 测试方式: 1. 需要使用未初始化的 Halo。 2. 测试在未初始化前是否会自动切换到初始化页面。 3. 测试初始化之后是否还会跳转到初始化页面。 #### Does this PR introduce a user-facing change? ```release-note None ```pull/687/head
parent
fdf964b18d
commit
e0ca6186ab
|
@ -18,6 +18,7 @@ import { hasPermission } from "@/utils/permission";
|
|||
import { useRoleStore } from "@/stores/role";
|
||||
import type { RouteRecordRaw } from "vue-router";
|
||||
import { useThemeStore } from "./stores/theme";
|
||||
import { useSystemStatesStore } from "./stores/system-states";
|
||||
|
||||
const app = createApp(App);
|
||||
|
||||
|
@ -240,6 +241,9 @@ async function initApp() {
|
|||
} catch (e) {
|
||||
console.error("Failed to load plugins", e);
|
||||
}
|
||||
|
||||
const systemStateStore = useSystemStatesStore();
|
||||
await systemStateStore.fetchSystemStates();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} finally {
|
||||
|
|
|
@ -10,8 +10,6 @@ export function setupCheckStatesGuard(router: Router) {
|
|||
|
||||
const systemStateStore = useSystemStatesStore();
|
||||
|
||||
await systemStateStore.fetchSystemStates();
|
||||
|
||||
if (!systemStateStore.states.isSetup) {
|
||||
next({ name: "Setup" });
|
||||
return;
|
||||
|
|
|
@ -92,6 +92,9 @@ const handleSubmit = async () => {
|
|||
},
|
||||
});
|
||||
|
||||
const systemStateStore = useSystemStatesStore();
|
||||
await systemStateStore.fetchSystemStates();
|
||||
|
||||
router.push({ name: "Dashboard" });
|
||||
} catch (error) {
|
||||
console.error("Failed to setup", error);
|
||||
|
|
Loading…
Reference in New Issue