From d206c79c2418736dee0105d7bf5990d1909e2a13 Mon Sep 17 00:00:00 2001 From: momen Date: Tue, 10 Mar 2026 00:52:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=80=9A=E8=BF=87E2E=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main/index.ts | 8 ++++---- playwright.config.ts | 4 ++-- src/App.vue | 8 +++++--- src/__tests__/unit/downloadStatus.test.ts | 8 ++------ src/components/HomeView.vue | 12 ++++++------ src/components/TopActions.vue | 4 ---- tsconfig.json | 21 +++++++++++++++++---- vitest.config.ts | 11 +++++++---- 8 files changed, 43 insertions(+), 33 deletions(-) diff --git a/electron/main/index.ts b/electron/main/index.ts index f496ece7..f0d7b969 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -222,16 +222,16 @@ app.on("will-quit", () => { // 获取图标路径 function getIconPath() { let iconPath = ""; - const iconFile = - process.platform === "win32" ? "amber-pm-logo.ico" : "spark-store.svg"; // 图标文件名,linux下需要png格式,不然会不显示 + const iconName = + process.platform === "win32" ? "amber-pm-logo.ico" : "amber-pm-logo.png"; // 图标文件名,linux下需要png格式,不然会不显示 // 判断是否在打包模式 if (app.isPackaged) { // 打包模式 - iconPath = path.join(process.resourcesPath, "icons", iconFile); // 路径根据自身情况调整 + iconPath = path.join(process.resourcesPath, "icons", iconName); // 路径根据自身情况调整 } else { // 开发模式 const projectRoot = path.join(__dirname, "../.."); // __dirname 指向 dist-electron/main,但资源在项目根目录,所以..指向上一级 - iconPath = path.join(projectRoot, "icons", iconFile); + iconPath = path.join(projectRoot, "icons", iconName); } // 检查文件是否存在 diff --git a/playwright.config.ts b/playwright.config.ts index adcdb1ec..dc2a1d92 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -11,7 +11,7 @@ export default defineConfig({ ["json", { outputFile: "test-results.json" }], ], use: { - baseURL: "http://127.0.0.1:3344", + baseURL: "http://127.0.0.1:5173", trace: "on-first-retry", screenshot: "only-on-failure", video: "retain-on-failure", @@ -24,7 +24,7 @@ export default defineConfig({ ], webServer: { command: "npm run dev", - url: "http://127.0.0.1:3344", + url: "http://127.0.0.1:5173", reuseExistingServer: !process.env.CI, timeout: 120 * 1000, stdout: "pipe", diff --git a/src/App.vue b/src/App.vue index 9df7e64e..74dc0a40 100644 --- a/src/App.vue +++ b/src/App.vue @@ -368,8 +368,10 @@ const closeScreenPreview = () => { }; // Home data -const homeLinks = ref([]); -const homeLists = ref>([]); +const homeLinks = ref[]>([]); +const homeLists = ref< + Array<{ title: string; apps: Record[] }> +>([]); const homeLoading = ref(false); const homeError = ref(""); @@ -405,7 +407,7 @@ const loadHome = async () => { const appsJson = await r.json(); const rawApps = appsJson || []; const apps = await Promise.all( - rawApps.map(async (a: any) => { + rawApps.map(async (a: Record) => { const baseApp = { name: a.Name || a.name || a.Pkgname || a.PkgName || "", pkgname: a.Pkgname || a.pkgname || "", diff --git a/src/__tests__/unit/downloadStatus.test.ts b/src/__tests__/unit/downloadStatus.test.ts index 6530d02d..6a7d0f34 100644 --- a/src/__tests__/unit/downloadStatus.test.ts +++ b/src/__tests__/unit/downloadStatus.test.ts @@ -1,9 +1,5 @@ import { describe, it, expect, beforeEach } from "vitest"; -import { - downloads, - addDownload, - removeDownloadItem, -} from "@/global/downloadStatus"; +import { downloads, removeDownloadItem } from "@/global/downloadStatus"; import type { DownloadItem } from "@/global/typedefinition"; describe("downloadStatus", () => { @@ -31,7 +27,7 @@ describe("downloadStatus", () => { retry: false, }; - addDownload(mockDownload); + downloads.value.push(mockDownload); expect(downloads.value).toHaveLength(1); expect(downloads.value[0].pkgname).toBe("test-app"); diff --git a/src/components/HomeView.vue b/src/components/HomeView.vue index 98f154c1..6a410193 100644 --- a/src/components/HomeView.vue +++ b/src/components/HomeView.vue @@ -51,15 +51,15 @@ import AppCard from "./AppCard.vue"; import { APM_STORE_BASE_URL } from "../global/storeConfig"; -const props = defineProps<{ - links: Array; - lists: Array<{ title: string; apps: any[] }>; +defineProps<{ + links: Array>; + lists: Array<{ title: string; apps: Record[] }>; loading: boolean; error: string; }>(); -const emit = defineEmits<{ - (e: "open-detail", app: any): void; +defineEmits<{ + (e: "open-detail", app: Record): void; }>(); const computedImgUrl = (imgUrl: string) => { @@ -68,7 +68,7 @@ const computedImgUrl = (imgUrl: string) => { return `${APM_STORE_BASE_URL}/${window.apm_store.arch}${imgUrl}`; }; -const onLinkClick = (link: any) => { +const onLinkClick = (link: Record) => { if (link.type === "_blank") { window.open(link.url, "_blank"); } else { diff --git a/src/components/TopActions.vue b/src/components/TopActions.vue index 15aa33bf..d0c8814a 100644 --- a/src/components/TopActions.vue +++ b/src/components/TopActions.vue @@ -41,10 +41,6 @@ const handleUpdate = () => { emit("update"); }; -const handleList = () => { - emit("list"); -}; - const handleSettings = () => { emit("open-install-settings"); }; diff --git a/tsconfig.json b/tsconfig.json index 6d0f5ee4..17632357 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,11 @@ { "compilerOptions": { + "baseUrl": ".", + "paths": { + "@/*": [ + "src/*" + ] + }, "target": "ESNext", "useDefineForClassFields": true, "module": "ESNext", @@ -9,12 +15,19 @@ "resolveJsonModule": true, "isolatedModules": true, "esModuleInterop": true, - "lib": ["ESNext", "DOM"], + "lib": [ + "ESNext", + "DOM" + ], "skipLibCheck": true, "noEmit": true }, - "include": ["src"], + "include": [ + "src" + ], "references": [ - { "path": "./tsconfig.node.json" } + { + "path": "./tsconfig.node.json" + } ] -} +} \ No newline at end of file diff --git a/vitest.config.ts b/vitest.config.ts index 7a6036c6..f97d8c1e 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -13,6 +13,7 @@ export default defineConfig({ globals: true, environment: "jsdom", setupFiles: ["./src/__tests__/setup.ts"], + include: ["src/__tests__/unit/**/*.test.ts", "src/__tests__/unit/**/*.spec.ts"], coverage: { provider: "v8", reporter: ["text", "json", "html", "lcov"], @@ -28,10 +29,12 @@ export default defineConfig({ "**/*.test.ts", "electron/", ], - statements: 70, - branches: 70, - functions: 70, - lines: 70, + thresholds: { + statements: 70, + branches: 70, + functions: 70, + lines: 70, + } }, }, });