mirror of
https://github.com/Kuingsmile/PicList.git
synced 2025-02-02 02:58:13 -05:00
🐛 Fix(custom): remove listener before unmount
This commit is contained in:
parent
c102ac5158
commit
8b21e8407c
@ -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) {
|
||||
|
@ -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)) {
|
||||
|
@ -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)
|
||||
|
@ -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>
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user