diff --git a/app/.eslintrc.js b/app/.eslintrc.js index 6dfd3ab..3d77926 100644 --- a/app/.eslintrc.js +++ b/app/.eslintrc.js @@ -34,7 +34,7 @@ module.exports = { }, parserOptions: { parser: '@typescript-eslint/parser', - ecmaVersion: 2018, + ecmaVersion: 2019, sourceType: 'module', project: './tsconfig.json', tsconfigRootDir: __dirname, diff --git a/app/script/release-download-count.ts b/app/script/release-download-count.ts index 92f0e57..4bb0ca5 100644 --- a/app/script/release-download-count.ts +++ b/app/script/release-download-count.ts @@ -1,6 +1,6 @@ import { get } from 'https' -const repeat = (s: string, n: number) => { +const repeat = (s: string, n: number): string => { if (n < 0) throw new Error('repeat(s, n < 0)') let str = '' for (let i = 0; i < n; i++) { @@ -17,23 +17,23 @@ get({ } }, (response) => { let body = '' - response.on('data',chunk => body += chunk) + response.on('data', (chunk: string) => { body += chunk }) response.on('end', () => { console.log('Release' + repeat(' ', 40 - 7) + 'Download Count\n') - let res = JSON.parse(body) + const res = JSON.parse(body) let total = 0 let lineCount = 0 try { for (const release of res) { for (const asset of release.assets) { - total += asset.download_count - let line = asset.name + repeat(' ', 40 - asset.name.length) + asset.download_count + total += asset.download_count as number + const line = `${asset.name}${repeat(' ', 40 - asset.name.length)}${asset.download_count}` if (lineCount < 20) console.log(line) lineCount++ } } - console.log('\nTotal' + repeat(' ', 40 - 5) + total) + console.log(`\nTotal${repeat(' ', 40 - 5)}${total}`) } catch (err) { console.log(res) } diff --git a/app/src/ts/renderer-back.ts b/app/src/ts/renderer-back.ts index 66bff30..8e1fd8c 100644 --- a/app/src/ts/renderer-back.ts +++ b/app/src/ts/renderer-back.ts @@ -16,7 +16,7 @@ ipcRenderer.on('openManifestDatabase', async (event, callbackChannel: string, pa try { manifest = await DB.open(path) event.sender.sendTo(mainWindowId, callbackChannel, null) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message) } }) @@ -29,7 +29,7 @@ ipcRenderer.on('openMasterDatabase', async (event, callbackChannel: string, path try { master = await DB.open(path) event.sender.sendTo(mainWindowId, callbackChannel, null) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message) } }) @@ -38,7 +38,7 @@ ipcRenderer.on('getMasterHash', async (event, callbackChannel: string) => { try { const masterHash = (await manifest!.find('manifests', ['name', 'hash'], { name: 'master.mdb' }))[0].hash as string event.sender.sendTo(mainWindowId, callbackChannel, null, masterHash) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, '') } }) @@ -50,7 +50,7 @@ ipcRenderer.on('readMasterData', async (event, callbackChannel: string, masterFi await master.close() master = null event.sender.sendTo(mainWindowId, callbackChannel, null, masterData) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, '') } }) @@ -59,7 +59,7 @@ ipcRenderer.on('getCardHash', async (event, callbackChannel: string, id: string try { const res = await manifest!.find('manifests', ['hash'], { name: `card_bg_${id}.unity3d` }) event.sender.sendTo(mainWindowId, callbackChannel, null, res[0].hash) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, '') } }) @@ -68,7 +68,7 @@ ipcRenderer.on('getIconHash', async (event, callbackChannel: string, id: string try { const res = await manifest!.findOne('manifests', ['hash'], { name: `card_${id}_m.unity3d` }) event.sender.sendTo(mainWindowId, callbackChannel, null, res.hash) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, '') } }) @@ -77,7 +77,7 @@ ipcRenderer.on('getEmblemHash', async (event, callbackChannel: string, id: strin try { const res = await manifest!.findOne('manifests', ['hash'], { name: `emblem_${id}_l.unity3d` }) event.sender.sendTo(mainWindowId, callbackChannel, null, res.hash) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, '') } }) @@ -86,7 +86,7 @@ ipcRenderer.on('searchResources', async (event, callbackChannel: string, querySt try { const res = await manifest!.find<{ name: string, hash: string }>('manifests', ['name', 'hash', 'size'], { name: { $like: `%${queryString.trim()}%` } }) event.sender.sendTo(mainWindowId, callbackChannel, null, res) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, '') } }) @@ -98,7 +98,7 @@ ipcRenderer.on('startBatchDownload', async (event, callbackChannel: string) => { batchDownloading = true await batchDownload(manifest!) event.sender.sendTo(mainWindowId, callbackChannel, null, batchDownloading) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, '') } }) @@ -108,7 +108,7 @@ ipcRenderer.on('stopBatchDownload', async (event, callbackChannel: string) => { await batchStop() batchDownloading = false event.sender.sendTo(mainWindowId, callbackChannel, null, batchDownloading) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, '') } }) @@ -117,7 +117,7 @@ ipcRenderer.on('getBatchErrorList', (event, callbackChannel: string) => { try { const list = getBatchErrorList() event.sender.sendTo(mainWindowId, callbackChannel, null, list) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message, null) } }) @@ -126,7 +126,7 @@ ipcRenderer.on('setDownloaderProxy', (event, callbackChannel: string, proxy: str try { setDownloaderProxy(proxy) event.sender.sendTo(mainWindowId, callbackChannel, null) - } catch (err) { + } catch (err: any) { event.sender.sendTo(mainWindowId, callbackChannel, err.message) } }) diff --git a/app/src/ts/renderer/back/batch-download.ts b/app/src/ts/renderer/back/batch-download.ts index 3473bef..64e23a7 100644 --- a/app/src/ts/renderer/back/batch-download.ts +++ b/app/src/ts/renderer/back/batch-download.ts @@ -120,7 +120,7 @@ export async function batchDownload (manifest: DB): Promise { }) await currentDownloadPromise currentDownloadPromise = null - } catch (err) { + } catch (err: any) { if (stopBatch) { currentDownloadPromise = null break diff --git a/app/src/ts/renderer/mishiro-commu.ts b/app/src/ts/renderer/mishiro-commu.ts index 523a112..b824215 100644 --- a/app/src/ts/renderer/mishiro-commu.ts +++ b/app/src/ts/renderer/mishiro-commu.ts @@ -165,7 +165,7 @@ export default class extends Vue { let res: ServerResponse try { res = await getProfile(/* '646406677' */this.queryString) - } catch (err) { + } catch (err: any) { this.isSearching = false this.event.$emit('alert', this.$t('home.errorTitle'), err.message) return @@ -218,7 +218,7 @@ export default class extends Vue { emblemB64 = readFileSync(emblemCache + '.png').toString('base64') } } - } catch (err) { + } catch (err: any) { console.error(err) this.event.$emit('alert', this.$t('home.errorTitle'), err.message) } @@ -236,8 +236,9 @@ export default class extends Vue { return } this.renderer.canvas.toBlob((blob) => { + if (!blob) return const a = document.createElement('a') - a.download = 'test.png' + a.download = `${this.queryString}.png` a.href = URL.createObjectURL(blob) const event = new MouseEvent('click', { view: window, diff --git a/app/src/ts/renderer/mishiro-home.ts b/app/src/ts/renderer/mishiro-home.ts index 3f8a11a..78dcd89 100644 --- a/app/src/ts/renderer/mishiro-home.ts +++ b/app/src/ts/renderer/mishiro-home.ts @@ -160,7 +160,7 @@ export default class extends Vue { const usmFile = result.filePaths[i] try { await this.core.movie.demuxAsync(usmFile) - } catch (err) { + } catch (err: any) { error(`USM: ${err.message}`) } } diff --git a/app/src/ts/renderer/mishiro-idol.ts b/app/src/ts/renderer/mishiro-idol.ts index 0e0de40..de40be6 100644 --- a/app/src/ts/renderer/mishiro-idol.ts +++ b/app/src/ts/renderer/mishiro-idol.ts @@ -476,8 +476,8 @@ export default class extends Vue { this.cardDownloadPromise = null return downloadResult } - } catch (_err) { - if (_err.message !== 'abort') { + } catch (err: any) { + if (err.message !== 'abort') { this.cardDownloadPromise = this.dler.downloadSpread( id.toString(), cardDir(`bg_${id}.png`), @@ -487,7 +487,7 @@ export default class extends Vue { this.cardDownloadPromise = null return downloadResult } else { - throw _err + throw err } } } diff --git a/app/src/ts/renderer/mishiro-update.ts b/app/src/ts/renderer/mishiro-update.ts index 950f0b6..89c17b6 100644 --- a/app/src/ts/renderer/mishiro-update.ts +++ b/app/src/ts/renderer/mishiro-update.ts @@ -288,7 +288,7 @@ export default class extends Vue { if (getBackgroundResult/* && getBackgroundResult !== 'await ipc' */) { this.event.$emit('eventBgReady', id) } - } catch (err) { + } catch (err: any) { this.event.$emit('alert', this.$t('home.errorTitle'), (this.$t('home.downloadFailed') as string) + '
' + (err.toString() as string)) } } @@ -362,7 +362,7 @@ export default class extends Vue { this.text = this.$t('update.check') as string this.loading = 0 resVer = await this.getResVer() - } catch (err) { + } catch (err: any) { console.error(err) error(`UPDATE getResVer: ${err.stack}`) if (Number(err.message) === 203) { diff --git a/app/src/ts/renderer/modal-version.ts b/app/src/ts/renderer/modal-version.ts index b2c2a66..3a531ba 100644 --- a/app/src/ts/renderer/modal-version.ts +++ b/app/src/ts/renderer/modal-version.ts @@ -38,7 +38,7 @@ export default class extends mixins(modalMixin) { this.btnDisabled = false this.updateProgress = 0 } - } catch (err) { + } catch (err: any) { updater.onDownload(null) this.btnDisabled = false this.event.$emit('alert', this.$t('home.errorTitle'), err.message) diff --git a/app/src/vue/modal/ModalOption.vue b/app/src/vue/modal/ModalOption.vue index 305fa4d..f08cb54 100644 --- a/app/src/vue/modal/ModalOption.vue +++ b/app/src/vue/modal/ModalOption.vue @@ -168,7 +168,7 @@ export default class extends mixins(modalMixin) { this.batchDownloading = true try { await startBatchDownload() - } catch (err) { + } catch (err: any) { this.event.$emit('alert', this.$t('home.errorTitle'), err.message) } this.batchDownloading = false