mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-09-20 21:50:11 +08:00
refactor: 多维度代码审查修复(安全/清理/类型)
- src/App.vue: - fetchAppFromStore 的 category/pkgname 路径参数 encodeURIComponent 编码(防路径穿越) - img_urls JSON.parse 增加 try/catch,解析失败回退空数组(两处) - onUnmounted 统一移除 hashchange/resize/keydown 及全部 IPC 监听,修复内存泄漏 - 提取 createFallbackApp 消除 openDetail 重复回退构造 - 收集并统一停止等待 loading 的一次性 watcher,闭环生命周期清理 - src/global/typedefinition.ts: 移除 CategoryInfo/HomeLink 宽泛索引签名, CategoryInfo 改用显式 extra 字段 - electron/main/backend/install-manager.ts: 清理冗余 eslint-disable 并修正缩进 (remove-installed/check-installed 已通过 parseAppPayload 完成 pkgname 校验,无需改动)
This commit is contained in:
@@ -1269,7 +1269,6 @@ ipcMain.handle("show-apm-install-dialog", async (event) => {
|
||||
return { success: false, cancelled: true };
|
||||
});
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
ipcMain.handle(
|
||||
"uninstall-installed",
|
||||
async (
|
||||
@@ -1283,42 +1282,42 @@ ipcMain.handle(
|
||||
}
|
||||
const { pkgname, origin } = parsed;
|
||||
|
||||
const superUserCmd = await checkSuperUserCommand();
|
||||
const execCommand = superUserCmd || SHELL_CALLER_PATH;
|
||||
const execParams = superUserCmd ? [SHELL_CALLER_PATH] : [];
|
||||
const superUserCmd = await checkSuperUserCommand();
|
||||
const execCommand = superUserCmd || SHELL_CALLER_PATH;
|
||||
const execParams = superUserCmd ? [SHELL_CALLER_PATH] : [];
|
||||
|
||||
if (origin === "apm") {
|
||||
execParams.push("apm", "remove", "-y", pkgname);
|
||||
} else {
|
||||
execParams.push("aptss", "remove", "-y", pkgname);
|
||||
}
|
||||
if (origin === "apm") {
|
||||
execParams.push("apm", "remove", "-y", pkgname);
|
||||
} else {
|
||||
execParams.push("aptss", "remove", "-y", pkgname);
|
||||
}
|
||||
|
||||
const { code, stdout, stderr } = await runCommandCapture(
|
||||
execCommand,
|
||||
execParams,
|
||||
);
|
||||
const success = code === 0;
|
||||
const { code, stdout, stderr } = await runCommandCapture(
|
||||
execCommand,
|
||||
execParams,
|
||||
);
|
||||
const success = code === 0;
|
||||
|
||||
if (success) {
|
||||
logger.info(`卸载完成: ${pkgname}`);
|
||||
} else {
|
||||
logger.error(`卸载失败: ${pkgname} ${stderr || stdout}`);
|
||||
}
|
||||
if (success) {
|
||||
logger.info(`卸载完成: ${pkgname}`);
|
||||
} else {
|
||||
logger.error(`卸载失败: ${pkgname} ${stderr || stdout}`);
|
||||
}
|
||||
|
||||
return {
|
||||
success,
|
||||
message: success
|
||||
? "卸载完成"
|
||||
: stderr || stdout || `卸载失败,退出码 ${code}`,
|
||||
};
|
||||
});
|
||||
return {
|
||||
success,
|
||||
message: success
|
||||
? "卸载完成"
|
||||
: stderr || stdout || `卸载失败,退出码 ${code}`,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
interface LaunchAppPayload {
|
||||
pkgname: string;
|
||||
origin?: "spark" | "apm";
|
||||
}
|
||||
|
||||
|
||||
ipcMain.handle(
|
||||
"launch-app",
|
||||
async (
|
||||
|
||||
Reference in New Issue
Block a user