mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 05:50:22 +08:00
1.1.79: 修复 bug,修复稳定性(#165 #166 #167)
This commit is contained in:
1 parent
add692e491
commit
82da559cff
17 files changed
+872
-185
No files matched your search
@@ -31,6 +31,9 @@ export function pathLooksDesktop(p) {
|
||||
n.includes("/dsh desktop.app/") ||
|
||||
n.includes("dsh-desktop") ||
|
||||
n.includes("dsh-plugin-desktop") ||
|
||||
n.includes("/deepseek bot/") ||
|
||||
n.includes("/deepseek-bot/") ||
|
||||
n.includes("/ds-bot/") ||
|
||||
n.includes("/deepseek harness.app/") ||
|
||||
(harnessDir && (n.includes("/resources/") || n.includes("/contents/resources/") || n.endsWith("/resources"))) ||
|
||||
/\/dsh desktop\.exe$/i.test(n) ||
|
||||
@@ -56,8 +59,25 @@ function resourcesLookLikeDesktopInstall(resourcesPath) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** 社区 Electron(DS Bot / DeepSeek Bot):profile 常是 ds-bot,DSH_SURFACE 还可能被写成 web。 */
|
||||
export function isCommunityElectronHost(input = {}) {
|
||||
const env = input.env ?? process.env;
|
||||
const profile = norm(env.DSH_PROFILE);
|
||||
if (profile === "ds-bot" || profile === "dsbot" || profile === "deepseek-bot") return true;
|
||||
const execPath = input.execPath ?? process.execPath;
|
||||
const name = exeName(execPath);
|
||||
if (/^deepseek[\s._-]*bot(\.exe)?$/.test(name) || /^ds[\s._-]*bot(\.exe)?$/.test(name)) return true;
|
||||
const p = slash(execPath);
|
||||
if (p.includes("/deepseek bot") || p.includes("/deepseek-bot") || p.includes("/ds-bot/") || p.endsWith("/ds-bot")) return true;
|
||||
const resourcesPath = input.resourcesPath ?? process.resourcesPath;
|
||||
const electron = (input.versions ?? process.versions)?.electron;
|
||||
if (electron && resourcesLookLikeDesktopInstall(resourcesPath)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
export function isDesktopSurface(input = {}) {
|
||||
const env = input.env ?? process.env;
|
||||
if (isCommunityElectronHost(input)) return true;
|
||||
const forced = norm(env.DSH_SURFACE);
|
||||
if (forced === "desktop") return true;
|
||||
if (forced && SURFACES.includes(forced)) return false;
|
||||
@@ -95,6 +115,7 @@ function forcedSurface(env) {
|
||||
|
||||
export function detectSurface(input = {}) {
|
||||
const env = input.env ?? process.env;
|
||||
if (isCommunityElectronHost(input)) return "desktop";
|
||||
const forced = forcedSurface(env);
|
||||
if (forced) return forced;
|
||||
if (isDesktopSurface(input)) return "desktop";
|
||||
|
||||
Reference in new issue
Block a user