import { defineStore } from "pinia"; import { ref, computed } from "vue"; // 分析相关 状态存储 export interface FilterObject { subjectCode: string; subjectName: string; subjectId: string; subjectGroupType: number; isTotal: boolean; subjectGroupCodes: string; schoolId: string; schoolLevel: string; schoolGroupId: string; schoolGroupName: string | null; schoolName: string | null; schoolGroupNames: string; registrationType: string; registrationName: string | null; registrationGroupId: string; statusGroupNames: string; scoreType: string; classType: string; classIdCode: string; classLevel: string | number; classGroupId: string; classGroupName: string; classGroupNames: string[]; } //用户相关的状态管理 export const useAnalysisStore = defineStore("analysis", () => { const filterObject = ref( JSON.parse(localStorage.getItem("filterObject") || "{}"), ); const analysisExamInfo = ref( JSON.parse(localStorage.getItem("analysisExamInfo") || "{}"), ); // 新增:设置公共参数 const setFilterObject = (info: FilterObject) => { filterObject.value = info; // 同步存储到 localStorage,确保持久化 localStorage.setItem("filterObject", JSON.stringify(info)); } const setAnalysisExamInfo = (info: any) => { analysisExamInfo.value = info; // 同步存储到 localStorage,确保持久化 localStorage.setItem("analysisExamInfo", JSON.stringify(info)); } return { filterObject, analysisExamInfo, setFilterObject, setAnalysisExamInfo }; });