394c6ce20c
Squashed commit of the following: commit 632f86c0228c68391c01865c7576f3aa0408c102 Author: Sun <95302870@qq.com> Date: Sun Jan 7 14:47:55 2024 +0800 退出的时候清除appstore commit b9d805e49a3c6b2ad38bc8d527cb12cc8709012e Author: Sun <95302870@qq.com> Date: Sun Jan 7 13:55:20 2024 +0800 系统状态监控适配国际化 commit daece99723ec96d210241d2ca4e5a85dc5ae69bd Author: Sun <95302870@qq.com> Date: Sun Jan 7 13:09:46 2024 +0800 适配添加项目页面的国际化配置还有时钟的星期* commit 8ea2b2fe951f6266415c96a197cb8d00faef4058 Author: Sun <95302870@qq.com> Date: Sun Jan 7 12:01:55 2024 +0800 完成适配所有apps国际化 commit 21ef54e0d4afb10f560c8cb7aff666374afe0f87 Author: Sun <95302870@qq.com> Date: Sat Jan 6 21:36:07 2024 +0800 增加读取默认浏览器语言 commit 6f710bbebe63ab2800193f27c71e5c0034f11978 Author: Sun <95302870@qq.com> Date: Sat Jan 6 21:09:58 2024 +0800 登录页面增加语言选择选项 commit cb7c4a89a160ed3ef91ad566ec98e75325e7601f Author: Sun <95302870@qq.com> Date: Sat Jan 6 20:37:16 2024 +0800 首次尝试增加英文语言,并在我的信息设置 commit fb996e17cd11611d30c0e12feee00ddf7b225e32 Author: Sun <95302870@qq.com> Date: Sat Jan 6 18:22:40 2024 +0800 完成基础设置页面的语言国际化适配
40 lines
918 B
TypeScript
40 lines
918 B
TypeScript
import { defineStore } from 'pinia'
|
|
import type { AppState, Language, Theme } from './helper'
|
|
import { defaultSetting, getLocalSetting, removeLocalState, setLocalSetting } from './helper'
|
|
import { store } from '@/store'
|
|
|
|
export const useAppStore = defineStore('app-store', {
|
|
state: (): AppState => getLocalSetting(),
|
|
actions: {
|
|
setSiderCollapsed(collapsed: boolean) {
|
|
this.siderCollapsed = collapsed
|
|
this.recordState()
|
|
},
|
|
|
|
setTheme(theme: Theme) {
|
|
this.theme = theme
|
|
this.recordState()
|
|
},
|
|
|
|
setLanguage(language: Language) {
|
|
if (this.language !== language) {
|
|
this.language = language
|
|
this.recordState()
|
|
}
|
|
},
|
|
|
|
recordState() {
|
|
setLocalSetting(this.$state)
|
|
},
|
|
|
|
removeToken() {
|
|
this.$state = defaultSetting()
|
|
removeLocalState()
|
|
},
|
|
},
|
|
})
|
|
|
|
export function useAppStoreWithOut() {
|
|
return useAppStore(store)
|
|
}
|