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-09-28 13:07:12 +00:00
|
|
|
|
// settings store 的类型
|
|
|
|
|
import { KUNGalgameSettingsStore } from '../types/settings'
|
2023-05-26 09:07:35 +00:00
|
|
|
|
|
2023-05-29 09:18:38 +00:00
|
|
|
|
export const useKUNGalgameSettingsStore = defineStore({
|
2023-10-07 08:51:14 +00:00
|
|
|
|
id: 'KUNGalgameSettings',
|
2023-05-29 09:18:38 +00:00
|
|
|
|
persist: true,
|
2023-05-30 14:25:42 +00:00
|
|
|
|
// 默认值
|
2023-09-28 13:07:12 +00:00
|
|
|
|
state: (): KUNGalgameSettingsStore => ({
|
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: {
|
2023-10-07 08:51:14 +00:00
|
|
|
|
KUN: 90,
|
2023-09-09 15:42:55 +00:00
|
|
|
|
Topic: 90,
|
|
|
|
|
Edit: 90,
|
|
|
|
|
KUNGalgame: 90,
|
|
|
|
|
Pool: 90,
|
|
|
|
|
Bylaw: 90,
|
|
|
|
|
Technique: 90,
|
|
|
|
|
ThanksList: 90,
|
|
|
|
|
},
|
2023-09-10 15:12:04 +00:00
|
|
|
|
showKUNGalgameFontStyle: 'system-ui',
|
2023-05-29 09:18:38 +00:00
|
|
|
|
showKUNGalgameBackground: 'none',
|
2023-05-30 14:25:42 +00:00
|
|
|
|
showKUNGalgameCustomBackground: '',
|
2023-09-10 14:05:39 +00:00
|
|
|
|
|
|
|
|
|
isShowPageWidth: true,
|
2023-05-29 09:18:38 +00:00
|
|
|
|
}),
|
2023-05-30 14:25:42 +00:00
|
|
|
|
actions: {
|
2023-06-06 16:58:09 +00:00
|
|
|
|
// 设置主题,只有两种模式 light 和 dark,light 为 ''
|
|
|
|
|
setKUNGalgameTheme(theme: string) {
|
|
|
|
|
this.showKUNGalgameMode = theme
|
|
|
|
|
document.documentElement.className = theme
|
|
|
|
|
},
|
2023-09-10 10:49:47 +00:00
|
|
|
|
// 设置字体,用户自己设置,默认为系统 UI
|
|
|
|
|
setKUNGalgameFontStyle(font: string) {
|
|
|
|
|
this.showKUNGalgameFontStyle = font
|
|
|
|
|
document.documentElement.style.fontFamily = font
|
|
|
|
|
},
|
|
|
|
|
// 恢复所有设置,由于调用了 document,所以 pinia 响应式不生效
|
|
|
|
|
setKUNGalgameSettingsRecover() {
|
|
|
|
|
this.$reset()
|
|
|
|
|
this.setKUNGalgameTheme('')
|
2023-09-10 15:12:04 +00:00
|
|
|
|
this.setKUNGalgameFontStyle('system-ui')
|
2023-09-10 10:49:47 +00:00
|
|
|
|
},
|
2023-05-30 14:25:42 +00:00
|
|
|
|
},
|
2023-05-12 18:23:22 +00:00
|
|
|
|
})
|