This commit is contained in:
lyswhut
2023-01-06 14:39:44 +08:00
parent 1db54195f5
commit 27c1bf8eb6
30 changed files with 196 additions and 85 deletions
+2 -2
View File
@@ -242,13 +242,13 @@ export const setThumbarButtons = ({ empty, collect, play, next, prev }: LX.TaskB
export const setThumbnailClip = (region: Electron.Rectangle) => {
if (!browserWindow) return
return browserWindow.setThumbnailClip(region)
browserWindow.setThumbnailClip(region)
}
export const clearCache = async() => {
if (!browserWindow) throw new Error('main window is undefined')
return await browserWindow.webContents.session.clearCache()
await browserWindow.webContents.session.clearCache()
}
export const getCacheSize = async() => {
@@ -55,7 +55,10 @@ export default () => {
showWindow()
})
mainOn<boolean>(WIN_MAIN_RENDERER_EVENT_NAME.close, ({ params: isForce }) => {
if (isForce) return app.exit(0)
if (isForce) {
app.exit(0)
return
}
global.lx.isTrafficLightClose = true
closeWindow()
})
@@ -79,7 +82,7 @@ export default () => {
mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.clear_cache, async() => {
return await clearCache()
await clearCache()
})
mainHandle<number>(WIN_MAIN_RENDERER_EVENT_NAME.get_cache_size, async() => {
@@ -13,7 +13,7 @@ export default () => {
await global.lx.worker.dbService.downloadInfoUpdate(list)
})
mainHandle<string[]>(WIN_MAIN_RENDERER_EVENT_NAME.download_list_remove, async({ params: ids }) => {
return await global.lx.worker.dbService.downloadInfoRemove(ids)
await global.lx.worker.dbService.downloadInfoRemove(ids)
})
mainHandle(WIN_MAIN_RENDERER_EVENT_NAME.download_list_clear, async() => {
await global.lx.worker.dbService.downloadInfoClear()
@@ -6,7 +6,10 @@ import { WIN_MAIN_RENDERER_EVENT_NAME } from '@common/ipcNames'
const handleInflate = async(data: Buffer) => {
return await new Promise((resolve: (result: Buffer) => void, reject) => {
inflate(data, (err, result) => {
if (err) return reject(err)
if (err) {
reject(err)
return
}
resolve(result)
})
})
@@ -9,7 +9,8 @@ export default () => {
mainHandle<LX.Sync.SyncServiceActions, any>(WIN_MAIN_RENDERER_EVENT_NAME.sync_action, async({ params: data }) => {
switch (data.action) {
case 'enable':
return data.data.enable ? await startServer(parseInt(data.data.port)) : await stopServer()
data.data.enable ? await startServer(parseInt(data.data.port)) : await stopServer()
return
case 'get_status':
return getStatus()
case 'generate_code':
@@ -22,7 +22,7 @@ export default () => {
})
mainHandle<LX.UserApi.UserApiSetApiParams>(WIN_MAIN_RENDERER_EVENT_NAME.set_user_api, async({ params: apiId }) => {
return await setApi(apiId)
await setApi(apiId)
})
mainHandle<LX.UserApi.UserApiInfo[]>(WIN_MAIN_RENDERER_EVENT_NAME.get_user_api_list, async() => {
@@ -34,14 +34,14 @@ export default () => {
})
mainHandle<LX.UserApi.UserApiSetAllowUpdateAlertParams>(WIN_MAIN_RENDERER_EVENT_NAME.user_api_set_allow_update_alert, async({ params: { id, enable } }) => {
return setAllowShowUpdateAlert(id, enable)
setAllowShowUpdateAlert(id, enable)
})
mainHandle<LX.UserApi.UserApiRequestParams>(WIN_MAIN_RENDERER_EVENT_NAME.request_user_api, async({ params }) => {
return await request(params)
})
mainHandle<LX.UserApi.UserApiRequestCancelParams>(WIN_MAIN_RENDERER_EVENT_NAME.request_user_api_cancel, async({ params: requestKey }) => {
return cancelRequest(requestKey)
cancelRequest(requestKey)
})
}