🐛 Fix(custom): remove listener before unmount

This commit is contained in:
Kuingsmile 2024-05-25 21:06:27 +08:00
parent c102ac5158
commit 8b21e8407c
5 changed files with 8 additions and 9 deletions

View File

@ -180,8 +180,8 @@ class LifeCycle {
shortKeyHandler.init()
})
server.startup()
startFileServer()
webServer.start()
startFileServer()
if (process.env.NODE_ENV !== 'development') {
handleStartUpFiles(process.argv, process.cwd())
}
@ -229,7 +229,7 @@ class LifeCycle {
}
#onRunning () {
app.on('second-instance', (event, commandLine, workingDirectory) => {
app.on('second-instance', (_, commandLine, workingDirectory) => {
logger.info('detect second instance')
const result = handleStartUpFiles(commandLine, workingDirectory)
if (!result) {

View File

@ -11,8 +11,7 @@ class ManageDB {
this.#db = new JSONStore(this.#ctx.configPath)
let initParams: IStringKeyMap = {
picBed: {},
settings: {},
currentPicBed: 'placeholder'
settings: {}
}
for (let key in initParams) {
if (!this.#db.has(key)) {

View File

@ -31,7 +31,7 @@ export class ManageApi extends EventEmitter implements ManageApiType {
constructor (currentPicBed: string = '') {
super()
this.currentPicBed = currentPicBed || (this.getConfig('currentPicBed') ?? 'placeholder')
this.currentPicBed = currentPicBed || 'placeholder'
this.configPath = managePathChecker()
this.initConfigPath()
this.logger = new ManageLogger(this)

View File

@ -192,14 +192,14 @@ function uploadClipboardFiles () {
onBeforeMount(() => {
disableDragFile()
getData()
ipcRenderer.on('dragFiles', async (event: Event, _files: string[]) => {
ipcRenderer.on('dragFiles', async (_: Event, _files: string[]) => {
for (let i = 0; i < _files.length; i++) {
const item = _files[i]
await $$db.insert(item)
}
files.value = (await $$db.get<ImgInfo>({ orderBy: 'desc', limit: 5 })).data
})
ipcRenderer.on('clipboardFiles', (event: Event, files: ImgInfo[]) => {
ipcRenderer.on('clipboardFiles', (_: Event, files: ImgInfo[]) => {
clipboardFiles.value = files
})
ipcRenderer.on('uploadFiles', async () => {
@ -214,7 +214,7 @@ onBeforeMount(() => {
onBeforeUnmount(() => {
ipcRenderer.removeAllListeners('dragFiles')
ipcRenderer.removeAllListeners('clipboardFiles')
ipcRenderer.removeAllListeners('uploadClipboardFiles')
ipcRenderer.removeAllListeners('uploadFiles')
ipcRenderer.removeAllListeners('updateFiles')
})
</script>

View File

@ -57,7 +57,7 @@ export class GalleryDB implements IGalleryDB {
#msgHandler<T> (method: string, ...args: any[]): Promise<T> {
return new Promise((resolve) => {
const callbackId = uuid()
const callback = (event: IpcRendererEvent, data: T, returnCallbackId: string) => {
const callback = (_: IpcRendererEvent, data: T, returnCallbackId: string) => {
if (returnCallbackId === callbackId) {
resolve(data)
ipcRenderer.removeListener(method, callback)