fix: 支持 DSH Desktop 解包依赖路径探测

This commit is contained in:
wangqiupei committed 2026-08-25 09:43:23 +08:00
1 parent 852f9d9e39
commit 4d47ce69dc
4 files changed
+36 -6

No files matched your search

+25
View File
@@ -61,6 +61,28 @@ export function findShimDir() {
return null;
}
/**
* 定位 DSH Desktop 解包后的 @deepseek-ai 依赖目录。
* Electron 将 app.asar 中标记为 unpacked 的文件放在相邻目录,补丁应写入该真实路径。
*/
function findDesktopAiBase() {
const candidates = [];
if (typeof process.resourcesPath === "string" && process.resourcesPath.trim()) {
candidates.push(path.join(process.resourcesPath, "app.asar.unpacked", "node_modules", "@deepseek-ai"));
}
// ELECTRON_RUN_AS_NODE 模式没有稳定的 resourcesPath,按可执行文件位置回推 Contents/Resources。
const contentsDir = path.dirname(path.dirname(process.execPath));
candidates.push(path.join(contentsDir, "Resources", "app.asar.unpacked", "node_modules", "@deepseek-ai"));
for (const candidate of candidates) {
if (fs.existsSync(path.join(candidate, "dsh-agent-instructions", "lib"))) {
return path.normalize(candidate);
}
}
return null;
}
export function findAiBase() {
const env = process.env.DSH_BASE;
if (env && env.trim()) {
@@ -68,6 +90,9 @@ export function findAiBase() {
if (fs.existsSync(path.join(p, "dsh-agent-instructions", "lib"))) return p;
}
const desktopBase = findDesktopAiBase();
if (desktopBase) return desktopBase;
const rel = path.join("node_modules", "@deepseek-ai", "dsh", "node_modules", "@deepseek-ai");
const prefix = findNpmPrefix();