This commit is contained in:
xiaozhiyong
2026-06-11 17:09:20 +08:00
parent abe40c5ae9
commit 082b766349
15 changed files with 854 additions and 391 deletions

View File

@@ -2,7 +2,8 @@ import { createPinia } from 'pinia'
import { useAppStore } from '@/pinia/modules/app'
import { useUserStore } from '@/pinia/modules/user'
import { useDictionaryStore } from '@/pinia/modules/dictionary'
import { useProjectStore } from '@/pinia/modules/project'
const store = createPinia()
export { store, useAppStore, useUserStore, useDictionaryStore }
export { store, useAppStore, useUserStore, useDictionaryStore, useProjectStore }

View File

@@ -0,0 +1,26 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'
const PROJECT_STORAGE_KEY = 'masterStation_current_project_id'
export const useProjectStore = defineStore('project', () => {
const currentProject = ref(null)
const setCurrentProject = (project) => {
currentProject.value = project || null
if (project?.id) {
localStorage.setItem(PROJECT_STORAGE_KEY, String(project.id))
}
}
const getSavedProjectId = () => {
const savedId = Number(localStorage.getItem(PROJECT_STORAGE_KEY))
return savedId || null
}
return {
currentProject,
setCurrentProject,
getSavedProjectId
}
})