|
@@ -14,6 +14,7 @@ interface MainStoreState {
|
|
|
newMsgs: { newCount: number; messages: any[] }
|
|
|
online: boolean
|
|
|
lockScreenStatus: boolean
|
|
|
+ keepAliveViews: any[]
|
|
|
}
|
|
|
|
|
|
interface MainStoreActions {
|
|
@@ -23,6 +24,8 @@ interface MainStoreActions {
|
|
|
setNewMsgs: (msgData: { newCount: number; messages: any[] }) => void
|
|
|
setOnline: (bool: boolean) => void
|
|
|
setLockScreen: (bool: boolean) => void
|
|
|
+ setKeepAliveViews: (name: string) => void
|
|
|
+ cutKeepAliveViews: (name: string) => void
|
|
|
}
|
|
|
|
|
|
const useMainStore = defineStore<'main', MainStoreState, Record<string, any>, MainStoreActions>('main', {
|
|
@@ -45,9 +48,21 @@ const useMainStore = defineStore<'main', MainStoreState, Record<string, any>, Ma
|
|
|
newMsgs: { newCount: 0, messages: [] },
|
|
|
online: true,
|
|
|
lockScreenStatus: false,
|
|
|
+ keepAliveViews: ['MainLayout'],
|
|
|
}
|
|
|
},
|
|
|
actions: {
|
|
|
+ setKeepAliveViews(name) {
|
|
|
+ if (!this.keepAliveViews.includes(name)) {
|
|
|
+ this.keepAliveViews.push(name)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ cutKeepAliveViews(name) {
|
|
|
+ const index = this.keepAliveViews.indexOf(name)
|
|
|
+ if (index > -1) {
|
|
|
+ this.keepAliveViews.splice(index, 1)
|
|
|
+ }
|
|
|
+ },
|
|
|
setLockScreen(bool: boolean) {
|
|
|
this.lockScreenStatus = !!bool
|
|
|
},
|