mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-28 13:30:22 +08:00
release: 1.1.70
Hub/残装不再空等 pluginPackages;清洗页合并升级链展示,Apply 仍全打。合并 #97/#98/#99。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1863a4b1e4
commit
a5dcbb02d8
17 files changed
+774
-471
No files matched your search
+25
-15
@@ -542,25 +542,30 @@ export function clearDesktopLocateCache() {
|
||||
cachedRegistryDirs = undefined;
|
||||
}
|
||||
|
||||
function extraDiscoveredInstallDirs(env = process.env) {
|
||||
return uniquePaths([
|
||||
function extraDiscoveredInstallDirs(env = process.env, input = {}) {
|
||||
const cheap = [
|
||||
...homeSiblingInstalls(env),
|
||||
...portableInstallGuesses(env),
|
||||
];
|
||||
if (input.discover !== true) return uniquePaths(cheap);
|
||||
return uniquePaths([
|
||||
...cheap,
|
||||
...runningOfficialExecutables().map((exe) => path.dirname(exe)),
|
||||
...shortcutOfficialExecutables().map((exe) => path.dirname(exe)),
|
||||
]);
|
||||
}
|
||||
|
||||
/** NSIS / 商店默认位置;不是全盘扫描。自定义目录还看进程、快捷方式、各盘根下一层常见名。 */
|
||||
export function commonDesktopInstallDirs(env = process.env) {
|
||||
/** NSIS / 商店默认位置;不是全盘扫描。discover 才查注册表 / 进程 / 快捷方式。 */
|
||||
export function commonDesktopInstallDirs(env = process.env, input = {}) {
|
||||
const discover = input.discover === true;
|
||||
const home = os.homedir();
|
||||
const local = env.LOCALAPPDATA || path.join(home, "AppData", "Local");
|
||||
const pf = env.ProgramFiles || "";
|
||||
const pf86 = env["ProgramFiles(x86)"] || "";
|
||||
return uniquePaths([
|
||||
...extraInstallsFromEnv(env).filter(trustedInstallDir),
|
||||
...registryInstallDirs(),
|
||||
...extraDiscoveredInstallDirs(env),
|
||||
...(discover ? registryInstallDirs() : []),
|
||||
...extraDiscoveredInstallDirs(env, { discover }),
|
||||
path.join(local, "Programs", "DeepSeek Harness"),
|
||||
path.join(local, "Programs", "DSH Desktop"),
|
||||
path.join(local, "DeepSeek Harness"),
|
||||
@@ -646,6 +651,7 @@ export function findDesktopAppExecutable(input = {}) {
|
||||
const resourcesPath = input.resourcesPath ?? process.resourcesPath;
|
||||
const argv = input.argv ?? process.argv;
|
||||
const env = input.env ?? process.env;
|
||||
const discover = input.discover === true;
|
||||
|
||||
if (isDesktopExecutable(execPath) && isFile(execPath)) return path.normalize(execPath);
|
||||
|
||||
@@ -670,15 +676,16 @@ export function findDesktopAppExecutable(input = {}) {
|
||||
if (hit) return hit;
|
||||
}
|
||||
|
||||
const running = runningOfficialExecutables();
|
||||
if (running[0]) return running[0];
|
||||
|
||||
const shortcuts = shortcutOfficialExecutables();
|
||||
if (shortcuts[0]) return shortcuts[0];
|
||||
if (discover) {
|
||||
const running = runningOfficialExecutables();
|
||||
if (running[0]) return running[0];
|
||||
const shortcuts = shortcutOfficialExecutables();
|
||||
if (shortcuts[0]) return shortcuts[0];
|
||||
}
|
||||
|
||||
const guessed = firstExistingExe([
|
||||
...extraInstallsFromEnv(env),
|
||||
...commonDesktopInstallDirs(env),
|
||||
...commonDesktopInstallDirs(env, { discover }),
|
||||
]);
|
||||
return guessed || "";
|
||||
}
|
||||
@@ -702,6 +709,7 @@ export function listDesktopPackageRoots(input = {}) {
|
||||
const resourcesPath = input.resourcesPath ?? process.resourcesPath;
|
||||
const argv = input.argv ?? process.argv;
|
||||
const env = input.env ?? process.env;
|
||||
const discover = input.discover === true;
|
||||
const cands = [];
|
||||
|
||||
if (resourcesPath) {
|
||||
@@ -731,8 +739,10 @@ export function listDesktopPackageRoots(input = {}) {
|
||||
const localHits = uniquePaths(cands).filter(isAiBase);
|
||||
// 已经在某个桌面 exe 里时,只改这一份。旁边装了另一种客户端也不能被带上。
|
||||
if (isDesktopExecutable(execPath)) return localHits;
|
||||
// 启动自愈:exe / 环境 / 常见目录已经够用。注册表和快捷方式留给点「应用」。
|
||||
if (!discover && localHits.length) return localHits;
|
||||
|
||||
for (const install of commonDesktopInstallDirs(env)) {
|
||||
for (const install of commonDesktopInstallDirs(env, { discover })) {
|
||||
cands.push(...packageRootsFromInstall(install));
|
||||
}
|
||||
|
||||
@@ -938,7 +948,7 @@ const ASAR_RENAME_WHEN_IDLE_PS1 = [
|
||||
" $restartFlag = Join-Path $env:TEMP 'dsh-purge-official-restarting'",
|
||||
" if (Test-Path -LiteralPath $restartFlag) {",
|
||||
" $flagAge = (Get-Date) - (Get-Item -LiteralPath $restartFlag).LastWriteTime",
|
||||
" if ($flagAge.TotalSeconds -ge 0 -and $flagAge.TotalSeconds -lt 180) { exit 0 }",
|
||||
" if ($flagAge.TotalSeconds -ge 0 -and $flagAge.TotalSeconds -lt 45) { exit 0 }",
|
||||
" Remove-Item -LiteralPath $restartFlag -Force -ErrorAction SilentlyContinue",
|
||||
" }",
|
||||
" $holding = @(Get-Process -ErrorAction SilentlyContinue | Where-Object { try { $_.Path -eq $ExePath } catch { $false } })",
|
||||
@@ -1341,7 +1351,7 @@ function unpackedHostIsClean(exe) {
|
||||
}
|
||||
|
||||
const OFFICIAL_RESTART_FLAG = "dsh-purge-official-restarting";
|
||||
const OFFICIAL_RESTART_WINDOW_MS = 180000;
|
||||
const OFFICIAL_RESTART_WINDOW_MS = 45000;
|
||||
|
||||
/**
|
||||
* Windows 官方换包走哪条。
|
||||
|
||||
Reference in new issue
Block a user