diff --git a/electron/main/backend/install-manager.ts b/electron/main/backend/install-manager.ts index 2c0687a4..72ad73c5 100644 --- a/electron/main/backend/install-manager.ts +++ b/electron/main/backend/install-manager.ts @@ -428,14 +428,23 @@ ipcMain.handle("check-installed", async (_event, payload: any) => { let isInstalled = false; if (origin === "apm") { - const { code, stdout } = await runCommandCapture("apm", ["list", "--installed"]); + const { code, stdout } = await runCommandCapture("apm", [ + "list", + "--installed", + ]); if (code === 0) { // eslint-disable-next-line no-control-regex const cleanStdout = stdout.replace(/\x1b\[[0-9;]*m/g, ""); const lines = cleanStdout.split("\n"); for (const line of lines) { const trimmed = line.trim(); - if (!trimmed || trimmed.startsWith("Listing") || trimmed.startsWith("[INFO]") || trimmed.startsWith("警告")) continue; + if ( + !trimmed || + trimmed.startsWith("Listing") || + trimmed.startsWith("[INFO]") || + trimmed.startsWith("警告") + ) + continue; if (trimmed.includes("/")) { const installedPkg = trimmed.split("/")[0].trim(); if (installedPkg === pkgname) { diff --git a/electron/preload/index.ts b/electron/preload/index.ts index 5ae928df..aab78e57 100644 --- a/electron/preload/index.ts +++ b/electron/preload/index.ts @@ -29,9 +29,11 @@ contextBridge.exposeInMainWorld("apm_store", { arch: (() => { const arch = process.arch; if (arch === "x64") { - return "amd64" + "-store"; + return "amd64"; + } else if (arch === "arm64") { + return "arm64"; } else { - return arch + "-store"; + return arch; } })(), }); diff --git a/src/App.vue b/src/App.vue index a57e1b25..a039a719 100644 --- a/src/App.vue +++ b/src/App.vue @@ -239,67 +239,6 @@ const updateError = ref(""); const showUninstallModal = ref(false); const uninstallTargetApp: Ref = ref(null); -// 缓存不同模式的数据 -const storeCache = ref< - Record< - string, - { - apps: App[]; - categories: Record; - homeLinks: HomeLink[]; - homeLists: HomeList[]; - } - > ->({}); - -const saveToCache = (mode: string) => { - storeCache.value[mode] = { - apps: [...apps.value], - categories: { ...categories.value }, - homeLinks: [...homeLinks.value], - homeLists: [...homeLists.value], - }; -}; - -const restoreFromCache = (mode: string) => { - const cache = storeCache.value[mode]; - if (cache) { - apps.value = [...cache.apps]; - categories.value = { ...cache.categories }; - homeLinks.value = [...cache.homeLinks]; - homeLists.value = [...cache.homeLists]; - return true; - } - return false; -}; - -// 监听模式变化 -watch(currentStoreMode, async (newMode, oldMode) => { - if (oldMode) { - saveToCache(oldMode); - } - - if (!restoreFromCache(newMode)) { - // 如果没有缓存,清空当前状态并重新加载 - apps.value = []; - categories.value = {}; - homeLinks.value = []; - homeLists.value = []; - - loading.value = true; - await loadCategories(); - await Promise.all([ - loadHome(), - new Promise((resolve) => { - loadApps(() => { - loading.value = false; - resolve(); - }); - }), - ]); - } -}); - // 计算属性 const filteredApps = computed(() => { let result = [...apps.value]; @@ -475,11 +414,8 @@ const checkAppInstalled = (app: App) => { const loadScreenshots = (app: App) => { screenshots.value = []; - const arch = window.apm_store.arch || "amd64-apm"; - const finalArch = - app.origin === "spark" - ? arch.replace("-apm", "-store") - : arch.replace("-store", "-apm"); + const arch = window.apm_store.arch || "amd64"; + const finalArch = app.origin === "spark" ? `${arch}-store` : `${arch}-apm`; for (let i = 1; i <= 5; i++) { const screenshotUrl = `${APM_STORE_BASE_URL}/${finalArch}/${app.category}/${app.pkgname}/screen_${i}.png`; screenshots.value.push(screenshotUrl); @@ -512,16 +448,11 @@ const loadHome = async () => { homeLinks.value = []; homeLists.value = []; try { - const arch = window.apm_store.arch || "amd64-apm"; - const modes: Array<"spark" | "apm"> = []; - if (currentStoreMode.value === "hybrid") modes.push("spark", "apm"); - else modes.push(currentStoreMode.value as "spark" | "apm"); + const arch = window.apm_store.arch || "amd64"; + const modes: Array<"spark" | "apm"> = ["spark", "apm"]; // 只保留混合模式 for (const mode of modes) { - const finalArch = - mode === "spark" - ? arch.replace("-apm", "-store") - : arch.replace("-store", "-apm"); + const finalArch = mode === "spark" ? `${arch}-store` : `${arch}-apm`; const base = `${APM_STORE_BASE_URL}/${finalArch}/home`; // homelinks.json @@ -662,7 +593,7 @@ const refreshUpgradableApps = async () => { updateError.value = result?.message || "检查更新失败"; return; } - // eslint-disable-next-line @typescript-eslint/no-explicit-any + upgradableApps.value = (result.apps || []).map( (app: Record) => ({ ...app, @@ -923,18 +854,13 @@ const openDownloadedApp = (pkgname: string, origin?: "spark" | "apm") => { const loadCategories = async () => { try { - const arch = window.apm_store.arch || "amd64-apm"; - const modes: Array<"spark" | "apm"> = []; - if (currentStoreMode.value === "hybrid") modes.push("spark", "apm"); - else modes.push(currentStoreMode.value as "spark" | "apm"); + const arch = window.apm_store.arch || "amd64"; + const modes: Array<"spark" | "apm"> = ["spark", "apm"]; const categoryData: Record = {}; for (const mode of modes) { - const finalArch = - mode === "spark" - ? arch.replace("-apm", "-store") - : arch.replace("-store", "-apm"); + const finalArch = mode === "spark" ? `${arch}-store` : `${arch}-apm`; const path = mode === "spark" ? "/store/categories.json" @@ -971,7 +897,7 @@ const loadApps = async (onFirstBatch?: () => void) => { const categoriesList = Object.keys(categories.value || {}); let firstBatchCallDone = false; - const arch = window.apm_store.arch || "amd64-apm"; + const arch = window.apm_store.arch || "amd64"; // 并发加载所有分类,每个分类自带重试机制 await Promise.all( @@ -985,9 +911,7 @@ const loadApps = async (onFirstBatch?: () => void) => { origins.map(async (mode) => { try { const finalArch = - mode === "spark" - ? arch.replace("-apm", "-store") - : arch.replace("-store", "-apm"); + mode === "spark" ? `${arch}-store` : `${arch}-apm`; const path = mode === "spark" diff --git a/src/components/AppCard.vue b/src/components/AppCard.vue index 02cc7f62..9dac369f 100644 --- a/src/components/AppCard.vue +++ b/src/components/AppCard.vue @@ -72,11 +72,9 @@ const loadedIcon = ref( ); const iconPath = computed(() => { - const arch = window.apm_store.arch || "amd64-apm"; + const arch = window.apm_store.arch || "amd64"; const finalArch = - props.app.origin === "spark" - ? arch.replace("-apm", "-store") - : arch.replace("-store", "-apm"); + props.app.origin === "spark" ? `${arch}-store` : `${arch}-apm`; return `${APM_STORE_BASE_URL}/${finalArch}/${props.app.category}/${props.app.pkgname}/icon.png`; }); diff --git a/src/components/AppDetailModal.vue b/src/components/AppDetailModal.vue index 167dd093..75d60120 100644 --- a/src/components/AppDetailModal.vue +++ b/src/components/AppDetailModal.vue @@ -109,7 +109,13 @@