From f7667b5ff63674043c9c25beda0159cb4bd3721a Mon Sep 17 00:00:00 2001 From: Kuingsmile <96409857+Kuingsmile@users.noreply.github.com> Date: Thu, 15 Jan 2026 11:18:40 +0800 Subject: [PATCH] :sparkles: Feature(custom): optimize theme download logic --- src/main/apis/app/theme/index.ts | 7 ++++--- src/main/events/rpc/routes/system/app.ts | 2 +- src/renderer/pages/PicGoSetting.vue | 5 ++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/apis/app/theme/index.ts b/src/main/apis/app/theme/index.ts index 1bdc444a..76db6e03 100644 --- a/src/main/apis/app/theme/index.ts +++ b/src/main/apis/app/theme/index.ts @@ -43,7 +43,7 @@ export async function resolveThemes(): Promise<{ key: string; label: string }[]> } } -export async function fetchThemes(): Promise { +export async function fetchThemes(): Promise { try { const zipUrl = 'https://github.com/Kuingsmile/piclist-themeHub/releases/download/latest/themes.zip' const zipData = await axios.get(zipUrl, { @@ -51,9 +51,10 @@ export async function fetchThemes(): Promise { headers: { 'Content-Type': 'application/octet-stream' }, }) const zip = new AdmZip(zipData.data as Buffer) - zip.extractAllTo(themesDir(), true) + zip.extractAllTo(path.join(themesDir()), true) + return true } catch (_e) { - console.error('Failed to fetch themes from remote.') + return false } } diff --git a/src/main/events/rpc/routes/system/app.ts b/src/main/events/rpc/routes/system/app.ts index 80a4859b..f373096a 100644 --- a/src/main/events/rpc/routes/system/app.ts +++ b/src/main/events/rpc/routes/system/app.ts @@ -62,7 +62,7 @@ export default [ { action: IRPCActionType.THEME_FETCH_THEMES, handler: async () => { - await fetchThemes() + return await fetchThemes() }, type: IRPCType.INVOKE, }, diff --git a/src/renderer/pages/PicGoSetting.vue b/src/renderer/pages/PicGoSetting.vue index 5584e603..9c054ba8 100644 --- a/src/renderer/pages/PicGoSetting.vue +++ b/src/renderer/pages/PicGoSetting.vue @@ -2142,7 +2142,10 @@ async function loadThemes() { async function handleDownloadThemes() { try { downloadingThemes.value = true - await window.electron.triggerRPC(IRPCActionType.THEME_FETCH_THEMES) + const result = await window.electron.triggerRPC(IRPCActionType.THEME_FETCH_THEMES) + if (!result) { + throw new Error('No themes were downloaded.') + } message.success(t('pages.settings.system.downloadThemesSuccess')) await loadThemes() } catch (error) {