/** * 小程序信息 store */ import {defineStore} from 'pinia'; import {getMpInfo} from '@/api/layout'; import type {MpInfo} from "@/api/cms/mp/model"; export interface UserState { mpInfo: MpInfo | null; } export const useMpStore = defineStore({ id: 'mp', state: (): UserState => ({ // 小程序 mpInfo: null, }), getters: {}, actions: { /** * 请求用户信息、权限、角色、菜单 */ async fetchMpInfo() { const info = await getMpInfo().catch((err => { console.log(err.code,'fetchMpInfo()') })); if (!info) { return {}; } // 租户信息 this.mpInfo = info; return info; }, /** * 更新租户信息 */ setInfo(value: MpInfo) { this.mpInfo = value; } } });