ework-web 0.10.72 → 0.10.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-web",
3
- "version": "0.10.72",
3
+ "version": "0.10.74",
4
4
  "type": "module",
5
5
  "description": "ework-web — standalone multi-project issue tracker. Local SQLite-backed, no external API dependency. Bun + TypeScript + SSR HTML.",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -589,6 +589,21 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
589
589
  // /api/* routes since those would 404 on /api/v1/* paths. The shim reuses
590
590
  // the existing ctx.user (cookie or PAT auth already resolved above).
591
591
  if (url.pathname.startsWith("/api/v1/")) {
592
+ if (url.pathname === "/api/v1/dispatch-state" && req.method === "GET") {
593
+ const owner = url.searchParams.get("owner") ?? "";
594
+ const repo = url.searchParams.get("repo") ?? "";
595
+ const number = url.searchParams.get("number") ?? "";
596
+ if (!owner || !repo || !number) return json({ error: "owner, repo, number required" }, 400);
597
+ const project = await getProject(owner, repo);
598
+ if (!project) return json({ dispatchOff: false, aiStatus: "" });
599
+ const issue = await getIssueWithMeta(project.id, Number(number));
600
+ const cfgKv = await getConfigAll();
601
+ const globalOff = cfgKv["dispatchEnabled"] === "false";
602
+ const projectOff = cfgKv[`dispatchOff:${owner}/${repo}`] === "1";
603
+ const aiStatus = issue?.ai_status ?? "";
604
+ const issueOff = aiStatus === "dispatch_off" || aiStatus === "halted";
605
+ return json({ dispatchOff: globalOff || projectOff || issueOff, aiStatus });
606
+ }
592
607
  const evStatus = url.pathname.match(/^\/api\/v1\/repos\/([^/]+)\/([^/]+)\/issues\/(\d+)\/status$/);
593
608
  if (evStatus && req.method === "POST") {
594
609
  const [, owner, repo, numStr] = evStatus;
@@ -1351,22 +1366,6 @@ async function handle(req: Request, url: URL, ip: string, ctx: { authed: boolean
1351
1366
  }
1352
1367
  }
1353
1368
 
1354
- if (url.pathname === "/api/v1/dispatch-state" && req.method === "GET") {
1355
- const owner = url.searchParams.get("owner") ?? "";
1356
- const repo = url.searchParams.get("repo") ?? "";
1357
- const number = url.searchParams.get("number") ?? "";
1358
- if (!owner || !repo || !number) return json({ error: "owner, repo, number required" }, 400);
1359
- const project = await getProject(owner, repo);
1360
- if (!project) return json({ dispatchOff: false, aiStatus: "" });
1361
- const issue = await getIssueWithMeta(project.id, Number(number));
1362
- const cfgKv = await getConfigAll();
1363
- const globalOff = cfgKv["dispatchEnabled"] === "false";
1364
- const projectOff = cfgKv[`dispatchOff:${owner}/${repo}`] === "1";
1365
- const aiStatus = issue?.ai_status ?? "";
1366
- const issueOff = aiStatus === "dispatch_off" || aiStatus === "halted";
1367
- return json({ dispatchOff: globalOff || projectOff || issueOff, aiStatus });
1368
- }
1369
-
1370
1369
  if (url.pathname === "/api/router/strategy") {
1371
1370
  if (!ctx.user || ctx.user.is_admin !== 1) return json({ error: "admin required" }, 403);
1372
1371
  const routerUrl = cfg.daemonWebhookUrl.replace(/\/$/, "");
@@ -36,12 +36,9 @@
36
36
  });
37
37
  });
38
38
 
39
- document.addEventListener("click", function (e) {
40
- var saveBtn = e.target.closest("#issueModelSave");
41
- if (!saveBtn) return;
42
- e.preventDefault();
39
+ function saveModel(saveBtn) {
43
40
  var sel = document.getElementById("issueModelSelect");
44
- if (!sel) return;
41
+ if (!sel || !saveBtn) return;
45
42
  var m = sel.value;
46
43
  saveBtn.disabled = true;
47
44
  var path = location.pathname.split("/").slice(0, 5).join("/");
@@ -60,5 +57,16 @@
60
57
  saveBtn.disabled = false;
61
58
  alert("网络错误: " + err);
62
59
  });
60
+ }
61
+
62
+ document.addEventListener("click", function (e) {
63
+ var saveBtn = e.target.closest("#issueModelSave");
64
+ if (!saveBtn) return;
65
+ e.preventDefault();
66
+ saveModel(saveBtn);
67
+ });
68
+
69
+ document.addEventListener("change", function (e) {
70
+ if (e.target && e.target.id === "issueModelSelect") saveModel(document.getElementById("issueModelSave"));
63
71
  });
64
72
  })();