fix: 修复企业管理模式下,切换用户登录后,丢失项目列表的bug

This commit is contained in:
xiaojunnuo
2026-03-08 01:53:46 +08:00
parent 00c0dcc81d
commit d23c8b4a2a

View File

@@ -15,11 +15,18 @@ export type ProjectItem = {
export const useProjectStore = defineStore("app.project", () => {
const myProjects = ref([]);
const inited = ref(false);
const currentProjectId = ref(); // 直接调用
function $reset() {
myProjects.value = [];
currentProjectId.value = "";
inited.value = false;
}
const userStore = useUserStore();
const userId = userStore.getUserInfo?.id;
const lastProjectIdCacheKey = "currentProjectId:" + userId;
const lastProjectId = LocalStorage.get(lastProjectIdCacheKey);
const currentProjectId = ref(lastProjectId); // 直接调用
currentProjectId.value = lastProjectId;
const projects = computed(() => {
return myProjects.value;
@@ -118,11 +125,6 @@ export const useProjectStore = defineStore("app.project", () => {
return false;
}
function $reset() {
myProjects.value = [];
currentProjectId.value = "";
}
return {
projects,
myProjects,