🐛 Fix: i18n bug

This commit is contained in:
PiEgg
2023-01-07 20:45:01 +08:00
parent 66d8d714db
commit 911e34e98d
9 changed files with 36 additions and 17 deletions

View File

@@ -1,4 +1,4 @@
import { reactive, InjectionKey, readonly, App, UnwrapRef } from 'vue'
import { reactive, InjectionKey, readonly, App, UnwrapRef, ref } from 'vue'
import { saveConfig } from '@/utils/dataSender'
export interface IState {
@@ -8,6 +8,7 @@ export interface IState {
export interface IStore {
state: UnwrapRef<IState>
setDefaultPicBed: (type: string) => void;
updateForceUpdateTime: () => void;
}
export const storeKey: InjectionKey<IStore> = Symbol('store')
@@ -17,6 +18,8 @@ const state: IState = reactive({
defaultPicBed: 'smms'
})
const forceUpdateTime = ref<number>(Date.now())
// methods
const setDefaultPicBed = (type: string) => {
saveConfig({
@@ -24,14 +27,19 @@ const setDefaultPicBed = (type: string) => {
'picBed.uploader': type
})
state.defaultPicBed = type
console.log(state)
}
const updateForceUpdateTime = () => {
forceUpdateTime.value = Date.now()
}
export const store = {
install (app: App) {
app.provide(storeKey, {
state: readonly(state),
setDefaultPicBed
setDefaultPicBed,
updateForceUpdateTime
})
app.provide('forceUpdateTime', forceUpdateTime)
}
}