mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-06-03 06:42:09 +08:00
✨ Feature(custom): update i18n force update
This commit is contained in:
@@ -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>()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user