niucloud/uni-app/stores/system.ts
全栈小学生 89abab8153 uni-app
2023-05-31 11:34:01 +08:00

29 lines
727 B
TypeScript

import { defineStore } from 'pinia'
import { getSiteInfo } from '@/api/system'
import { redirect } from '@/utils/common'
interface System {
site: AnyObject | null
}
const useSystemStore = defineStore('system', {
state: () : System => {
return {
site: null
}
},
actions: {
async getSitenfo() {
await getSiteInfo()
.then((res: any) => {
this.site = res.data
if (this.site.status == 3) redirect({ url: '/pages/index/close', mode: 'reLaunch' })
})
.catch((err) => {
redirect({ url: '/pages/index/nonexistence', mode: 'reLaunch' })
})
}
}
})
export default useSystemStore