Feature(custom): update i18n force update

This commit is contained in:
Kuingsmile
2024-06-13 11:13:58 +08:00
parent 5ddc182bd1
commit e9c386d5d8
14 changed files with 54 additions and 91 deletions

View File

@@ -1,8 +1,7 @@
import mitt from 'mitt'
import {
SHOW_INPUT_BOX,
SHOW_INPUT_BOX_RESPONSE,
FORCE_UPDATE
SHOW_INPUT_BOX_RESPONSE
} from '#/events/constants'
type IEvent ={
@@ -11,8 +10,7 @@ type IEvent ={
value: string
title: string
placeholder: string
},
[FORCE_UPDATE]: void
}
}
const emitter = mitt<IEvent>()

View File

@@ -51,6 +51,11 @@ export function sendRPC (action: IRPCActionType, ...args: any[]): void {
ipcRenderer.send(RPC_ACTIONS, action, data)
}
export function sendRpcSync (action: IRPCActionType, ...args: any[]) {
const data = getRawData(args)
return ipcRenderer.sendSync(RPC_ACTIONS, action, data)
}
export function invokeToMain (channel: string, ...args: any[]) {
const data = getRawData(args)
return ipcRenderer.invoke(channel, ...data)

View File

@@ -4,13 +4,20 @@ import { IRPCActionType } from '#/types/enum'
const osGlobal = ref<string>(process.platform)
const picBedGlobal = ref<IPicBedType[]>([])
const pageReloadCount = ref(0)
async function updatePicBedGlobal () {
picBedGlobal.value = (await triggerRPC<IPicBedType[]>(IRPCActionType.MAIN_GET_PICBED))!
}
async function updatePageReloadCount () {
pageReloadCount.value++
}
export {
osGlobal,
pageReloadCount,
picBedGlobal,
updatePicBedGlobal
updatePicBedGlobal,
updatePageReloadCount
}

View File

@@ -1,24 +0,0 @@
import { ComponentOptions } from 'vue'
import bus from '@/utils/bus'
import { FORCE_UPDATE } from '#/events/constants'
export const mainMixin: ComponentOptions = {
inject: ['forceUpdateTime'],
created () {
// FIXME: may be memory leak
this?.$watch('forceUpdateTime', (newVal: number, oldVal: number) => {
if (oldVal !== newVal) {
this?.$forceUpdate()
}
})
},
methods: {
forceUpdate () {
bus.emit(FORCE_UPDATE)
}
}
}