123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- import { reactive } from "vue";
- type IUser = {
- username?: string;
- nickname?: string;
- /** 真实姓名 */
- realName?: string;
- tenantId?: number;
- /** 声部名称 */
- subjectId?: any;
- subjectNames?: string;
- subjectName?: string;
- /** 头像 */
- avatar?: string;
- memberRankSettingId?: number;
- id?: string | number;
- clientType?: "BACKEND" | "SCHOOL" | "TEACHER" | "STUDENT";
- phone?: string;
- schoolInfos?: any[];
- // 当前用户 绑定 的乐器
- instrumentId?: string;
- // 如果学生的声部是打击乐,打击乐可能会有多个乐器id,
- specialInstrumentIds?: any[];
- // 性别
- gender?: 1|0;
- // vip类型 VIP:会员 SVIP:SVIP,PERMANENT_SVIP:永久SVIP,NOT_VIP:不是vip
- vipType?: string;
- };
- type IStatus = "init" | "login" | "logout" | "error";
- type IPlatformType = "STUDENT" | "TEACHER" | "WEB" | "";
- type IPlatformApi = "/api-student" | "/api-teacher" | "/api-web" | "/api-backend" | "/edu-app" | "/cbs-app";
- type IProxy = "" | "/gym" | "/colexiu" | "/orchestra" | "/instrument";
- export interface IStoreData {
- platformType: IPlatformType;
- platformApi: IPlatformApi;
- proxy: IProxy;
- isApp: boolean;
- isTeacher: boolean;
- }
- 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,
- /** 是否在APP中 */
- isApp: false,
- /** 是否是老师端 */
- isTeacher: false,
- });
- /** 初始化 */
- export const setStoreData = (data: IStoreData) => {
- 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 = {};
- };
|