eslint
parent
1db54195f5
commit
27c1bf8eb6
|
@ -64,7 +64,7 @@
|
|||
"build:renderer-lyric": "cross-env NODE_ENV=production webpack --config build-config/renderer-lyric/webpack.config.prod.js --progress",
|
||||
"build:renderer-scripts": "cross-env NODE_ENV=production webpack --config build-config/renderer-scripts/webpack.config.prod.js --progress",
|
||||
"build": "npm run clean:electron && npm run build:main && npm run build:renderer && npm run build:renderer-lyric && npm run build:renderer-scripts",
|
||||
"lint": "eslint --ext .js,.vue -f node_modules/eslint-formatter-friendly src",
|
||||
"lint": "eslint --ext .ts,.js,.vue -f node_modules/eslint-formatter-friendly src",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"lint:fix": "eslint --ext .js,.vue -f node_modules/eslint-formatter-friendly --fix src",
|
||||
"dp": "cross-env ELECTRON_GET_USE_PROXY=true GLOBAL_AGENT_HTTPS_PROXY=http://127.0.0.1:1081 npm run pack",
|
||||
|
|
|
@ -65,9 +65,7 @@ declare namespace LX {
|
|||
|
||||
interface HotKeyConfig {
|
||||
enable: boolean
|
||||
keys: {
|
||||
[key: string]: HotKey
|
||||
}
|
||||
keys: Record<string, HotKey>
|
||||
}
|
||||
interface HotKeyConfigAll {
|
||||
local: HotKeyConfig
|
||||
|
|
|
@ -135,12 +135,13 @@ class Task extends EventEmitter {
|
|||
try {
|
||||
this.__initDownload(response)
|
||||
} catch (error: any) {
|
||||
return this.__handleError(error)
|
||||
this.__handleError(error)
|
||||
return
|
||||
}
|
||||
this.status = STATUS.running
|
||||
response
|
||||
.on('data', this.__handleWriteData.bind(this))
|
||||
.on('error', err => this.__handleError(err))
|
||||
.on('error', err => { this.__handleError(err) })
|
||||
.on('end', () => {
|
||||
if (response.complete) {
|
||||
this.__handleComplete()
|
||||
|
@ -150,7 +151,7 @@ class Task extends EventEmitter {
|
|||
}
|
||||
})
|
||||
})
|
||||
.on('error', err => this.__handleError(err))
|
||||
.on('error', err => { this.__handleError(err) })
|
||||
.on('close', () => {
|
||||
void this.__closeWriteStream()
|
||||
})
|
||||
|
@ -159,7 +160,10 @@ class Task extends EventEmitter {
|
|||
|
||||
__initDownload(response: http.IncomingMessage) {
|
||||
this.progress.total = response.headers['content-length'] ? parseInt(response.headers['content-length']) : 0
|
||||
if (!this.progress.total) return this.__handleError(new Error('Content length is 0'))
|
||||
if (!this.progress.total) {
|
||||
this.__handleError(new Error('Content length is 0'))
|
||||
return
|
||||
}
|
||||
let options: any = {}
|
||||
let isResumable = this.options.forceResume ||
|
||||
response.headers['accept-ranges'] !== 'none' ||
|
||||
|
@ -170,11 +174,17 @@ class Task extends EventEmitter {
|
|||
options.flags = 'a'
|
||||
if (this.progress.downloaded) this.progress.total -= 10
|
||||
} else {
|
||||
if (this.chunkInfo.startByte != '0') return this.__handleError(new Error('The resource cannot be resumed download.'))
|
||||
if (this.chunkInfo.startByte != '0') {
|
||||
this.__handleError(new Error('The resource cannot be resumed download.'))
|
||||
return
|
||||
}
|
||||
}
|
||||
this.progress.total += this.progress.downloaded
|
||||
this.statsEstimate.prevBytes = this.progress.downloaded
|
||||
if (!this.chunkInfo.path) return this.__handleError(new Error('Chunk save Path is not set.'))
|
||||
if (!this.chunkInfo.path) {
|
||||
this.__handleError(new Error('Chunk save Path is not set.'))
|
||||
return
|
||||
}
|
||||
this.ws = fs.createWriteStream(this.chunkInfo.path, options)
|
||||
|
||||
this.ws.on('finish', () => {
|
||||
|
@ -216,7 +226,10 @@ class Task extends EventEmitter {
|
|||
|
||||
async __closeWriteStream() {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (!this.ws) return resolve()
|
||||
if (!this.ws) {
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
// console.log('close write stream')
|
||||
this.ws.close(err => {
|
||||
if (err) {
|
||||
|
@ -251,7 +264,10 @@ class Task extends EventEmitter {
|
|||
// this.__handleError(err)
|
||||
this.chunkInfo.startByte = '0'
|
||||
this.resumeLastChunk = null
|
||||
if (unlinkErr && unlinkErr.code !== 'ENOENT') return this.__handleError(unlinkErr)
|
||||
if (unlinkErr && unlinkErr.code !== 'ENOENT') {
|
||||
this.__handleError(unlinkErr)
|
||||
return
|
||||
}
|
||||
void this.start()
|
||||
})
|
||||
})
|
||||
|
@ -259,7 +275,10 @@ class Task extends EventEmitter {
|
|||
}
|
||||
}
|
||||
// console.log('data', chunk)
|
||||
if (this.status == STATUS.stopped || this.ws == null) return console.log('cancel write')
|
||||
if (this.status == STATUS.stopped || this.ws == null) {
|
||||
console.log('cancel write')
|
||||
return
|
||||
}
|
||||
this.__calculateProgress(chunk.length)
|
||||
this.ws.write(chunk, err => {
|
||||
if (!err) return
|
||||
|
|
|
@ -16,9 +16,15 @@ export const dirname = (p: string): string => path.dirname(p)
|
|||
*/
|
||||
export const checkPath = async(path: string): Promise<boolean> => {
|
||||
return await new Promise(resolve => {
|
||||
if (!path) return resolve(false)
|
||||
if (!path) {
|
||||
resolve(false)
|
||||
return
|
||||
}
|
||||
fs.access(path, fs.constants.F_OK, err => {
|
||||
if (err) return resolve(false)
|
||||
if (err) {
|
||||
resolve(false)
|
||||
return
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
})
|
||||
|
@ -26,9 +32,15 @@ export const checkPath = async(path: string): Promise<boolean> => {
|
|||
|
||||
export const getFileStats = async(path: string): Promise<fs.Stats | null> => {
|
||||
return await new Promise(resolve => {
|
||||
if (!path) return resolve(null)
|
||||
if (!path) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
fs.stat(path, (err, stats) => {
|
||||
if (err) return resolve(null)
|
||||
if (err) {
|
||||
resolve(null)
|
||||
return
|
||||
}
|
||||
resolve(stats)
|
||||
})
|
||||
})
|
||||
|
@ -39,29 +51,37 @@ export const getFileStats = async(path: string): Promise<fs.Stats | null> => {
|
|||
* @param path
|
||||
* @returns
|
||||
*/
|
||||
export const createDir = async(path: string): Promise<void> => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
fs.access(path, fs.constants.F_OK | fs.constants.W_OK, err => {
|
||||
if (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
fs.mkdir(path, { recursive: true }, err => {
|
||||
if (err) return reject(err)
|
||||
resolve()
|
||||
})
|
||||
return
|
||||
}
|
||||
return reject(err)
|
||||
export const createDir = async(path: string) => new Promise<void>((resolve, reject) => {
|
||||
fs.access(path, fs.constants.F_OK | fs.constants.W_OK, err => {
|
||||
if (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
fs.mkdir(path, { recursive: true }, err => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
return
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
export const removeFile = async(path: string) => new Promise<void>((resolve, reject) => {
|
||||
fs.access(path, fs.constants.F_OK, err => {
|
||||
if (err) return err.code == 'ENOENT' ? resolve() : reject(err)
|
||||
if (err) {
|
||||
err.code == 'ENOENT' ? resolve() : reject(err)
|
||||
return
|
||||
}
|
||||
fs.unlink(path, err => {
|
||||
if (err) return reject(err)
|
||||
if (err) {
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
resolve()
|
||||
})
|
||||
})
|
||||
|
@ -79,7 +99,10 @@ export const toMD5 = (str: string) => crypto.createHash('md5').update(str).diges
|
|||
export const gzipData = async(str: string): Promise<Buffer> => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
gzip(str, (err, result) => {
|
||||
if (err) return reject(err)
|
||||
if (err) {
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
resolve(result)
|
||||
})
|
||||
})
|
||||
|
@ -88,7 +111,10 @@ export const gzipData = async(str: string): Promise<Buffer> => {
|
|||
export const gunzipData = async(buf: Buffer): Promise<string> => {
|
||||
return await new Promise((resolve, reject) => {
|
||||
gunzip(buf, (err, result) => {
|
||||
if (err) return reject(err)
|
||||
if (err) {
|
||||
reject(err)
|
||||
return
|
||||
}
|
||||
resolve(result.toString())
|
||||
})
|
||||
})
|
||||
|
|
|
@ -45,7 +45,10 @@ const handleScrollY = (element: HTMLElement, to: number, duration = 300, fn = no
|
|||
element.scrollTop = val
|
||||
}
|
||||
if (currentTime < duration) {
|
||||
if (cancel) return fn()
|
||||
if (cancel) {
|
||||
fn()
|
||||
return
|
||||
}
|
||||
window.setTimeout(animateScroll, increment)
|
||||
} else {
|
||||
fn()
|
||||
|
@ -117,7 +120,10 @@ const handleScrollX = (element: HTMLElement, to: number, duration = 300, fn = ()
|
|||
element.scrollLeft = val
|
||||
}
|
||||
if (currentTime < duration) {
|
||||
if (cancel) return fn()
|
||||
if (cancel) {
|
||||
fn()
|
||||
return
|
||||
}
|
||||
window.setTimeout(animateScroll, increment)
|
||||
} else {
|
||||
fn()
|
||||
|
@ -192,7 +198,10 @@ const handleScrollXR = (element: HTMLElement, to: number, duration = 300, fn = (
|
|||
element.scrollLeft = val
|
||||
}
|
||||
if (currentTime < duration) {
|
||||
if (cancel) return fn()
|
||||
if (cancel) {
|
||||
fn()
|
||||
return
|
||||
}
|
||||
window.setTimeout(animateScroll, increment)
|
||||
} else {
|
||||
fn()
|
||||
|
|
|
@ -116,8 +116,14 @@ export const registerDeeplink = (startApp: () => void) => {
|
|||
export const listenerAppEvent = (startApp: () => void) => {
|
||||
app.on('web-contents-created', (event, contents) => {
|
||||
contents.on('will-navigate', (event, navigationUrl) => {
|
||||
if (global.isDev) return console.log('navigation to url:', navigationUrl)
|
||||
if (!navigationUrlWhiteList.some(url => url.test(navigationUrl))) return event.preventDefault()
|
||||
if (global.isDev) {
|
||||
console.log('navigation to url:', navigationUrl)
|
||||
return
|
||||
}
|
||||
if (!navigationUrlWhiteList.some(url => url.test(navigationUrl))) {
|
||||
event.preventDefault()
|
||||
return
|
||||
}
|
||||
console.log('navigation to url:', navigationUrl)
|
||||
})
|
||||
contents.setWindowOpenHandler(({ url }) => {
|
||||
|
@ -233,7 +239,7 @@ export const initAppSetting = async() => {
|
|||
if (!isInitialized) {
|
||||
const dbFileExists = await global.lx.worker.dbService.init(global.lxDataPath)
|
||||
global.lx.appSetting = (await initSetting()).setting
|
||||
if (!dbFileExists) await migrateDBData().catch(err => log.error(err))
|
||||
if (!dbFileExists) await migrateDBData().catch(err => { log.error(err) })
|
||||
initTheme()
|
||||
}
|
||||
// global.lx.theme = getTheme()
|
||||
|
|
|
@ -17,8 +17,12 @@ electronDebug({
|
|||
// Install `vue-devtools`
|
||||
app.on('ready', () => {
|
||||
installExtension(VUEJS_DEVTOOLS)
|
||||
.then((name: string) => console.log(`Added Extension: ${name}`))
|
||||
.catch((err: Error) => console.log('An error occurred: ', err))
|
||||
.then((name: string) => {
|
||||
console.log(`Added Extension: ${name}`)
|
||||
})
|
||||
.catch((err: Error) => {
|
||||
console.log('An error occurred: ', err)
|
||||
})
|
||||
})
|
||||
|
||||
// Require `main` process to boot app
|
||||
|
|
|
@ -30,4 +30,6 @@ listenerAppEvent(init)
|
|||
|
||||
|
||||
// https://github.com/electron/electron/issues/16809
|
||||
void app.whenReady().then(() => isLinux ? setTimeout(init, 300) : init())
|
||||
void app.whenReady().then(() => {
|
||||
isLinux ? setTimeout(init, 300) : init()
|
||||
})
|
||||
|
|
|
@ -146,7 +146,7 @@ const broadcast = async(action: listAction, data: any, excludeIds: string[] = []
|
|||
export const sendListAction = async(action: LX.Sync.ActionList) => {
|
||||
console.log('sendListAction', action.action)
|
||||
// io.sockets
|
||||
return await broadcast('list:action', JSON.stringify(action))
|
||||
await broadcast('list:action', JSON.stringify(action))
|
||||
}
|
||||
|
||||
export const registerListHandler = (_io: Server, socket: LX.Sync.Socket) => {
|
||||
|
|
|
@ -142,7 +142,10 @@ const handleStartServer = async(port = 9527) => await new Promise((resolve, reje
|
|||
|
||||
httpServer.on('listening', () => {
|
||||
const addr = httpServer.address()
|
||||
if (!addr) return reject(new Error('address is null'))
|
||||
if (!addr) {
|
||||
reject(new Error('address is null'))
|
||||
return
|
||||
}
|
||||
const bind = typeof addr == 'string' ? `pipe ${addr}` : `port ${addr.port}`
|
||||
console.info(`Listening on ${bind}`)
|
||||
resolve(null)
|
||||
|
@ -171,7 +174,7 @@ export const stopServer = async() => {
|
|||
return
|
||||
}
|
||||
console.log('stoping sync server...')
|
||||
return await handleStopServer().then(() => {
|
||||
await handleStopServer().then(() => {
|
||||
console.log('sync server stoped')
|
||||
status.status = false
|
||||
status.message = ''
|
||||
|
@ -189,7 +192,7 @@ export const startServer = async(port: number) => {
|
|||
if (status.status) await handleStopServer()
|
||||
|
||||
console.log('starting sync server...')
|
||||
return await handleStartServer(port).then(() => {
|
||||
await handleStartServer(port).then(() => {
|
||||
console.log('sync server started')
|
||||
status.status = true
|
||||
status.message = ''
|
||||
|
|
|
@ -31,7 +31,10 @@ const getRemoteListData = async(socket: LX.Sync.Socket): Promise<LX.Sync.ListDat
|
|||
socket.removeListener('list:sync', handleSuccess)
|
||||
console.log('getRemoteListData', 'handleSuccess')
|
||||
const data: LX.Sync.Data | null = JSON.parse(decryptMsg(socket.data.keyInfo, enData))
|
||||
if (!data) return reject(new Error('Get remote list data failed'))
|
||||
if (!data) {
|
||||
reject(new Error('Get remote list data failed'))
|
||||
return
|
||||
}
|
||||
if (data.action != 'getData') return
|
||||
resolve(patchListData(data.data))
|
||||
}
|
||||
|
@ -101,10 +104,10 @@ const updateSnapshot = async(path: string, data: string) => {
|
|||
let writeFilePromise = writeFilePromises.get(path) ?? Promise.resolve()
|
||||
writeFilePromise = writeFilePromise.then(async() => {
|
||||
if (writeFilePromise !== writeFilePromises.get(path)) return
|
||||
return await fsPromises.writeFile(path, data)
|
||||
await fsPromises.writeFile(path, data)
|
||||
})
|
||||
writeFilePromises.set(path, writeFilePromise)
|
||||
return await writeFilePromise.finally(() => {
|
||||
await writeFilePromise.finally(() => {
|
||||
if (writeFilePromise !== writeFilePromises.get(path)) return
|
||||
writeFilePromises.delete(path)
|
||||
})
|
||||
|
@ -453,7 +456,7 @@ const checkSyncQueue = async(): Promise<void> => {
|
|||
if (!syncingId) return
|
||||
console.log('sync queue...')
|
||||
await wait()
|
||||
return await checkSyncQueue()
|
||||
await checkSyncQueue()
|
||||
}
|
||||
|
||||
// export {
|
||||
|
@ -484,7 +487,7 @@ const _syncList = async(_io: Server, socket: LX.Sync.Socket) => {
|
|||
|
||||
const removeSnapshot = async(keyInfo: LX.Sync.KeyInfo) => {
|
||||
const filePath = getSnapshotFilePath(keyInfo)
|
||||
return await fsPromises.unlink(filePath)
|
||||
await fsPromises.unlink(filePath)
|
||||
}
|
||||
|
||||
export {
|
||||
|
|
|
@ -72,7 +72,10 @@ export const createWindow = async(userApi: LX.UserApi.UserApiInfo) => {
|
|||
})
|
||||
}
|
||||
browserWindow.webContents.session.setPermissionRequestHandler((webContents, permission, resolve) => {
|
||||
if (webContents === browserWindow?.webContents) return resolve(false)
|
||||
if (webContents === browserWindow?.webContents) {
|
||||
resolve(false)
|
||||
return
|
||||
}
|
||||
resolve(true)
|
||||
})
|
||||
browserWindow.webContents.setWindowOpenHandler(() => {
|
||||
|
|
|
@ -118,7 +118,9 @@ export const cancelRequest = (requestKey: string) => {
|
|||
}
|
||||
|
||||
export const request = async({ requestKey, data }: LX.UserApi.UserApiRequestParams): Promise<any> => await new Promise((resolve, reject) => {
|
||||
if (!userApi) return reject(new Error('user api is not load'))
|
||||
if (!userApi) {
|
||||
reject(new Error('user api is not load'))
|
||||
}
|
||||
|
||||
// const requestKey = `request__${Math.random().toString().substring(2)}`
|
||||
const timeout = timeouts.get(requestKey)
|
||||
|
|
|
@ -202,7 +202,10 @@ export const alwaysOnTopTools: AlwaysOnTopTools = {
|
|||
startLoop() {
|
||||
this.clearLoop()
|
||||
this.timeout = setInterval(() => {
|
||||
if (!isExistWindow()) return this.clearLoop()
|
||||
if (!isExistWindow()) {
|
||||
this.clearLoop()
|
||||
return
|
||||
}
|
||||
setAlwaysOnTop(true, 'screen-saver')
|
||||
}, 1000)
|
||||
},
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,9 @@ const migrateFile = async(name: string, targetName: string) => {
|
|||
if (!await checkPath(path) && await checkPath(oldPath)) {
|
||||
await fs.promises.copyFile(oldPath, path).catch(err => {
|
||||
log.error(err)
|
||||
}).catch(err => log.error(err))
|
||||
}).catch(err => {
|
||||
log.error(err)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +110,9 @@ export const migrateDataJson = async() => {
|
|||
if (oldDataFile.listPosition) newData.listScrollPosition = oldDataFile.listPosition
|
||||
if (oldDataFile.listUpdateInfo) newData.listUpdateInfo = oldDataFile.listUpdateInfo
|
||||
|
||||
await fs.promises.writeFile(path, JSON.stringify(newData)).catch(err => log.error(err))
|
||||
await fs.promises.writeFile(path, JSON.stringify(newData)).catch(err => {
|
||||
log.error(err)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,9 +4,7 @@ import { join } from 'path'
|
|||
import fs from 'fs'
|
||||
import log from 'electron-log'
|
||||
|
||||
interface Stores {
|
||||
[key: string]: Store
|
||||
}
|
||||
type Stores = Record<string, Store>
|
||||
|
||||
const stores: Stores = {}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ export const insertMusicInfoList = (list: LX.DBService.MusicInfo[]) => {
|
|||
const musicInfoInsertStatement = createMusicInfoInsertStatement()
|
||||
const musicInfoOrderInsertStatement = createMusicInfoOrderInsertStatement()
|
||||
const db = getDB()
|
||||
return db.transaction((musics: LX.DBService.MusicInfo[]) => {
|
||||
db.transaction((musics: LX.DBService.MusicInfo[]) => {
|
||||
for (const music of musics) {
|
||||
musicInfoInsertStatement.run(music)
|
||||
musicInfoOrderInsertStatement.run({
|
||||
|
@ -238,7 +238,7 @@ export const removeMusicInfos = (listId: string, ids: string[]) => {
|
|||
const musicInfoDeleteStatement = createMusicInfoDeleteStatement()
|
||||
const musicInfoOrderDeleteStatement = createMusicInfoOrderDeleteStatement()
|
||||
const db = getDB()
|
||||
return db.transaction((listId: string, ids: string[]) => {
|
||||
db.transaction((listId: string, ids: string[]) => {
|
||||
for (const id of ids) {
|
||||
musicInfoDeleteStatement.run({ listId, id })
|
||||
musicInfoOrderDeleteStatement.run({ listId, id })
|
||||
|
|
|
@ -22,16 +22,26 @@ let mouseCheckTools: {
|
|||
let yDiff = Math.abs(this.y - this.preY)
|
||||
if (xDiff > 8) {
|
||||
if (this.x > this.preX) {
|
||||
if (this.x + xDiff * 1.25 > window.innerWidth - 16) return setShow()
|
||||
if (this.x + xDiff * 1.25 > window.innerWidth - 16) {
|
||||
setShow()
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if (this.x - xDiff * 1.25 < 8) return setShow()
|
||||
if (this.x - xDiff * 1.25 < 8) {
|
||||
setShow()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if (yDiff > 8) {
|
||||
if (this.y > this.preY) {
|
||||
if (this.y + yDiff * 1.25 > window.innerHeight - 16) return setShow()
|
||||
if (this.y + yDiff * 1.25 > window.innerHeight - 16) {
|
||||
setShow()
|
||||
}
|
||||
} else {
|
||||
if (this.y - yDiff * 1.25 < 8) return setShow()
|
||||
if (this.y - yDiff * 1.25 < 8) {
|
||||
setShow()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,12 +33,16 @@ export default () => {
|
|||
return async() => {
|
||||
await Promise.all([
|
||||
initUserApi(), // 自定义API
|
||||
]).catch(err => log.error(err))
|
||||
]).catch(err => {
|
||||
log.error(err)
|
||||
})
|
||||
void music.init() // 初始化音乐sdk
|
||||
unregister = registerAction((ids) => {
|
||||
window.app_event.myListUpdate(ids)
|
||||
})
|
||||
window.lxData.userLists = await getUserLists() // 获取用户列表
|
||||
await initPrevPlayInfo().catch(err => log.error(err)) // 初始化上次的歌曲播放信息
|
||||
await initPrevPlayInfo().catch(err => {
|
||||
log.error(err)
|
||||
}) // 初始化上次的歌曲播放信息
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,7 +49,10 @@ export default () => {
|
|||
const addDelayNextTimeout = () => {
|
||||
clearDelayNextTimeout()
|
||||
delayNextTimeout = setTimeout(() => {
|
||||
if (window.lx.isPlayedStop) return setAllStatus('')
|
||||
if (window.lx.isPlayedStop) {
|
||||
setAllStatus('')
|
||||
return
|
||||
}
|
||||
void playNext(true)
|
||||
}, 5000)
|
||||
}
|
||||
|
|
|
@ -49,4 +49,6 @@ export const unregisterKeyEvent = () => {
|
|||
keyBind.unbindKey()
|
||||
}
|
||||
|
||||
export const clearDownKeys = () => keyBind.clearDownKeys()
|
||||
export const clearDownKeys = () => {
|
||||
keyBind.clearDownKeys()
|
||||
}
|
||||
|
|
|
@ -22,7 +22,10 @@ export const buildBgUrl = (originUrl: string, dataPath: string): string => {
|
|||
}
|
||||
|
||||
export const getThemes = (callback: (themeInfo: LX.ThemeInfo) => void) => {
|
||||
if (themeInfo.themes.length) return callback(themeInfo)
|
||||
if (themeInfo.themes.length) {
|
||||
callback(themeInfo)
|
||||
return
|
||||
}
|
||||
void getTheme().then(info => {
|
||||
themeInfo.themes = markRaw(info.themes)
|
||||
themeInfo.userThemes = shallowReactive(info.userThemes)
|
||||
|
|
|
@ -21,7 +21,7 @@ export const onSettingChanged = (listener: LX.IpcRendererEventListenerParams<Par
|
|||
}
|
||||
|
||||
export const sendInited = () => {
|
||||
return rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.inited)
|
||||
rendererSend(WIN_MAIN_RENDERER_EVENT_NAME.inited)
|
||||
}
|
||||
|
||||
export const getOtherSource = async(id: string): Promise<LX.Music.MusicInfoOnline[]> => {
|
||||
|
|
|
@ -52,7 +52,9 @@ export default () => {
|
|||
case 'playListPart_v2':
|
||||
listData = configData.data
|
||||
break
|
||||
default: return showImportTip(configData.type)
|
||||
default:
|
||||
showImportTip(configData.type)
|
||||
return
|
||||
}
|
||||
|
||||
const targetList = [defaultList, loveList, ...userLists].find(l => l.id == listData.id)
|
||||
|
|
Loading…
Reference in New Issue