import { reactive } from "vue"; type IUser = { username?: string /** 会员结束时间 */ membershipEndTime?: string tenantId?: number /** 声部名称 */ subjectNames?: string /** 头像 */ avatar?: string }; type IStatus = "init" | "login" | "logout" | "error"; type IPlatformType = "STUDENT" | "TEACHER" | "WEB"; type IPlatformApi = "/api-student" | "/api-teacher" | "/api-web"; type IProxy = "/gym" | "/colexiu" | "/orchestra"; export const storeData = reactive({ status: "init" as IStatus, /** 用户信息 */ user: {} as IUser, /** 端口 */ platformType: "STUDENT" as IPlatformType, /** api地址前缀 */ platformApi: "/api-student" as IPlatformApi, /** 开发模式api前缀 */ proxy: "" as IProxy, }); /** 初始化 */ export const initStore = (data: storeData) => { Object.assign(storeData, data); }; /** 设置用户信息 */ export const setUserInfo = (user: IUser) => { storeData.status = "login"; storeData.user = user || {}; }; export const setLogout = () => { storeData.status = "logout"; storeData.user = {}; }; export const setLoginError = () => { storeData.status = "error"; storeData.user = {}; };