2023-05-12 18:23:22 +00:00
|
|
|
|
// KUNGalgame 设置面板的 store
|
|
|
|
|
import { defineStore } from 'pinia'
|
2023-05-26 09:07:35 +00:00
|
|
|
|
|
2023-06-15 15:51:50 +00:00
|
|
|
|
// 网站的默认设置
|
|
|
|
|
import { lang, mode } from '@/utils/getDefaultEnv'
|
|
|
|
|
|
2023-05-26 09:07:35 +00:00
|
|
|
|
// 设置面板配置
|
|
|
|
|
interface KUNGalgameSettings {
|
2023-06-06 16:58:09 +00:00
|
|
|
|
// 白天黑夜模式切换
|
|
|
|
|
showKUNGalgameMode: string
|
2023-05-29 09:18:38 +00:00
|
|
|
|
// 网站显示语言
|
|
|
|
|
showKUNGalgameLanguage: string
|
2023-05-26 09:07:35 +00:00
|
|
|
|
// 主页宽度
|
2023-05-29 09:18:38 +00:00
|
|
|
|
showKUNGalgameMainPageWidth: string
|
2023-05-27 02:39:57 +00:00
|
|
|
|
// 背景图
|
2023-05-29 09:18:38 +00:00
|
|
|
|
showKUNGalgameBackground: string
|
2023-05-30 14:06:30 +00:00
|
|
|
|
// 自定义背景图
|
2023-05-30 14:25:42 +00:00
|
|
|
|
showKUNGalgameCustomBackground: string
|
2023-05-26 09:07:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-29 09:18:38 +00:00
|
|
|
|
export const useKUNGalgameSettingsStore = defineStore({
|
2023-05-30 10:59:54 +00:00
|
|
|
|
id: 'KUNGalgame-settings',
|
2023-05-29 09:18:38 +00:00
|
|
|
|
persist: true,
|
2023-05-30 14:25:42 +00:00
|
|
|
|
// 默认值
|
2023-05-29 09:18:38 +00:00
|
|
|
|
state: (): KUNGalgameSettings => ({
|
2023-06-15 15:51:50 +00:00
|
|
|
|
showKUNGalgameMode: mode,
|
|
|
|
|
showKUNGalgameLanguage: lang,
|
2023-05-29 09:18:38 +00:00
|
|
|
|
showKUNGalgameMainPageWidth: '61.8',
|
|
|
|
|
showKUNGalgameBackground: 'none',
|
2023-05-30 14:25:42 +00:00
|
|
|
|
showKUNGalgameCustomBackground: '',
|
2023-05-29 09:18:38 +00:00
|
|
|
|
}),
|
2023-05-30 14:25:42 +00:00
|
|
|
|
actions: {
|
|
|
|
|
// 恢复出厂设置()
|
|
|
|
|
restoreSettings() {
|
2023-06-06 16:58:09 +00:00
|
|
|
|
this.setKUNGalgameTheme('light')
|
2023-05-30 14:25:42 +00:00
|
|
|
|
this.showKUNGalgameLanguage = 'en'
|
|
|
|
|
this.showKUNGalgameMainPageWidth = '61.8'
|
|
|
|
|
this.showKUNGalgameBackground = 'none'
|
|
|
|
|
this.showKUNGalgameCustomBackground = ''
|
|
|
|
|
},
|
2023-06-06 16:58:09 +00:00
|
|
|
|
// 设置主题,只有两种模式 light 和 dark,light 为 ''
|
|
|
|
|
setKUNGalgameTheme(theme: string) {
|
|
|
|
|
this.showKUNGalgameMode = theme
|
|
|
|
|
document.documentElement.className = theme
|
|
|
|
|
},
|
2023-05-30 14:25:42 +00:00
|
|
|
|
},
|
2023-05-12 18:23:22 +00:00
|
|
|
|
})
|