mirror of
https://github.com/YuJunZhiXue/dsh-purge.git
synced 2026-11-27 15:00:22 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6075a782bf | ||
|
|
a576e9b817 | ||
|
|
e360fa6b70 |
No files matched your search
@@ -1031,7 +1031,7 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
setState(d);
|
||||
if (d.channel) setChannel(d.channel);
|
||||
if (d.update && d.update.ok && !d.update.error) setUpdateInfo(d.update);
|
||||
if (d.boot_full_quit) setAskOfficialRestart(true);
|
||||
setAskOfficialRestart(Boolean(d.boot_full_quit));
|
||||
} else {
|
||||
setState({ ok: false, patches_total: 0, patches_applied: 0, patch_status: {}, shim_cmd: "n/a", shim_ps1: "n/a", shim_bin: "n/a", has_backup: false });
|
||||
setNotice({ kind: "error", text: tr("err.status", { error: (d && d.error) || "bad response" }) });
|
||||
@@ -1714,8 +1714,11 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
function keepListedVersion(item, ceiling) {
|
||||
const ver = String((item && (item.version || item.ref)) || "").replace(/^v/i, "");
|
||||
if (/^1\.1\.11-beta/i.test(ver)) return false;
|
||||
if (item && item.channel === "beta" && ceiling && !listedVersionNewer(ver, ceiling)) return false;
|
||||
return true;
|
||||
if (!item || item.channel !== "beta") return true;
|
||||
// 与 lib/update.hideListedVersion 一致:测试 tip / beta 分支始终可见(并行通道)。
|
||||
if (item.ref === "beta" || item.kind === "head" || item.latest) return true;
|
||||
if (!ceiling) return true;
|
||||
return listedVersionNewer(ver, ceiling);
|
||||
}
|
||||
|
||||
function preferListed(list, localVer) {
|
||||
@@ -2031,14 +2034,23 @@ window.__ModuleLoader__.load({ id: "dsh-purge", factory: (require) => {
|
||||
|
||||
function waitForRestart(setNotice, setBusy, t) {
|
||||
const started = Date.now();
|
||||
// 必须先看到旧进程掉线,再等新进程就绪;否则同进程立刻 200 会被当成「重启成功」又弹重启。
|
||||
let sawDown = false;
|
||||
const ping = () => {
|
||||
fetch("/dsh-purge/status", { cache: "no-store", credentials: "same-origin" })
|
||||
.then((r) => (r.ok ? r.json() : Promise.reject()))
|
||||
.then((d) => {
|
||||
if (!sawDown) {
|
||||
retry();
|
||||
return;
|
||||
}
|
||||
if (d && d.ok && d.ready !== false) reopenAfterRestart();
|
||||
else retry();
|
||||
})
|
||||
.catch(retry);
|
||||
.catch(() => {
|
||||
sawDown = true;
|
||||
retry();
|
||||
});
|
||||
};
|
||||
const retry = () => {
|
||||
if (Date.now() - started > 90000) {
|
||||
|
||||
@@ -1232,6 +1232,8 @@ function installWebServer(ctx, cfg) {
|
||||
pendingQuit = Boolean(swapped?.pending);
|
||||
}
|
||||
const leaveTray = renamed || pendingQuit;
|
||||
if (complete) reapply.markPatchesApplied();
|
||||
if (leaveTray) bootFullQuit = true;
|
||||
sendJson(response, 200, {
|
||||
ok: true,
|
||||
complete,
|
||||
@@ -1371,6 +1373,8 @@ function installWebServer(ctx, cfg) {
|
||||
try {
|
||||
const surface = hostctl.currentSurface();
|
||||
const planned = hostctl.scheduleRestart(request, ctx);
|
||||
// 用户已点重启:清掉粘性标记,避免同进程误刷新/再进面板又弹一次。
|
||||
bootFullQuit = false;
|
||||
sendJson(response, 200, {
|
||||
ok: true,
|
||||
surface,
|
||||
|
||||
+7
-1
@@ -64,6 +64,11 @@ function writeAppliedStamp(sha) {
|
||||
}, null, 2)}\n`, "utf8");
|
||||
}
|
||||
|
||||
/** 手动「应用」成功后也要打戳,否则重启后 settle 会以为补丁未对齐再要求重启。 */
|
||||
export function markPatchesApplied(sha) {
|
||||
writeAppliedStamp(sha == null ? installedRev() : sha);
|
||||
}
|
||||
|
||||
/**
|
||||
* 先把宿主文件从备份还原,再按当前这份插件的补丁重写。
|
||||
* 低版本带着自己的补丁列表,高版本带着自己的;回退到哪一版就打哪一版。
|
||||
@@ -103,6 +108,7 @@ export async function reapplyInstalled(options = {}) {
|
||||
}
|
||||
const summary = core.summarizeApplyReport(report);
|
||||
writeAppliedStamp(installedRev());
|
||||
const pending = Boolean(handoff?.asar && !renamed && options.scheduleSwap !== false);
|
||||
return {
|
||||
ok: true,
|
||||
version: pluginVersion(),
|
||||
@@ -110,7 +116,7 @@ export async function reapplyInstalled(options = {}) {
|
||||
applied: summary.applied || 0,
|
||||
failed: summary.failed.length,
|
||||
renamed,
|
||||
needsFullQuit: renamed || core.officialHostMustStayUp(),
|
||||
needsFullQuit: renamed || pending || core.officialHostMustStayUp(),
|
||||
cmdFlashOk: flash.ok === true,
|
||||
};
|
||||
}
|
||||
+42
-15
@@ -11,7 +11,7 @@ import { cliInvocation } from "./desktop.js";
|
||||
const REPO = "YuJunZhiXue/dsh-purge";
|
||||
const STABLE_REF = "master";
|
||||
const BETA_REF = "beta";
|
||||
export const TARBALL_URL = `https://github.com/${REPO}/archive/refs/heads/${STABLE_REF}.tar.gz`;
|
||||
export const TARBALL_URL = `https://codeload.github.com/${REPO}/tar.gz/refs/heads/${STABLE_REF}`;
|
||||
const PLUGIN_ROOT = path.resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
|
||||
const CHANNELS = {
|
||||
stable: { id: "stable", ref: STABLE_REF, label: "正式版" },
|
||||
@@ -165,18 +165,19 @@ function pushHistory(entry) {
|
||||
fs.writeFileSync(historyPath(), `${JSON.stringify(next, null, 2)}\n`, "utf8");
|
||||
}
|
||||
|
||||
/** 直连 codeload,避免 github.com/archive → 302 在 Electron/部分 Node 下变成 http 302 / fetch failed。 */
|
||||
function archiveZipUrl(ref) {
|
||||
const value = String(ref || STABLE_REF);
|
||||
if (/^[0-9a-f]{40}$/i.test(value)) return `https://github.com/${REPO}/archive/${value}.zip`;
|
||||
if (/^v?\d/.test(value)) return `https://github.com/${REPO}/archive/refs/tags/${encodeURIComponent(value)}.zip`;
|
||||
return `https://github.com/${REPO}/archive/refs/heads/${encodeURIComponent(value)}.zip`;
|
||||
if (/^[0-9a-f]{40}$/i.test(value)) return `https://codeload.github.com/${REPO}/zip/${value}`;
|
||||
if (/^v?\d/.test(value)) return `https://codeload.github.com/${REPO}/zip/refs/tags/${encodeURIComponent(value)}`;
|
||||
return `https://codeload.github.com/${REPO}/zip/refs/heads/${encodeURIComponent(value)}`;
|
||||
}
|
||||
|
||||
function archiveTarballUrl(ref) {
|
||||
const value = String(ref || STABLE_REF);
|
||||
if (/^[0-9a-f]{40}$/i.test(value)) return `https://github.com/${REPO}/archive/${value}.tar.gz`;
|
||||
if (/^v?\d/.test(value)) return `https://github.com/${REPO}/archive/refs/tags/${encodeURIComponent(value)}.tar.gz`;
|
||||
return `https://github.com/${REPO}/archive/refs/heads/${encodeURIComponent(value)}.tar.gz`;
|
||||
if (/^[0-9a-f]{40}$/i.test(value)) return `https://codeload.github.com/${REPO}/tar.gz/${value}`;
|
||||
if (/^v?\d/.test(value)) return `https://codeload.github.com/${REPO}/tar.gz/refs/tags/${encodeURIComponent(value)}`;
|
||||
return `https://codeload.github.com/${REPO}/tar.gz/refs/heads/${encodeURIComponent(value)}`;
|
||||
}
|
||||
|
||||
function readStamp() {
|
||||
@@ -420,14 +421,25 @@ async function fetchRes(url, ms = 20000, headers = {}) {
|
||||
}
|
||||
}, ms);
|
||||
try {
|
||||
const res = await fetch(url, {
|
||||
headers: { "user-agent": "dsh-purge-update", accept: "*/*", ...headers },
|
||||
redirect: "follow",
|
||||
cache: "no-store",
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
if (!res.ok) throw new Error(`http ${res.status}`);
|
||||
return res;
|
||||
let current = String(url || "");
|
||||
for (let hop = 0; hop < 6; hop += 1) {
|
||||
const res = await fetch(current, {
|
||||
headers: { "user-agent": "dsh-purge-update", accept: "*/*", ...headers },
|
||||
// 手动跟跳转:部分宿主对 github.com → codeload 跨域 302 不会自动 follow,会直接抛 http 302。
|
||||
redirect: "manual",
|
||||
cache: "no-store",
|
||||
signal: ctrl.signal,
|
||||
});
|
||||
if ([301, 302, 303, 307, 308].includes(res.status)) {
|
||||
const loc = res.headers.get("location");
|
||||
if (!loc) throw new Error(`http ${res.status}`);
|
||||
current = new URL(loc, current).href;
|
||||
continue;
|
||||
}
|
||||
if (!res.ok) throw new Error(`http ${res.status}`);
|
||||
return res;
|
||||
}
|
||||
throw new Error("http redirect loop");
|
||||
} catch (e) {
|
||||
if (isAbortError(e)) throw new Error("GitHub 超时");
|
||||
throw e;
|
||||
@@ -631,6 +643,21 @@ async function listRemoteVersions() {
|
||||
kind: "head",
|
||||
latest: true,
|
||||
});
|
||||
} else {
|
||||
// API/atom 拿不到 tip 时,仍用 raw/jsDelivr 探一下 beta 分支,避免测试通道整栏空白。
|
||||
const version = await remotePackageVersion("", BETA_REF).catch(() => "");
|
||||
if (version) {
|
||||
add({
|
||||
id: BETA_REF,
|
||||
ref: BETA_REF,
|
||||
sha: "",
|
||||
version,
|
||||
channel: "beta",
|
||||
label: `${versionLabel(version, "beta")} · 最新`,
|
||||
kind: "head",
|
||||
latest: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
for (const tag of tags) {
|
||||
if (!withdrawnVersion(tag)) add(tag);
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "dsh-purge",
|
||||
"version": "1.1.26",
|
||||
"version": "1.1.28",
|
||||
"description": "DeepSeek Harness 网络安全红队工具:本机官方 Harness 受控评测与清洗,不同模型可换不同提示词;默认提示词面向国模「小码酱」。求 Star ⭐",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
|
||||
@@ -1,3 +1,29 @@
|
||||
# 1.1.28
|
||||
|
||||
## 中文
|
||||
|
||||
- **修复更新失败 `http 302`**:下载改为直连 `codeload.github.com`,并手动跟随跳转,避免 Electron/部分 Node 对 github.com → codeload 的 302 处理失败。
|
||||
- **修复测试版列表空白**:前端 `keepListedVersion` 与后端一致,正式版已发布时仍保留 beta tip / `beta` 分支;tip SHA 拉不到时回退 raw/jsDelivr 探测。
|
||||
|
||||
## English
|
||||
|
||||
- **Fix update failure `http 302`**: download via `codeload.github.com` and follow redirects manually so Electron/some Node builds no longer stall on github.com → codeload 302.
|
||||
- **Fix empty beta list**: client `keepListedVersion` matches the server — keep the beta tip / `beta` branch after stable ships; fall back to raw/jsDelivr when tip SHA cannot be fetched.
|
||||
|
||||
# 1.1.27
|
||||
|
||||
## 中文
|
||||
|
||||
- **修复应用重启后进规则设定仍弹「需要重启」**:手动「应用」成功后写入 `applied` 戳,重启后 settle 不再误判补丁未对齐。
|
||||
- 点「重启」清掉 `boot_full_quit` 粘性标记;status 按布尔值同步弹窗。
|
||||
- web `waitForRestart` 必须先看到旧进程掉线再判定成功,避免同进程误刷新又弹窗。
|
||||
|
||||
## English
|
||||
|
||||
- **Fix restart prompt still showing after Apply + successful restart**: write the `applied` stamp on successful manual Apply so settle does not think patches are out of date.
|
||||
- Clear sticky `boot_full_quit` when Restart is clicked; status syncs the modal from the boolean.
|
||||
- Web `waitForRestart` requires the old process to go down before treating restart as success, avoiding same-process false refresh.
|
||||
|
||||
# 1.1.26
|
||||
|
||||
## 中文
|
||||
|
||||
@@ -11,10 +11,10 @@ assert.equal(safeUpdateRef("origin/master"), "");
|
||||
assert.equal(safeUpdateRef("../evil"), "");
|
||||
assert.equal(safeUpdateRef("master;rm"), "");
|
||||
|
||||
const masterTar = "https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.tar.gz";
|
||||
const masterTar = "https://codeload.github.com/YuJunZhiXue/dsh-purge/tar.gz/refs/heads/master";
|
||||
assert.equal(pluginAddSpec("git+https://github.com/yujunzhixue/dsh-purge.git", "master"), masterTar);
|
||||
assert.equal(pluginAddSpec("github:yujunzhixue/dsh-purge", "master"), masterTar);
|
||||
assert.equal(pluginAddSpec("https://github.com/YuJunZhiXue/dsh-purge/archive/refs/heads/master.zip", "master"), masterTar);
|
||||
assert.equal(pluginAddSpec("https://codeload.github.com/YuJunZhiXue/dsh-purge/zip/refs/heads/master", "master"), masterTar);
|
||||
assert.equal(pluginAddSpec("dsh-purge", "master"), "");
|
||||
|
||||
const head = "9397203733562d6baeec9e38ac519698c619edcb";
|
||||
|
||||
Reference in new issue
Block a user