12345678910111213141516171819202122232425262728293031323334353637383940 |
- import {defineStore} from 'pinia'
- import pinia from "../store/init"
- import config from '../config/index';
- import {clearStorage,getStorage, setStorage,} from "@/utils/storage";
- export const useAppStore = defineStore('main', {
- //getStorage, setStorage,
- state: () => ({
- onUpdate: null,
- //用户信息
- tenantId: config.tenantId,
- userInfo: getStorage('userInfo') ?? {},
- }),
- actions: {
- setOnUpdate(value) {
- this.onUpdate = value
- },
- //用户信息
- setTenantId(value) {
- this.tenantId = value
- setStorage('tenantId', value)
- },
- setUserInfo(value) {
- this.userInfo = value
- setStorage('userInfo', value)
- },
- //清除缓存和token
- clearStoreData() {
- this.onUpdate = null
- //用户信息
- this.tenantId = config.tenantId
- this.userInfo = {}
- clearStorage()
- },
- }
- })
- export default function useUserStoreWidthOut() {
- return useAppStore(pinia);
- }
|