mirror of
https://github.com/Kuingsmile/PicList.git
synced 2026-05-22 16:50:35 +08:00
⬆️ Upgrade(custom): upgrade deps and fix lint error
This commit is contained in:
@@ -7,7 +7,7 @@ import simpleImportSort from 'eslint-plugin-simple-import-sort'
|
|||||||
import pluginUnicorn from 'eslint-plugin-unicorn'
|
import pluginUnicorn from 'eslint-plugin-unicorn'
|
||||||
import pluginVue from 'eslint-plugin-vue'
|
import pluginVue from 'eslint-plugin-vue'
|
||||||
import globals from 'globals'
|
import globals from 'globals'
|
||||||
import jsoncParser from 'jsonc-eslint-parser'
|
import * as jsoncParser from 'jsonc-eslint-parser'
|
||||||
import tseslint from 'typescript-eslint'
|
import tseslint from 'typescript-eslint'
|
||||||
import vueParser from 'vue-eslint-parser'
|
import vueParser from 'vue-eslint-parser'
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ export default defineConfig(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
files: ['*.config.js', '.stylelintrc.cjs', 'scripts/*.{js,mjs,cjs}'],
|
files: ['*.config.js', '.stylelintrc.cjs', 'scripts/*.{js,mjs,cjs}', 'tests/*.{js,mjs,cjs}'],
|
||||||
languageOptions: {
|
languageOptions: {
|
||||||
globals: {
|
globals: {
|
||||||
...globals.node,
|
...globals.node,
|
||||||
|
|||||||
47
package.json
47
package.json
@@ -54,12 +54,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"baseline-browser-mapping": "^2.9.13"
|
"baseline-browser-mapping": "^2.9.13",
|
||||||
|
"semver": "^7.7.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@aws-sdk/client-s3": "3.1012.0",
|
"@aws-sdk/client-s3": "3.1013.0",
|
||||||
"@aws-sdk/lib-storage": "^3.1012.0",
|
"@aws-sdk/lib-storage": "^3.1013.0",
|
||||||
"@aws-sdk/s3-request-presigner": "^3.1012.0",
|
"@aws-sdk/s3-request-presigner": "^3.1013.0",
|
||||||
"@nodelib/fs.walk": "^3.0.1",
|
"@nodelib/fs.walk": "^3.0.1",
|
||||||
"@octokit/rest": "^22.0.1",
|
"@octokit/rest": "^22.0.1",
|
||||||
"@piclist/i18n": "^2.0.0",
|
"@piclist/i18n": "^2.0.0",
|
||||||
@@ -108,27 +109,27 @@
|
|||||||
"@codemirror/theme-one-dark": "^6.1.3",
|
"@codemirror/theme-one-dark": "^6.1.3",
|
||||||
"@codemirror/view": "^6.40.0",
|
"@codemirror/view": "^6.40.0",
|
||||||
"@electron/notarize": "^3.1.1",
|
"@electron/notarize": "^3.1.1",
|
||||||
"@eslint/js": "^9.39.2",
|
"@eslint/js": "^10.0.1",
|
||||||
"@headlessui/vue": "^1.7.23",
|
"@headlessui/vue": "^1.7.23",
|
||||||
"@highlightjs/vue-plugin": "^2.1.2",
|
"@highlightjs/vue-plugin": "^2.1.2",
|
||||||
"@intlify/unplugin-vue-i18n": "^11.1.1",
|
"@intlify/unplugin-vue-i18n": "^11.1.1",
|
||||||
"@tailwindcss/vite": "^4.1.18",
|
"@tailwindcss/vite": "^4.2.2",
|
||||||
"@types/adm-zip": "^0.5.8",
|
"@types/adm-zip": "^0.5.8",
|
||||||
"@types/ali-oss": "^6.23.3",
|
"@types/ali-oss": "^6.23.3",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/js-yaml": "^4.0.9",
|
"@types/js-yaml": "^4.0.9",
|
||||||
"@types/lodash-es": "^4.17.12",
|
"@types/lodash-es": "^4.17.12",
|
||||||
"@types/multer": "^2.1.0",
|
"@types/multer": "^2.1.0",
|
||||||
"@types/node": "^25.0.3",
|
"@types/node": "^25.5.0",
|
||||||
"@types/semver": "^7.7.1",
|
"@types/semver": "^7.7.1",
|
||||||
"@types/tunnel": "^0.0.7",
|
"@types/tunnel": "^0.0.7",
|
||||||
"@types/upyun": "^3.4.3",
|
"@types/upyun": "^3.4.3",
|
||||||
"@types/video.js": "^7.3.58",
|
"@types/video.js": "^7.3.58",
|
||||||
"@types/write-file-atomic": "^4.0.3",
|
"@types/write-file-atomic": "^4.0.3",
|
||||||
"@videojs-player/vue": "^1.0.0",
|
"@videojs-player/vue": "^1.0.0",
|
||||||
"@vitejs/plugin-vue": "^6.0.3",
|
"@vitejs/plugin-vue": "^6.0.5",
|
||||||
"@vueuse/core": "^14.2.1",
|
"@vueuse/core": "^14.2.1",
|
||||||
"baseline-browser-mapping": "^2.10.8",
|
"baseline-browser-mapping": "^2.10.9",
|
||||||
"codemirror": "^6.0.2",
|
"codemirror": "^6.0.2",
|
||||||
"dexie": "^3.2.4",
|
"dexie": "^3.2.4",
|
||||||
"dotenv": "^17.3.1",
|
"dotenv": "^17.3.1",
|
||||||
@@ -137,14 +138,14 @@
|
|||||||
"electron-builder": "^26.0.12",
|
"electron-builder": "^26.0.12",
|
||||||
"electron-devtools-installer": "^4.0.0",
|
"electron-devtools-installer": "^4.0.0",
|
||||||
"electron-vite": "^5.0.0",
|
"electron-vite": "^5.0.0",
|
||||||
"eslint": "^9.39.2",
|
"eslint": "^10.0.3",
|
||||||
"eslint-config-prettier": "^10.1.8",
|
"eslint-config-prettier": "^10.1.8",
|
||||||
"eslint-plugin-jsonc": "^2.21.0",
|
"eslint-plugin-jsonc": "^3.1.2",
|
||||||
"eslint-plugin-prettier": "^5.5.4",
|
"eslint-plugin-prettier": "^5.5.5",
|
||||||
"eslint-plugin-simple-import-sort": "^12.1.1",
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
||||||
"eslint-plugin-unicorn": "^62.0.0",
|
"eslint-plugin-unicorn": "^63.0.0",
|
||||||
"eslint-plugin-vue": "^10.6.2",
|
"eslint-plugin-vue": "^10.8.0",
|
||||||
"globals": "^16.5.0",
|
"globals": "^17.4.0",
|
||||||
"highlight.js": "^11.11.1",
|
"highlight.js": "^11.11.1",
|
||||||
"husky": "^9.1.7",
|
"husky": "^9.1.7",
|
||||||
"js-yaml": "^4.1.1",
|
"js-yaml": "^4.1.1",
|
||||||
@@ -155,22 +156,22 @@
|
|||||||
"pinia-plugin-persistedstate": "^4.7.1",
|
"pinia-plugin-persistedstate": "^4.7.1",
|
||||||
"postcss": "^8.5.8",
|
"postcss": "^8.5.8",
|
||||||
"postcss-html": "^1.8.1",
|
"postcss-html": "^1.8.1",
|
||||||
"prettier": "^3.7.4",
|
"prettier": "^3.8.1",
|
||||||
"prettier-plugin-tailwindcss": "^0.7.2",
|
"prettier-plugin-tailwindcss": "^0.7.2",
|
||||||
"qrcode.vue": "^3.6.0",
|
"qrcode.vue": "^3.8.0",
|
||||||
"stylelint": "^16.26.1",
|
"stylelint": "^17.5.0",
|
||||||
"stylelint-config-html": "^1.1.0",
|
"stylelint-config-html": "^1.1.0",
|
||||||
"stylelint-config-standard": "^39.0.1",
|
"stylelint-config-standard": "^40.0.0",
|
||||||
"stylelint-config-standard-vue": "^1.0.0",
|
"stylelint-config-standard-vue": "^1.0.0",
|
||||||
"stylelint-order": "^7.0.1",
|
"stylelint-order": "^8.1.1",
|
||||||
"stylus": "^0.64.0",
|
"stylus": "^0.64.0",
|
||||||
"tailwindcss": "^4.2.2",
|
"tailwindcss": "^4.2.2",
|
||||||
"typescript": "5.8.2",
|
"typescript": "5.9.3",
|
||||||
"typescript-eslint": "^8.52.0",
|
"typescript-eslint": "^8.57.1",
|
||||||
"video.js": "^8.23.8",
|
"video.js": "^8.23.8",
|
||||||
"vite": "^7.3.1",
|
"vite": "^7.3.1",
|
||||||
"vitest": "^4.0.16",
|
"vitest": "^4.0.16",
|
||||||
"vue-eslint-parser": "^10.2.0",
|
"vue-eslint-parser": "^10.4.0",
|
||||||
"vue-i18n": "^11.3.0",
|
"vue-i18n": "^11.3.0",
|
||||||
"vue-router": "^5.0.3",
|
"vue-router": "^5.0.3",
|
||||||
"vue-tsc": "^3.2.6",
|
"vue-tsc": "^3.2.6",
|
||||||
|
|||||||
@@ -52,24 +52,6 @@ function combineYmlFiles(ymlFiles, outputPath) {
|
|||||||
console.log(`Created ${outputPath} with ${combinedData?.files?.length || 0} file entries`)
|
console.log(`Created ${outputPath} with ${combinedData?.files?.length || 0} file entries`)
|
||||||
}
|
}
|
||||||
|
|
||||||
function processSingleYmlFile(ymlFile, outputPath) {
|
|
||||||
if (!fs.existsSync(ymlFile)) {
|
|
||||||
console.log(`File not found: ${ymlFile}`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const content = fs.readFileSync(ymlFile, 'utf8')
|
|
||||||
const data = yaml.load(content)
|
|
||||||
|
|
||||||
if (data && data.files) {
|
|
||||||
data.files = removeDuplicates(data.files)
|
|
||||||
}
|
|
||||||
|
|
||||||
const ymlContent = yaml.dump(data, { lineWidth: -1 })
|
|
||||||
fs.writeFileSync(outputPath, ymlContent, 'utf8')
|
|
||||||
console.log(`Processed ${outputPath} with ${data?.files?.length || 0} file entries`)
|
|
||||||
}
|
|
||||||
|
|
||||||
function findYmlInFolder(basePath, folderPattern, ymlFileName) {
|
function findYmlInFolder(basePath, folderPattern, ymlFileName) {
|
||||||
const folders = fs.existsSync(basePath)
|
const folders = fs.existsSync(basePath)
|
||||||
? fs.readdirSync(basePath).filter(f => {
|
? fs.readdirSync(basePath).filter(f => {
|
||||||
|
|||||||
@@ -29,11 +29,9 @@ const handleClipboardUploadingReturnCtx = async (img?: IUploadOption): Promise<I
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
export const uploadClipboardFiles = async (): Promise<IStringKeyMap> => {
|
||||||
let img: ImgInfo[] | false = false
|
|
||||||
let backImg: ImgInfo[] | false = false
|
|
||||||
const res = await handleClipboardUploadingReturnCtx()
|
const res = await handleClipboardUploadingReturnCtx()
|
||||||
img = res.ctx?.output ? res.ctx.output : false
|
const img = res.ctx?.output ? res.ctx.output : false
|
||||||
backImg = res.backupCtx?.output ? res.backupCtx.output : false
|
const backImg = res.backupCtx?.output ? res.backupCtx.output : false
|
||||||
const allConfig = picgo.getConfig<any>() || {}
|
const allConfig = picgo.getConfig<any>() || {}
|
||||||
if (img !== false) {
|
if (img !== false) {
|
||||||
if (img.length > 0) {
|
if (img.length > 0) {
|
||||||
@@ -97,11 +95,9 @@ export const uploadChoosedFiles = async (
|
|||||||
): Promise<IStringKeyMap[]> => {
|
): Promise<IStringKeyMap[]> => {
|
||||||
const input = files.map(item => item.path)
|
const input = files.map(item => item.path)
|
||||||
const rawInput = cloneDeep(input)
|
const rawInput = cloneDeep(input)
|
||||||
let imgs: ImgInfo[] | false = false
|
|
||||||
let backImgs: ImgInfo[] | false = false
|
|
||||||
const res = await uploader.setWebContents(webContents).uploadReturnCtx(input)
|
const res = await uploader.setWebContents(webContents).uploadReturnCtx(input)
|
||||||
imgs = res.ctx?.output ? res.ctx.output : false
|
const imgs = res.ctx?.output ? res.ctx.output : false
|
||||||
backImgs = res.backupCtx?.output ? res.backupCtx.output : false
|
const backImgs = res.backupCtx?.output ? res.backupCtx.output : false
|
||||||
const result = []
|
const result = []
|
||||||
const allConfig = picgo.getConfig<any>() || {}
|
const allConfig = picgo.getConfig<any>() || {}
|
||||||
if (imgs !== false) {
|
if (imgs !== false) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function dbChecker() {
|
|||||||
if (!fs.existsSync(configFilePath)) {
|
if (!fs.existsSync(configFilePath)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let configFile: string = '{}'
|
let configFile: string
|
||||||
const optionsTpl = {
|
const optionsTpl = {
|
||||||
title: $t('TIPS_NOTICE'),
|
title: $t('TIPS_NOTICE'),
|
||||||
body: '',
|
body: '',
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default [
|
|||||||
return true
|
return true
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
throw new Error('Migrate failed')
|
throw new Error('Migrate failed', { cause: err })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE,
|
type: IRPCType.INVOKE,
|
||||||
@@ -77,7 +77,7 @@ export default [
|
|||||||
)
|
)
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
throw new Error('Migrate failed')
|
throw new Error('Migrate failed', { cause: err })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
type: IRPCType.INVOKE,
|
type: IRPCType.INVOKE,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export default [
|
|||||||
{
|
{
|
||||||
action: IRPCActionType.PICLIST_OPEN_FILE,
|
action: IRPCActionType.PICLIST_OPEN_FILE,
|
||||||
handler: async (_: IIPCEvent, args: [fileName: string]) => {
|
handler: async (_: IIPCEvent, args: [fileName: string]) => {
|
||||||
let abFilePath = path.join(STORE_PATH, args[0])
|
let abFilePath: string
|
||||||
switch (args[0]) {
|
switch (args[0]) {
|
||||||
case 'piclist.log':
|
case 'piclist.log':
|
||||||
abFilePath = appLogPath()
|
abFilePath = appLogPath()
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ class AliyunApi {
|
|||||||
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
let res: any
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -279,7 +279,7 @@ class AliyunApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
let res: any
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -42,9 +42,8 @@ class GithubApi {
|
|||||||
|
|
||||||
formatFolder(item: any, slicedPrefix: string, branch: string, repo: string, cdnUrl: string | undefined) {
|
formatFolder(item: any, slicedPrefix: string, branch: string, repo: string, cdnUrl: string | undefined) {
|
||||||
const key = `${slicedPrefix ? `${slicedPrefix}/` : ''}${item.path}/`
|
const key = `${slicedPrefix ? `${slicedPrefix}/` : ''}${item.path}/`
|
||||||
let rawUrl = ''
|
|
||||||
const placeholders = ['{username}', '{repo}', '{branch}', '{path}']
|
const placeholders = ['{username}', '{repo}', '{branch}', '{path}']
|
||||||
rawUrl = cdnUrl
|
let rawUrl = cdnUrl
|
||||||
? placeholders.some(item => cdnUrl.includes(item))
|
? placeholders.some(item => cdnUrl.includes(item))
|
||||||
? placeholders.reduce((url, ph) => {
|
? placeholders.reduce((url, ph) => {
|
||||||
const value =
|
const value =
|
||||||
@@ -78,10 +77,9 @@ class GithubApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
formatFile(item: any, slicedPrefix: string, branch: string, repo: string, cdnUrl: string | undefined) {
|
formatFile(item: any, slicedPrefix: string, branch: string, repo: string, cdnUrl: string | undefined) {
|
||||||
let rawUrl = ''
|
|
||||||
const placeholders = ['{username}', '{repo}', '{branch}', '{path}']
|
const placeholders = ['{username}', '{repo}', '{branch}', '{path}']
|
||||||
const key = slicedPrefix === '' ? item.path : `${slicedPrefix}/${item.path}`
|
const key = slicedPrefix === '' ? item.path : `${slicedPrefix}/${item.path}`
|
||||||
rawUrl = cdnUrl
|
let rawUrl = cdnUrl
|
||||||
? placeholders.some(item => cdnUrl.includes(item))
|
? placeholders.some(item => cdnUrl.includes(item))
|
||||||
? placeholders.reduce((url, ph) => {
|
? placeholders.reduce((url, ph) => {
|
||||||
const value =
|
const value =
|
||||||
@@ -194,7 +192,6 @@ class GithubApi {
|
|||||||
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -207,7 +204,7 @@ class GithubApi {
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
const currentPrefix = treeQueue[0]
|
const currentPrefix = treeQueue[0]
|
||||||
res = (await got(
|
const res = (await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${treeQueue.shift()}`,
|
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${treeQueue.shift()}`,
|
||||||
getOptions('GET', this.commonHeaders, {}, 'json', undefined, undefined, this.proxy),
|
getOptions('GET', this.commonHeaders, {}, 'json', undefined, undefined, this.proxy),
|
||||||
)) as any
|
)) as any
|
||||||
@@ -245,16 +242,15 @@ class GithubApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
}
|
}
|
||||||
res = await got(
|
const res = (await got(
|
||||||
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${slicedPrefix}`,
|
`${this.baseUrl}/repos/${this.username}/${repo}/git/trees/${branch}:${slicedPrefix}`,
|
||||||
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
getOptions('GET', this.commonHeaders, undefined, 'json', undefined, undefined, this.proxy),
|
||||||
)
|
)) as any
|
||||||
if (res && res.statusCode === 200) {
|
if (res && res.statusCode === 200) {
|
||||||
res.body.tree.forEach((item: any) => {
|
res.body.tree.forEach((item: any) => {
|
||||||
if (item.type === 'tree') {
|
if (item.type === 'tree') {
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ class ImgurApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
let res: any
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -84,14 +84,13 @@ class LocalApi {
|
|||||||
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
res = fsWalk.walkSync(this.transBack(prefix), {
|
const res = fsWalk.walkSync(this.transBack(prefix), {
|
||||||
followSymbolicLinks: true,
|
followSymbolicLinks: true,
|
||||||
fs,
|
fs,
|
||||||
stats: true,
|
stats: true,
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class QiniuApi {
|
|||||||
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
let res: any
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -308,7 +308,7 @@ class QiniuApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
let res: any
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -384,14 +384,13 @@ class QiniuApi {
|
|||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const config = new qiniu.conf.Config()
|
const config = new qiniu.conf.Config()
|
||||||
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
nextMarker: '',
|
nextMarker: '',
|
||||||
success: false,
|
success: false,
|
||||||
}
|
}
|
||||||
res = await new Promise((resolve, reject) => {
|
const res = (await new Promise((resolve, reject) => {
|
||||||
bucketManager.listPrefix(
|
bucketManager.listPrefix(
|
||||||
bucket,
|
bucket,
|
||||||
{
|
{
|
||||||
@@ -411,7 +410,7 @@ class QiniuApi {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
})
|
})) as any
|
||||||
if (res?.respInfo?.statusCode === 200) {
|
if (res?.respInfo?.statusCode === 200) {
|
||||||
if (res.respBody?.commonPrefixes) {
|
if (res.respBody?.commonPrefixes) {
|
||||||
res.respBody.commonPrefixes.forEach((item: string) => {
|
res.respBody.commonPrefixes.forEach((item: string) => {
|
||||||
@@ -467,7 +466,7 @@ class QiniuApi {
|
|||||||
const config = new qiniu.conf.Config()
|
const config = new qiniu.conf.Config()
|
||||||
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
const bucketManager = new qiniu.rs.BucketManager(this.mac, config)
|
||||||
let marker = ''
|
let marker = ''
|
||||||
let isTruncated = true
|
let isTruncated: boolean
|
||||||
const allFileList = {
|
const allFileList = {
|
||||||
Contents: [] as any[],
|
Contents: [] as any[],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ class S3plistApi {
|
|||||||
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as ListObjectsV2CommandOutput
|
let res: ListObjectsV2CommandOutput
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -386,7 +386,7 @@ class S3plistApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as ListObjectsV2CommandOutput
|
let res: ListObjectsV2CommandOutput
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ class SftpApi {
|
|||||||
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -168,7 +167,7 @@ class SftpApi {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.connectClient()
|
await this.connectClient()
|
||||||
res = await this.ctx.execCommand(`cd "${prefix}" && ls -la --time-style=long-iso`)
|
const res = await this.ctx.execCommand(`cd "${prefix}" && ls -la --time-style=long-iso`)
|
||||||
this.ctx.close()
|
this.ctx.close()
|
||||||
if (this.isRequestSuccess(res.code)) {
|
if (this.isRequestSuccess(res.code)) {
|
||||||
const formatedLSRes = this.formatLSResult(res.stdout, prefix)
|
const formatedLSRes = this.formatLSResult(res.stdout, prefix)
|
||||||
@@ -231,7 +230,6 @@ class SftpApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -239,7 +237,7 @@ class SftpApi {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await this.connectClient()
|
await this.connectClient()
|
||||||
res = await this.ctx.execCommand(`cd "${prefix}" && ls -la --time-style=long-iso`)
|
const res = await this.ctx.execCommand(`cd "${prefix}" && ls -la --time-style=long-iso`)
|
||||||
this.ctx.close()
|
this.ctx.close()
|
||||||
if (this.isRequestSuccess(res.code)) {
|
if (this.isRequestSuccess(res.code)) {
|
||||||
const formatedLSRes = this.formatLSResult(res.stdout, prefix)
|
const formatedLSRes = this.formatLSResult(res.stdout, prefix)
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class SmmsApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
let res: any
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ class TcyunApi {
|
|||||||
success: false,
|
success: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
}
|
}
|
||||||
let res = {} as COS.GetBucketResult
|
let res: COS.GetBucketResult
|
||||||
do {
|
do {
|
||||||
res = await this.ctx.getBucket({
|
res = await this.ctx.getBucket({
|
||||||
Bucket: bucket,
|
Bucket: bucket,
|
||||||
@@ -169,7 +169,7 @@ class TcyunApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as COS.GetBucketResult
|
let res: COS.GetBucketResult
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ class UpyunApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
let res: any
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
@@ -230,14 +230,13 @@ class UpyunApi {
|
|||||||
const { bucketName: bucket, prefix, marker, itemsPerPage } = configMap
|
const { bucketName: bucket, prefix, marker, itemsPerPage } = configMap
|
||||||
const slicedPrefix = prefix.slice(1)
|
const slicedPrefix = prefix.slice(1)
|
||||||
const urlPrefix = configMap.customUrl || `http://${bucket}.test.upcdn.net`
|
const urlPrefix = configMap.customUrl || `http://${bucket}.test.upcdn.net`
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
isTruncated: false,
|
isTruncated: false,
|
||||||
nextMarker: '',
|
nextMarker: '',
|
||||||
success: false,
|
success: false,
|
||||||
}
|
}
|
||||||
res = await this.cli.listDir(prefix, {
|
const res = await this.cli.listDir(prefix, {
|
||||||
limit: itemsPerPage,
|
limit: itemsPerPage,
|
||||||
iter: marker || '',
|
iter: marker || '',
|
||||||
})
|
})
|
||||||
@@ -339,9 +338,8 @@ class UpyunApi {
|
|||||||
}
|
}
|
||||||
} while (isTruncated)
|
} while (isTruncated)
|
||||||
if (allFileList.Contents.length > 0) {
|
if (allFileList.Contents.length > 0) {
|
||||||
let success = false
|
|
||||||
for (const allFileListItem of allFileList.Contents) {
|
for (const allFileListItem of allFileList.Contents) {
|
||||||
success = await this.cli.deleteFile(allFileListItem.key)
|
const success = await this.cli.deleteFile(allFileListItem.key)
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,17 +108,16 @@ class WebdavplistApi {
|
|||||||
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
ipcMain.removeAllListeners(cancelDownloadLoadingFileList)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
res = await this.ctx.getDirectoryContents(prefix, {
|
const res = (await this.ctx.getDirectoryContents(prefix, {
|
||||||
deep: true,
|
deep: true,
|
||||||
details: true,
|
details: true,
|
||||||
})
|
})) as any
|
||||||
if (this.isRequestSuccess(res.status)) {
|
if (this.isRequestSuccess(res.status)) {
|
||||||
if (res.data?.length) {
|
if (res.data?.length) {
|
||||||
res.data.forEach((item: FileStat) => {
|
res.data.forEach((item: FileStat) => {
|
||||||
@@ -153,17 +152,16 @@ class WebdavplistApi {
|
|||||||
ipcMain.removeAllListeners('cancelLoadingFileList')
|
ipcMain.removeAllListeners('cancelLoadingFileList')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let res = {} as any
|
|
||||||
const result = {
|
const result = {
|
||||||
fullList: [] as any,
|
fullList: [] as any,
|
||||||
success: false,
|
success: false,
|
||||||
finished: false,
|
finished: false,
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
res = await this.ctx.getDirectoryContents(prefix, {
|
const res = (await this.ctx.getDirectoryContents(prefix, {
|
||||||
deep: false,
|
deep: false,
|
||||||
details: true,
|
details: true,
|
||||||
})
|
})) as any
|
||||||
if (this.isRequestSuccess(res.status)) {
|
if (this.isRequestSuccess(res.status)) {
|
||||||
if (res.data?.length) {
|
if (res.data?.length) {
|
||||||
res.data.forEach((item: FileStat) => {
|
res.data.forEach((item: FileStat) => {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function manageDbChecker() {
|
|||||||
if (!fs.existsSync(manageConfigFilePath)) {
|
if (!fs.existsSync(manageConfigFilePath)) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let configFile: string = '{}'
|
let configFile: string
|
||||||
const optionsTpl = {
|
const optionsTpl = {
|
||||||
title: $t('TIPS_NOTICE'),
|
title: $t('TIPS_NOTICE'),
|
||||||
body: '',
|
body: '',
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ export async function dogecloudApi(
|
|||||||
throw new Error('API Error')
|
throw new Error('API Error')
|
||||||
}
|
}
|
||||||
return res.data.data
|
return res.data.data
|
||||||
} catch (_e: any) {
|
} catch (e: any) {
|
||||||
throw new Error('API Error')
|
throw new Error('API Error', { cause: e })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ StartupNotify=true
|
|||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||||
throw new Error(`Failed to ${enable ? 'enable' : 'disable'} auto-start: ${errorMessage}`)
|
throw new Error(`Failed to ${enable ? 'enable' : 'disable'} auto-start: ${errorMessage}`, { cause: error })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,6 +55,6 @@ export const isAutoStartEnabled = async (): Promise<boolean> => {
|
|||||||
return fs.pathExists(desktopFile)
|
return fs.pathExists(desktopFile)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||||
throw new Error(`Failed to check auto-start status: ${errorMessage}`)
|
throw new Error(`Failed to check auto-start status: ${errorMessage}`, { cause: error })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -350,8 +350,8 @@ export const extractData = async (zipPath: string): Promise<Record<string, any>>
|
|||||||
const buffer = await fs.readFile(zipPath)
|
const buffer = await fs.readFile(zipPath)
|
||||||
const str = strFromU8(gunzipSync(buffer))
|
const str = strFromU8(gunzipSync(buffer))
|
||||||
return JSON.parse(str)
|
return JSON.parse(str)
|
||||||
} catch (_err) {
|
} catch (err) {
|
||||||
throw new Error('Extract failed')
|
throw new Error('Extract failed', { cause: err })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,8 +360,8 @@ export const zipData = async (data: Record<string, any>, zipPath: string): Promi
|
|||||||
const buffer = Buffer.from(JSON.stringify(data))
|
const buffer = Buffer.from(JSON.stringify(data))
|
||||||
const compressed = gzipSync(buffer)
|
const compressed = gzipSync(buffer)
|
||||||
await fs.writeFile(zipPath, Buffer.from(compressed))
|
await fs.writeFile(zipPath, Buffer.from(compressed))
|
||||||
} catch (_err) {
|
} catch (err) {
|
||||||
throw new Error('Zip failed')
|
throw new Error('Zip failed', { cause: err })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ async function dogecloudApi(
|
|||||||
throw new Error('API Error')
|
throw new Error('API Error')
|
||||||
}
|
}
|
||||||
return res.data.data
|
return res.data.data
|
||||||
} catch (_err: any) {
|
} catch (err: any) {
|
||||||
throw new Error('API Error')
|
throw new Error('API Error', { cause: err })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ class SSHClient {
|
|||||||
this._isConnected = true
|
this._isConnected = true
|
||||||
return true
|
return true
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
throw new Error(err)
|
throw new Error(err, { cause: err })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ const mergeGalleryDB = async (targetFile: string) => {
|
|||||||
await fs.copyFile(targetFilePath, path.join(STORE_PATH, targetFile))
|
await fs.copyFile(targetFilePath, path.join(STORE_PATH, targetFile))
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
logger.error('merge gallery db failed:', String(err))
|
logger.error('merge gallery db failed:', String(err))
|
||||||
throw new Error('merge gallery db failed')
|
throw new Error('merge gallery db failed', { cause: err })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +218,7 @@ async function uploadFile(fileName: string[]): Promise<number> {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
const uploadFunc = async (file: string): Promise<number> => {
|
const uploadFunc = async (file: string): Promise<number> => {
|
||||||
let result = false
|
let result: boolean
|
||||||
try {
|
try {
|
||||||
result = await updateLocalToRemote(syncConfig, file)
|
result = await updateLocalToRemote(syncConfig, file)
|
||||||
} catch (_e: any) {
|
} catch (_e: any) {
|
||||||
@@ -559,7 +559,7 @@ async function checkCloudFileExist(syncConfig: ISyncConfig, fileName: string) {
|
|||||||
}
|
}
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
logger.error(error)
|
logger.error(error)
|
||||||
throw new Error('check file exist failed')
|
throw new Error('check file exist failed', { cause: error })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1252,7 +1252,7 @@ async function initData() {
|
|||||||
globalAutoRename.value = allConfig.settings?.autoRename ?? false
|
globalAutoRename.value = allConfig.settings?.autoRename ?? false
|
||||||
globalManualRename.value = allConfig.settings?.rename ?? false
|
globalManualRename.value = allConfig.settings?.rename ?? false
|
||||||
if (compressInFile) {
|
if (compressInFile) {
|
||||||
let cleanedObj = {}
|
let cleanedObj: Record<string, any>
|
||||||
try {
|
try {
|
||||||
if (typeof compressInFile.formatConvertObj === 'object') {
|
if (typeof compressInFile.formatConvertObj === 'object') {
|
||||||
cleanedObj = cleanFormatConvertObj(compressInFile.formatConvertObj)
|
cleanedObj = cleanFormatConvertObj(compressInFile.formatConvertObj)
|
||||||
@@ -1343,7 +1343,7 @@ async function initData() {
|
|||||||
mergedWatermark[key as keyof IBuildInWaterMarkOptions] = mergedWatermark[mapFieldName][currentPicbedName]
|
mergedWatermark[key as keyof IBuildInWaterMarkOptions] = mergedWatermark[mapFieldName][currentPicbedName]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
let cleanedFormatConvertObj = {}
|
let cleanedFormatConvertObj: Record<string, any>
|
||||||
try {
|
try {
|
||||||
const parsedObj = JSON.parse(singleConfigInFile.compress?.formatConvertObj as any)
|
const parsedObj = JSON.parse(singleConfigInFile.compress?.formatConvertObj as any)
|
||||||
cleanedFormatConvertObj = cleanFormatConvertObj(parsedObj)
|
cleanedFormatConvertObj = cleanFormatConvertObj(parsedObj)
|
||||||
@@ -1388,9 +1388,8 @@ function safeSetMapValue(form: any, fieldName: string, picbedType: string, value
|
|||||||
const mapFieldName = `${fieldName}Map`
|
const mapFieldName = `${fieldName}Map`
|
||||||
if (fieldName === 'formatConvertObj') {
|
if (fieldName === 'formatConvertObj') {
|
||||||
value = value || '{}'
|
value = value || '{}'
|
||||||
let parsedObj = {}
|
|
||||||
try {
|
try {
|
||||||
parsedObj = JSON.parse(value)
|
const parsedObj = JSON.parse(value)
|
||||||
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
||||||
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
||||||
value = JSON.stringify(cleanedObj)
|
value = JSON.stringify(cleanedObj)
|
||||||
@@ -1692,9 +1691,8 @@ watch(activeTab, () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(singleFormatConvertObj, () => {
|
watch(singleFormatConvertObj, () => {
|
||||||
let parsedObj = {}
|
|
||||||
try {
|
try {
|
||||||
parsedObj = JSON.parse(singleFormatConvertObj.value)
|
const parsedObj = JSON.parse(singleFormatConvertObj.value)
|
||||||
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
||||||
singleConfigSettings.value.compress!.formatConvertObj = cleanedObj
|
singleConfigSettings.value.compress!.formatConvertObj = cleanedObj
|
||||||
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
||||||
@@ -1706,9 +1704,8 @@ watch(singleFormatConvertObj, () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(formatConvertObjStr, () => {
|
watch(formatConvertObjStr, () => {
|
||||||
let parsedObj = {}
|
|
||||||
try {
|
try {
|
||||||
parsedObj = JSON.parse(formatConvertObjStr.value)
|
const parsedObj = JSON.parse(formatConvertObjStr.value)
|
||||||
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
const cleanedObj = cleanFormatConvertObj(parsedObj)
|
||||||
compressForm.value.formatConvertObj = cleanedObj
|
compressForm.value.formatConvertObj = cleanedObj
|
||||||
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
if (JSON.stringify(cleanedObj) !== JSON.stringify(parsedObj)) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ const imageSource = computed(() => {
|
|||||||
const iconPath = computed(() => `./assets/icons/${getFileIconPath(props.item.fileName ?? '')}`)
|
const iconPath = computed(() => `./assets/icons/${getFileIconPath(props.item.fileName ?? '')}`)
|
||||||
|
|
||||||
async function getWebdavHeader(key: string) {
|
async function getWebdavHeader(key: string) {
|
||||||
let headers = {} as any
|
let headers: Record<string, any>
|
||||||
if (props.config.authType === 'digest') {
|
if (props.config.authType === 'digest') {
|
||||||
const authHeader = await getAuthHeader(
|
const authHeader = await getAuthHeader(
|
||||||
'GET',
|
'GET',
|
||||||
|
|||||||
@@ -2007,16 +2007,16 @@ async function saveEditorContent() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function saveFile(file: string, content: string) {
|
async function saveFile(file: string, content: string) {
|
||||||
let dataToSave = content
|
let formattedContent: string
|
||||||
try {
|
try {
|
||||||
dataToSave = JSON.stringify(JSON.parse(content), null, 2)
|
formattedContent = JSON.stringify(JSON.parse(content), null, 2)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Invalid JSON content:', error)
|
console.error('Invalid JSON content:', error)
|
||||||
message.error(t('pages.settings.advanced.invalidJson'))
|
message.error(t('pages.settings.advanced.invalidJson'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
window.electron.sendRPC(IRPCActionType.WRITE_FILE_CONTENT, file, dataToSave)
|
window.electron.sendRPC(IRPCActionType.WRITE_FILE_CONTENT, file, formattedContent)
|
||||||
message.success(t('pages.settings.advanced.saveFileSuccess'))
|
message.success(t('pages.settings.advanced.saveFileSuccess'))
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
window.electron.sendRPC(IRPCActionType.RELOAD_WINDOW)
|
window.electron.sendRPC(IRPCActionType.RELOAD_WINDOW)
|
||||||
|
|||||||
@@ -1,26 +1,37 @@
|
|||||||
import { RELEASE_URL, RELEASE_URL_BACKUP } from '@/utils/static'
|
import { RELEASE_URL, RELEASE_URL_BACKUP } from '@/utils/static'
|
||||||
|
|
||||||
|
async function fetchData(url: string, options?: RequestInit) {
|
||||||
|
const response = await fetch(url, options)
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! status: ${response.status}`, {
|
||||||
|
cause: { url, status: response.status },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
export const getLatestVersion = async (): Promise<string> => {
|
export const getLatestVersion = async (): Promise<string> => {
|
||||||
|
let primaryError: unknown
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(RELEASE_URL)
|
const response = await fetchData(RELEASE_URL)
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error! status: ${response.status}`)
|
|
||||||
}
|
|
||||||
const normalList = await response.json()
|
const normalList = await response.json()
|
||||||
return normalList[0].name
|
return normalList[0]?.name ?? ''
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error fetching latest version: ', err)
|
primaryError = err
|
||||||
try {
|
console.warn('Primary version fetch failed, trying backup...', err)
|
||||||
const response = await fetch(`${RELEASE_URL_BACKUP}/latest.yml`)
|
}
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP error! status: ${response.status}`)
|
try {
|
||||||
}
|
const response = await fetchData(`${RELEASE_URL_BACKUP}/latest.yml`)
|
||||||
const data = await response.text()
|
const data = await response.text()
|
||||||
const r = window.node.yaml.parse(data).toJSON() as IStringKeyMap
|
const r = window.node.yaml.parse(data).toJSON() as IStringKeyMap
|
||||||
return r.version
|
return r.version || ''
|
||||||
} catch (err) {
|
} catch (backupErr) {
|
||||||
console.error('Error fetching backup latest version: ', err)
|
const finalError = new Error('Both primary and backup version fetch failed', {
|
||||||
return ''
|
cause: { primaryError, backupErr },
|
||||||
}
|
})
|
||||||
|
console.error(finalError)
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,19 +11,18 @@
|
|||||||
"experimentalDecorators": true,
|
"experimentalDecorators": true,
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"baseUrl": ".",
|
|
||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"typeRoots": ["./node_modules/@types", "./src/universal/types/"],
|
"typeRoots": ["./node_modules/@types", "./src/universal/types/"],
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["src/renderer/*"],
|
"@/*": ["./src/renderer/*"],
|
||||||
"~/*": ["src/main/*"],
|
"~/*": ["./src/main/*"],
|
||||||
"root/*": ["./*"],
|
"root/*": ["./*"],
|
||||||
"#/*": ["src/universal/*"],
|
"#/*": ["./src/universal/*"],
|
||||||
"apis/*": ["src/main/apis/*"],
|
"apis/*": ["./src/main/apis/*"],
|
||||||
"@core/*": ["src/main/apis/core/*"]
|
"@core/*": ["./src/main/apis/core/*"]
|
||||||
},
|
},
|
||||||
"lib": ["ESNext", "dom", "dom.iterable", "ScriptHost"]
|
"lib": ["ESNext", "dom", "dom.iterable", "ScriptHost"]
|
||||||
},
|
},
|
||||||
"include": ["src/**/*.ts", "src/**/*.vue", "src/**/*.d.ts", "tests/**/*.ts", "electron.vite.config.*"],
|
"include": ["./src/**/*.ts", "./src/**/*.vue", "./src/**/*.d.ts", "./tests/**/*.ts", "./electron.vite.config.*"],
|
||||||
"exclude": ["node_modules", "dist", "out"]
|
"exclude": ["./node_modules", "./dist", "./out"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user