kun-galgame-vue/src/store/modules/settings.ts

49 lines
1.2 KiB
TypeScript
Raw Normal View History

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
// 网站的默认设置
2023-08-20 13:38:40 +00:00
import { KUNGalgameLanguage, mode } from '@/utils/getDefaultEnv'
2023-06-15 15:51:50 +00:00
2023-05-26 09:07:35 +00:00
// 设置面板配置
interface KUNGalgameSettings {
2023-06-06 16:58:09 +00:00
// 白天黑夜模式切换
showKUNGalgameMode: string
// 网站显示语言
showKUNGalgameLanguage: string
2023-05-26 09:07:35 +00:00
// 主页宽度
2023-09-09 15:42:55 +00:00
showKUNGalgamePageWidth: Record<string, number>
2023-05-27 02:39:57 +00:00
// 背景图
showKUNGalgameBackground: string
2023-05-30 14:06:30 +00:00
// 自定义背景图
showKUNGalgameCustomBackground: string
2023-05-26 09:07:35 +00:00
}
export const useKUNGalgameSettingsStore = defineStore({
id: 'KUNGalgame-settings',
persist: true,
// 默认值
state: (): KUNGalgameSettings => ({
2023-06-15 15:51:50 +00:00
showKUNGalgameMode: mode,
2023-08-20 13:38:40 +00:00
showKUNGalgameLanguage: KUNGalgameLanguage,
2023-09-09 15:42:55 +00:00
showKUNGalgamePageWidth: {
KUN: 61.8,
Topic: 90,
Edit: 90,
KUNGalgame: 90,
Pool: 90,
Bylaw: 90,
Technique: 90,
ThanksList: 90,
},
showKUNGalgameBackground: 'none',
showKUNGalgameCustomBackground: '',
}),
actions: {
2023-06-06 16:58:09 +00:00
// 设置主题,只有两种模式 light 和 darklight 为 ''
setKUNGalgameTheme(theme: string) {
this.showKUNGalgameMode = theme
document.documentElement.className = theme
},
},
2023-05-12 18:23:22 +00:00
})