fix restore BUG, fix edit page alert BUG

This commit is contained in:
KUN1007 2023-06-18 00:03:03 +08:00
parent 733bd6dc1c
commit c4e8070b3d
5 changed files with 10 additions and 29 deletions

View file

@ -16,7 +16,7 @@
"moemoe", "moemoe",
"moemoepoint", "moemoepoint",
"non-moe", "non-moe",
"nprogress",
"persistedstate", "persistedstate",
"Pinia", "Pinia",
"shinnku", "shinnku",

View file

@ -13,25 +13,13 @@ import Background from './components/Background.vue'
// store // store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings' import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
// i18n
import { useI18n } from 'vue-i18n'
// 使 store // 使 store
const settingsStore = useKUNGalgameSettingsStore() const settingsStore = useKUNGalgameSettingsStore()
const { showKUNGalgameMainPageWidth, showKUNGalgameLanguage } = const { showKUNGalgameMainPageWidth } = storeToRefs(settingsStore)
storeToRefs(settingsStore)
const emits = defineEmits(['close']) const emits = defineEmits(['close'])
/*
* 网站的语言设置
*/
const { locale } = useI18n({ useScope: 'global' })
const handleChangeLanguage = () => {
locale.value = showKUNGalgameLanguage.value
}
/* 恢复所有设置为默认 */ /* 恢复所有设置为默认 */
const handleRecover = () => { const handleRecover = () => {
settingsStore.restoreSettings() settingsStore.restoreSettings()

View file

@ -2,6 +2,7 @@
// store // store
import { useKUNGalgameSettingsStore } from '@/store/modules/settings' import { useKUNGalgameSettingsStore } from '@/store/modules/settings'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { watch } from 'vue'
// i18n // i18n
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
@ -14,19 +15,15 @@ const { showKUNGalgameLanguage } = storeToRefs(settingsStore)
*/ */
const { locale } = useI18n({ useScope: 'global' }) const { locale } = useI18n({ useScope: 'global' })
const handleChangeLanguage = () => { watch(showKUNGalgameLanguage, () => {
locale.value = showKUNGalgameLanguage.value locale.value = showKUNGalgameLanguage.value
} })
</script> </script>
<template> <template>
<div class="set-lang"> <div class="set-lang">
<span>{{ $t('header.settings.language') }}</span> <span>{{ $t('header.settings.language') }}</span>
<select <select class="select" v-model="showKUNGalgameLanguage">
class="select"
v-model="showKUNGalgameLanguage"
@change="handleChangeLanguage"
>
<option value="en">English</option> <option value="en">English</option>
<option value="zh">中文</option> <option value="zh">中文</option>
</select> </select>

View file

@ -6,8 +6,6 @@ import { lang, mode } from '@/utils/getDefaultEnv'
// 设置面板配置 // 设置面板配置
interface KUNGalgameSettings { interface KUNGalgameSettings {
// 是否显示设置面板
showKUNGalgamePanel: boolean
// 白天黑夜模式切换 // 白天黑夜模式切换
showKUNGalgameMode: string showKUNGalgameMode: string
// 网站显示语言 // 网站显示语言
@ -25,7 +23,6 @@ export const useKUNGalgameSettingsStore = defineStore({
persist: true, persist: true,
// 默认值 // 默认值
state: (): KUNGalgameSettings => ({ state: (): KUNGalgameSettings => ({
showKUNGalgamePanel: false,
showKUNGalgameMode: mode, showKUNGalgameMode: mode,
showKUNGalgameLanguage: lang, showKUNGalgameLanguage: lang,
showKUNGalgameMainPageWidth: '61.8', showKUNGalgameMainPageWidth: '61.8',
@ -35,7 +32,6 @@ export const useKUNGalgameSettingsStore = defineStore({
actions: { actions: {
// 恢复出厂设置() // 恢复出厂设置()
restoreSettings() { restoreSettings() {
this.showKUNGalgamePanel = false
this.setKUNGalgameTheme('light') this.setKUNGalgameTheme('light')
this.showKUNGalgameLanguage = 'en' this.showKUNGalgameLanguage = 'en'
this.showKUNGalgameMainPageWidth = '61.8' this.showKUNGalgameMainPageWidth = '61.8'

View file

@ -10,20 +10,20 @@ import { ref } from 'vue'
const buttonStatus = ref(false) const buttonStatus = ref(false)
const handlePublish = async () => { const handlePublish = async () => {
const res = await info.alert('AlertInfo.publish', true) const res = await info.alert('AlertInfo.edit.publish', true)
// TODO: // TODO:
// //
if (res) { if (res) {
info.info('AlertInfo.publishSuccess') info.info('AlertInfo.edit.publishSuccess')
} else { } else {
info.info('AlertInfo.publishCancel') info.info('AlertInfo.edit.publishCancel')
} }
} }
const handleSave = () => { const handleSave = () => {
// TODO: // TODO:
// //
info.info('AlertInfo.draft') info.info('AlertInfo.edit.draft')
} }
</script> </script>