diff --git a/src/pages/base/components/XsPicker/index.vue b/src/pages/base/components/XsPicker/index.vue index 853fed9..613cd54 100644 --- a/src/pages/base/components/XsPicker/index.vue +++ b/src/pages/base/components/XsPicker/index.vue @@ -60,7 +60,7 @@ diff --git a/src/pages/base/home/xsXz.vue b/src/pages/base/home/xsXz.vue index 193b2b0..1814a2e 100644 --- a/src/pages/base/home/xsXz.vue +++ b/src/pages/base/home/xsXz.vue @@ -16,9 +16,12 @@ import XsPicker from "@/pages/base/components/XsPicker/index.vue" import { useDataStore } from "@/store/modules/data"; import { useUserStore } from "@/store/modules/user"; const { getGlobal } = useDataStore(); -const { checkXqk, checkJlb } = useUserStore(); +const { checkXqk, checkJlb, setXsPickerInitialized } = useUserStore(); const switchXs = (xs: any) => { + // 设置学生选择器已初始化标记 + setXsPickerInitialized(true); + if (getGlobal.type == 1) { checkXqk(); } else if (getGlobal.type == 2) { diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index cc1954e..43875b1 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -19,6 +19,7 @@ interface UserState { changeTime: string; // 权限变更时间 ws: any; wsCallback: any; + xsPickerInitialized: boolean; // 学生选择器是否已初始化 } export const useUserStore = defineStore({ @@ -36,7 +37,8 @@ export const useUserStore = defineStore({ refreshInterval: 7 * 24 * 60 * 60 * 1000, // 刷新间隔(毫秒) changeTime: '', // 权限变更时间 ws: null, - wsCallback: defWsCallback + wsCallback: defWsCallback, + xsPickerInitialized: false // 学生选择器是否已初始化 }), getters: { getToken(): string { @@ -59,6 +61,9 @@ export const useUserStore = defineStore({ }, getChangeTime(): string { return this.changeTime; + }, + getXsPickerInitialized(): boolean { + return this.xsPickerInitialized; } }, actions: { @@ -83,6 +88,9 @@ export const useUserStore = defineStore({ setChangeTime(changeTime: string) { this.changeTime = changeTime; }, + setXsPickerInitialized(initialized: boolean) { + this.xsPickerInitialized = initialized; + }, // 更新学生信息 updateStudentInfo(studentInfo: any) { this.setCurXs(studentInfo); @@ -186,6 +194,8 @@ export const useUserStore = defineStore({ } else { this.setCurXs({}) } + // 重置学生选择器初始化标记 + this.setXsPickerInitialized(false); if (value[AUTH_KEY]) { this.setToken(value[AUTH_KEY]) } @@ -389,6 +399,7 @@ export const useUserStore = defineStore({ this.setUser('') this.setCurXs({}) this.setAuth([]) + this.setXsPickerInitialized(false); // 注销时重置学生选择器状态 if (this.ws) { this.ws.closeConnect(); this.ws = null;