dsh-dock 0.21.1 → 0.23.0
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/README.md +28 -31
- package/client.js +1511 -751
- package/features/balance/view.js +6 -1
- package/features/mcpconfig/host.js +402 -0
- package/features/mcpconfig/view.js +658 -0
- package/features/modelconfig/host.js +1 -1
- package/features/modelconfig/view.js +2 -2
- package/features/notify/host.js +8 -3
- package/features/notify/view.jsx +40 -12
- package/features/providerconfig/host.js +1 -1
- package/features/providerconfig/view.js +4 -4
- package/features/tokenlog/host.js +207 -10
- package/features/tokenlog/view.jsx +101 -20
- package/index.js +5 -3
- package/package.json +3 -3
- package/src/client.jsx +11 -7
- package/src/host-core.js +3 -0
- package/src/shared.js +5 -0
- package/src/task-track.js +64 -0
- package/features/heartbeat/view.js +0 -35
- package/features/theme/view.js +0 -61
package/client.js
CHANGED
|
@@ -2126,7 +2126,7 @@ __export(client_exports, {
|
|
|
2126
2126
|
inject: () => inject
|
|
2127
2127
|
});
|
|
2128
2128
|
module.exports = __toCommonJS(client_exports);
|
|
2129
|
-
var
|
|
2129
|
+
var import_react22 = __toESM(require("react"), 1);
|
|
2130
2130
|
|
|
2131
2131
|
// src/shared.js
|
|
2132
2132
|
var import_react = __toESM(require("react"), 1);
|
|
@@ -2319,6 +2319,7 @@ function taskActivityAt(task) {
|
|
|
2319
2319
|
}
|
|
2320
2320
|
function taskBusy(task, now, capMs) {
|
|
2321
2321
|
if (!task) return false;
|
|
2322
|
+
if (task.ptcProgram === true) return true;
|
|
2322
2323
|
const at = typeof now === "number" ? now : Date.now();
|
|
2323
2324
|
const cap = typeof capMs === "number" && capMs > 0 ? capMs : TASK_BUSY_MS;
|
|
2324
2325
|
if (task.compacting === true) {
|
|
@@ -2418,6 +2419,10 @@ function hourOf(ts) {
|
|
|
2418
2419
|
var EXPORT_COLUMNS = [
|
|
2419
2420
|
["\u65F6\u95F4", (r) => fmtTime(r.time)],
|
|
2420
2421
|
["\u4F1A\u8BDDID", (r) => r.sessionId || ""],
|
|
2422
|
+
["\u76F4\u63A5\u7236\u4F1A\u8BDDID", (r) => r.parentSessionId || ""],
|
|
2423
|
+
["\u6839\u4F1A\u8BDDID", (r) => r.rootSessionId || r.sessionId || ""],
|
|
2424
|
+
["\u4F1A\u8BDD\u5C42\u7EA7", (r) => String(r.sessionDepth || 0)],
|
|
2425
|
+
["\u4F1A\u8BDD\u7C7B\u578B", (r) => r.isSubtask ? "\u5B50\u4EFB\u52A1" : "\u4E3B\u4F1A\u8BDD"],
|
|
2421
2426
|
["\u63D0\u4F9B\u5546", (r) => r.provider || "\u2014"],
|
|
2422
2427
|
["\u6A21\u578B", (r) => r.model || "\u2014"],
|
|
2423
2428
|
["\u8F93\u5165(\u547D\u4E2D)", (r) => fmtNum(r.cacheReadTokens)],
|
|
@@ -2461,7 +2466,7 @@ function buildExportCsv(rows, rate) {
|
|
|
2461
2466
|
return lines.join("\r\n");
|
|
2462
2467
|
}
|
|
2463
2468
|
var STORE_KEY = "dsh-dock/tokenlog/filters/v1";
|
|
2464
|
-
var FILTER_FIELDS = ["fromStr", "toStr", "provider", "model", "status", "effort", "sessionId", "dim"];
|
|
2469
|
+
var FILTER_FIELDS = ["fromStr", "toStr", "provider", "model", "status", "effort", "sessionId", "sessionScope", "dim"];
|
|
2465
2470
|
function loadSavedFilters() {
|
|
2466
2471
|
try {
|
|
2467
2472
|
if (typeof localStorage === "undefined") return null;
|
|
@@ -2488,6 +2493,9 @@ function shortId(sid) {
|
|
|
2488
2493
|
if (sid.length <= 16) return sid;
|
|
2489
2494
|
return sid.slice(0, 8) + "\u2026" + sid.slice(-6);
|
|
2490
2495
|
}
|
|
2496
|
+
function sessionType(r) {
|
|
2497
|
+
return r && r.isSubtask ? "\u5B50\u4EFB\u52A1" : "\u4E3B\u4F1A\u8BDD";
|
|
2498
|
+
}
|
|
2491
2499
|
function statusInfo(r) {
|
|
2492
2500
|
if (r.status === "completed") return { code: 200, label: "200", cls: "ok", title: "\u6210\u529F" };
|
|
2493
2501
|
if (r.status === "max-tokens") return { code: 200, label: "200", cls: "warn", title: "\u5B8C\u6210(\u8FBE\u5230\u8F93\u51FA\u4E0A\u9650)" };
|
|
@@ -2723,6 +2731,9 @@ var css = `
|
|
|
2723
2731
|
.dtok-empty{text-align:center;color:var(--dsw-alias-label-secondary);padding:32px 0;font-size:13px;}
|
|
2724
2732
|
.dtok-sid{color:var(--dk-accent);cursor:pointer;text-decoration:underline dotted;}
|
|
2725
2733
|
.dtok-sid:hover{filter:brightness(1.25);}
|
|
2734
|
+
.dtok-scope-note{font-size:12px;color:var(--dsw-alias-label-secondary);padding:7px 10px;border-left:3px solid var(--dk-accent);background:var(--dsw-alias-bg-layer-1);border-radius:4px;line-height:1.5;}
|
|
2735
|
+
.dtok-session-kind{display:inline-block;margin-left:5px;padding:1px 5px;border-radius:4px;font-size:10px;color:var(--dk-accent);background:rgb(96 165 250 / .12);vertical-align:middle;}
|
|
2736
|
+
.dtok-session-tree{font-family:ui-monospace,monospace;}
|
|
2726
2737
|
.dtok-code{font-weight:700;font-family:ui-monospace,monospace;}
|
|
2727
2738
|
.dtok-code.ok{color:var(--dsw-alias-state-success-primary,#4ade80);}
|
|
2728
2739
|
.dtok-code.warn{color:var(--dk-warn);}
|
|
@@ -2863,6 +2874,10 @@ function Detail({ rec, onClose, rate }) {
|
|
|
2863
2874
|
const rateCny = Number(rate) > 0 ? Number(rate) : 7.2;
|
|
2864
2875
|
const rows = [
|
|
2865
2876
|
["\u4F1A\u8BDD ID", rec.sessionId],
|
|
2877
|
+
["\u4F1A\u8BDD\u7C7B\u578B", sessionType(rec)],
|
|
2878
|
+
["\u76F4\u63A5\u7236\u4F1A\u8BDD ID", rec.parentSessionId || "\u2014"],
|
|
2879
|
+
["\u6839\u4F1A\u8BDD ID", rec.rootSessionId || rec.sessionId],
|
|
2880
|
+
["\u4F1A\u8BDD\u5C42\u7EA7", String(rec.sessionDepth || 0)],
|
|
2866
2881
|
["\u65F6\u95F4", fmtTime(rec.time)],
|
|
2867
2882
|
["\u63D0\u4F9B\u5546", rec.provider],
|
|
2868
2883
|
["\u6A21\u578B", rec.model],
|
|
@@ -3310,6 +3325,8 @@ function TokenLogView(props) {
|
|
|
3310
3325
|
const [status, setStatus] = (0, import_react2.useState)(() => savedFilters && savedFilters.status || "");
|
|
3311
3326
|
const [effort, setEffort] = (0, import_react2.useState)(() => savedFilters && savedFilters.effort || "");
|
|
3312
3327
|
const [sessionId, setSessionId] = (0, import_react2.useState)(() => navSession || savedFilters && savedFilters.sessionId || "");
|
|
3328
|
+
const [sessionScope, setSessionScope] = (0, import_react2.useState)(() => savedFilters && savedFilters.sessionScope || "tree");
|
|
3329
|
+
const scopeTouchedRef = (0, import_react2.useRef)(!!(savedFilters && savedFilters.sessionScope));
|
|
3313
3330
|
const [dim, setDim] = (0, import_react2.useState)(() => savedFilters && savedFilters.dim || "");
|
|
3314
3331
|
const [sortKey, setSortKey] = (0, import_react2.useState)("time");
|
|
3315
3332
|
const [sortDir, setSortDir] = (0, import_react2.useState)("desc");
|
|
@@ -3335,8 +3352,8 @@ function TokenLogView(props) {
|
|
|
3335
3352
|
}, [fetchedAt]);
|
|
3336
3353
|
const pageSize = 100;
|
|
3337
3354
|
(0, import_react2.useEffect)(() => {
|
|
3338
|
-
saveFilters({ fromStr, toStr, provider, model, status, effort, sessionId, dim });
|
|
3339
|
-
}, [fromStr, toStr, provider, model, status, effort, sessionId, dim]);
|
|
3355
|
+
saveFilters({ fromStr, toStr, provider, model, status, effort, sessionId, sessionScope, dim });
|
|
3356
|
+
}, [fromStr, toStr, provider, model, status, effort, sessionId, sessionScope, dim]);
|
|
3340
3357
|
(0, import_react2.useEffect)(() => {
|
|
3341
3358
|
let cancel = false;
|
|
3342
3359
|
setLoading(true);
|
|
@@ -3350,12 +3367,14 @@ function TokenLogView(props) {
|
|
|
3350
3367
|
if (savedFilters.status) q.status = savedFilters.status;
|
|
3351
3368
|
if (savedFilters.effort) q.effort = savedFilters.effort;
|
|
3352
3369
|
if (savedFilters.sessionId) q.sessionId = savedFilters.sessionId;
|
|
3370
|
+
if (savedFilters.sessionScope) q.sessionScope = savedFilters.sessionScope;
|
|
3353
3371
|
if (savedFilters.dim) q.dim = savedFilters.dim;
|
|
3354
3372
|
}
|
|
3355
3373
|
if (navSession) q.sessionId = navSession;
|
|
3356
3374
|
rpcCall("scan", {}).then(() => cancel ? null : rpcCall("query", q)).then((d) => {
|
|
3357
3375
|
if (cancel) return;
|
|
3358
3376
|
setData(d);
|
|
3377
|
+
if (!scopeTouchedRef.current && d && (d.defaultSessionScope === "tree" || d.defaultSessionScope === "session")) setSessionScope(d.defaultSessionScope);
|
|
3359
3378
|
}).catch((e) => {
|
|
3360
3379
|
if (!cancel) setErr(String(e && e.message || e));
|
|
3361
3380
|
}).finally(() => {
|
|
@@ -3374,10 +3393,11 @@ function TokenLogView(props) {
|
|
|
3374
3393
|
if (status) q.status = status;
|
|
3375
3394
|
if (effort) q.effort = effort;
|
|
3376
3395
|
if (sessionId) q.sessionId = sessionId;
|
|
3396
|
+
if (sessionId) q.sessionScope = sessionScope;
|
|
3377
3397
|
const dimNow = dimOverride !== void 0 ? dimOverride : dim;
|
|
3378
3398
|
if (withDim && dimNow) q.dim = dimNow;
|
|
3379
3399
|
return q;
|
|
3380
|
-
}, [fromStr, toStr, provider, model, status, effort, sessionId, dim]);
|
|
3400
|
+
}, [fromStr, toStr, provider, model, status, effort, sessionId, sessionScope, dim]);
|
|
3381
3401
|
const runQuery = (0, import_react2.useCallback)((dimOverride) => {
|
|
3382
3402
|
setLoading(true);
|
|
3383
3403
|
setErr("");
|
|
@@ -3387,17 +3407,19 @@ function TokenLogView(props) {
|
|
|
3387
3407
|
}).catch((e) => setErr(String(e && e.message || e))).finally(() => setLoading(false));
|
|
3388
3408
|
}, [buildQ]);
|
|
3389
3409
|
const navAppliedRef = (0, import_react2.useRef)(navAt);
|
|
3410
|
+
const lastNavSessionRef = (0, import_react2.useRef)(navSession);
|
|
3390
3411
|
(0, import_react2.useEffect)(() => {
|
|
3391
|
-
if (!navSession || navAppliedRef.current === navAt) return;
|
|
3412
|
+
if (!navSession || navAppliedRef.current === navAt && lastNavSessionRef.current === navSession) return;
|
|
3392
3413
|
navAppliedRef.current = navAt;
|
|
3414
|
+
lastNavSessionRef.current = navSession;
|
|
3393
3415
|
setSessionId(navSession);
|
|
3394
3416
|
setLoading(true);
|
|
3395
3417
|
setErr("");
|
|
3396
|
-
rpcCall("query", Object.assign({}, buildQ(true), { sessionId: navSession })).then((d) => {
|
|
3418
|
+
rpcCall("query", Object.assign({}, buildQ(true), { sessionId: navSession, sessionScope })).then((d) => {
|
|
3397
3419
|
setData(d);
|
|
3398
3420
|
setPage(0);
|
|
3399
3421
|
}).catch((e) => setErr(String(e && e.message || e))).finally(() => setLoading(false));
|
|
3400
|
-
}, [navAt]);
|
|
3422
|
+
}, [navAt, navSession]);
|
|
3401
3423
|
const rateCny = data && data.rateUsdCny || 7.2;
|
|
3402
3424
|
const resetFilters = (0, import_react2.useCallback)(() => {
|
|
3403
3425
|
setFromStr("");
|
|
@@ -3407,7 +3429,9 @@ function TokenLogView(props) {
|
|
|
3407
3429
|
setStatus("");
|
|
3408
3430
|
setEffort("");
|
|
3409
3431
|
setSessionId("");
|
|
3432
|
+
setSessionScope("tree");
|
|
3410
3433
|
setDim("");
|
|
3434
|
+
scopeTouchedRef.current = false;
|
|
3411
3435
|
setLoading(true);
|
|
3412
3436
|
setErr("");
|
|
3413
3437
|
rpcCall("query", {}).then((d) => {
|
|
@@ -3446,6 +3470,14 @@ function TokenLogView(props) {
|
|
|
3446
3470
|
}, [sortKey, sortDir]);
|
|
3447
3471
|
const records = data && data.records || [];
|
|
3448
3472
|
const totals = data && data.totals;
|
|
3473
|
+
const scopeInfo = data && data.sessionScope;
|
|
3474
|
+
const directTotals = data && data.directTotals;
|
|
3475
|
+
const breakdown = data && data.sessionBreakdown || [];
|
|
3476
|
+
const childTotals = scopeInfo && scopeInfo.scope === "tree" ? {
|
|
3477
|
+
calls: Math.max(0, (totals && totals.calls || 0) - (directTotals && directTotals.calls || 0)),
|
|
3478
|
+
totalTokens: Math.max(0, (totals && totals.totalTokens || 0) - (directTotals && directTotals.totalTokens || 0)),
|
|
3479
|
+
cost: Math.max(0, (totals && totals.cost || 0) - (directTotals && directTotals.cost || 0))
|
|
3480
|
+
} : null;
|
|
3449
3481
|
const sessionIds = data && data.sessionIds || [];
|
|
3450
3482
|
const sorted = (0, import_react2.useMemo)(() => {
|
|
3451
3483
|
const arr = records.slice();
|
|
@@ -3466,16 +3498,28 @@ function TokenLogView(props) {
|
|
|
3466
3498
|
const pageRows = sorted.slice(pageSafe * pageSize, (pageSafe + 1) * pageSize);
|
|
3467
3499
|
const cards = totals ? [
|
|
3468
3500
|
{ v: fmtNum(totals.calls), l: "\u8C03\u7528\u6B21\u6570" },
|
|
3469
|
-
{ v: fmtCompact(totals.totalTokens), l: "\u603B Token" },
|
|
3501
|
+
{ v: fmtCompact(totals.totalTokens), l: scopeInfo && scopeInfo.scope === "tree" ? "\u7D2F\u8BA1 Token\uFF08\u542B\u5B50\u4EFB\u52A1\uFF09" : "\u603B Token" },
|
|
3470
3502
|
{ v: fmtCompact(totals.cacheReadTokens), l: "\u8F93\u5165(\u547D\u4E2D)" },
|
|
3471
3503
|
{ v: fmtCompact(totals.inputTokens), l: "\u8F93\u5165(\u672A\u547D\u4E2D)" },
|
|
3472
3504
|
{ v: totals.cacheHitPct + "%", l: "\u7F13\u5B58\u547D\u4E2D\u7387" },
|
|
3473
3505
|
{ v: fmtCompact(totals.outputTokens), l: "\u8F93\u51FA" },
|
|
3474
|
-
{ v: fmtCostCny(totals.cost, rateCny), l: "\u6D88\u8017\u91D1\u989D(\u4F30\u7B97\xB7\u4EBA\u6C11\u5E01)" },
|
|
3506
|
+
{ v: fmtCostCny(totals.cost, rateCny), l: (scopeInfo && scopeInfo.scope === "tree" ? "\u7D2F\u8BA1\u91D1\u989D" : "\u6D88\u8017\u91D1\u989D") + "(\u4F30\u7B97\xB7\u4EBA\u6C11\u5E01)" },
|
|
3475
3507
|
{ v: fmtDuration(totals.llmMs), l: "\u7D2F\u8BA1\u8017\u65F6" + (totals.timed ? " (" + totals.timed + "\u6B65)" : "") }
|
|
3476
3508
|
] : [];
|
|
3477
3509
|
const opts = (arr) => (arr || []).map((x) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: x, children: x || "(\u7A7A)" }, x || "(none)"));
|
|
3478
3510
|
const modelChoices = provider && data && data.modelsByProvider ? data.modelsByProvider[provider] || [] : data && data.models || [];
|
|
3511
|
+
const changeScope = (next) => {
|
|
3512
|
+
scopeTouchedRef.current = true;
|
|
3513
|
+
setSessionScope(next);
|
|
3514
|
+
setLoading(true);
|
|
3515
|
+
setErr("");
|
|
3516
|
+
rpcCall("config", { sessionScope: next }).catch((e) => {
|
|
3517
|
+
setErr(String(e && e.message || e));
|
|
3518
|
+
}).then(() => rpcCall("query", Object.assign({}, buildQ(true), { sessionScope: next }))).then((d) => {
|
|
3519
|
+
setData(d);
|
|
3520
|
+
setPage(0);
|
|
3521
|
+
}).catch((e) => setErr(String(e && e.message || e))).finally(() => setLoading(false));
|
|
3522
|
+
};
|
|
3479
3523
|
const summaryRows = (data && data.summary || []).map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
3480
3524
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: r.key }),
|
|
3481
3525
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmtNum(r.calls) }),
|
|
@@ -3495,10 +3539,18 @@ function TokenLogView(props) {
|
|
|
3495
3539
|
const st = statusInfo(r);
|
|
3496
3540
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
3497
3541
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmtTime(r.time) }),
|
|
3498
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3542
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { children: [
|
|
3543
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dtok-sid", title: "\u4F1A\u8BDD\uFF1A" + r.sessionId + (r.parentSessionId ? "\n\u76F4\u63A5\u7236\u4F1A\u8BDD\uFF1A" + r.parentSessionId : "") + "\n\u70B9\u51FB\u6309\u6B64\u4F1A\u8BDD\u7B5B\u9009", onClick: () => {
|
|
3544
|
+
setSessionId(r.sessionId);
|
|
3545
|
+
setLoading(true);
|
|
3546
|
+
setErr("");
|
|
3547
|
+
rpcCall("query", Object.assign({}, buildQ(true), { sessionId: r.sessionId })).then((d) => {
|
|
3548
|
+
setData(d);
|
|
3549
|
+
setPage(0);
|
|
3550
|
+
}).catch((e) => setErr(String(e && e.message || e))).finally(() => setLoading(false));
|
|
3551
|
+
}, children: shortId(r.sessionId) }),
|
|
3552
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dtok-session-kind", children: sessionType(r) })
|
|
3553
|
+
] }),
|
|
3502
3554
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: r.provider || "\u2014" }),
|
|
3503
3555
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: r.model || "\u2014" }),
|
|
3504
3556
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmtNum(r.cacheReadTokens) }),
|
|
@@ -3538,6 +3590,14 @@ function TokenLogView(props) {
|
|
|
3538
3590
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChartsPanel, { records, rate: rateCny }, "charts-" + fetchedAt)
|
|
3539
3591
|
);
|
|
3540
3592
|
} else {
|
|
3593
|
+
if (scopeInfo && scopeInfo.sessionId) bodyNodes.push(
|
|
3594
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dtok-scope-note", children: [
|
|
3595
|
+
scopeInfo.scope === "tree" ? "\u4EFB\u52A1\u7D2F\u8BA1 = \u672C\u4F1A\u8BDD + \u5168\u90E8\u540E\u4EE3\u5B50\u4EFB\u52A1\uFF1B\u6309\u5B9E\u9645\u8C03\u7528 ID \u53BB\u91CD\uFF0C\u5B50\u4EFB\u52A1\u7EE7\u627F\u7684\u5386\u53F2\u4E0D\u4F1A\u91CD\u590D\u8BA1\u7B97\u3002" : "\u4EC5\u7EDF\u8BA1\u5F53\u524D\u4F1A\u8BDD\u81EA\u5DF1\u7684\u8C03\u7528\uFF0C\u4E0D\u5305\u542B\u6D3E\u53D1\u7684\u5B50\u4EFB\u52A1\u3002",
|
|
3596
|
+
" \u672C\u4F1A\u8BDD " + fmtCompact(directTotals && directTotals.totalTokens || 0) + " Token",
|
|
3597
|
+
childTotals ? " \xB7 \u5B50\u4EFB\u52A1 " + fmtCompact(childTotals.totalTokens) + " Token / " + fmtCostCny(childTotals.cost, rateCny) + "\uFF08" + scopeInfo.descendantCount + " \u4E2A\u4F1A\u8BDD\uFF09" : "",
|
|
3598
|
+
scopeInfo.complete === false ? " \xB7 \u8C31\u7CFB\u90E8\u5206\u7F3A\u5931\uFF0C\u4EC5\u7D2F\u8BA1\u5DF2\u77E5\u4F1A\u8BDD" : ""
|
|
3599
|
+
] }, "scope-note")
|
|
3600
|
+
);
|
|
3541
3601
|
if (cards.length) bodyNodes.push(
|
|
3542
3602
|
// key 带 fetchedAt:每次「手动查询 / 首次加载」拿到新数据时重建一次,KPI 卡重播回弹动画
|
|
3543
3603
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dtok-cards" + (fetchedAt ? " dtok-pop" : ""), children: cards.map((c, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dtok-card", style: { "--i": String(i) }, children: [
|
|
@@ -3545,6 +3605,32 @@ function TokenLogView(props) {
|
|
|
3545
3605
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "l", children: c.l })
|
|
3546
3606
|
] }, c.l)) }, "cards-" + fetchedAt)
|
|
3547
3607
|
);
|
|
3608
|
+
if (breakdown.length) bodyNodes.push(
|
|
3609
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dtok-section-title", children: [
|
|
3610
|
+
"\u4F1A\u8BDD\u7528\u91CF\u62C6\u5206\uFF08",
|
|
3611
|
+
breakdown.length,
|
|
3612
|
+
" \u4E2A\u6709\u7528\u91CF\u7684\u4F1A\u8BDD\uFF09"
|
|
3613
|
+
] }, "session-sum"),
|
|
3614
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "dtok-table-wrap", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("table", { className: "dtok-table", children: [
|
|
3615
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
3616
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u4F1A\u8BDD" }),
|
|
3617
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u7C7B\u578B" }),
|
|
3618
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u8C03\u7528" }),
|
|
3619
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u603B Token" }),
|
|
3620
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("th", { children: "\u91D1\u989D\uFF08\u4EBA\u6C11\u5E01\uFF09" })
|
|
3621
|
+
] }) }),
|
|
3622
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: breakdown.map((r) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("tr", { children: [
|
|
3623
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("td", { className: "dtok-session-tree", title: "\u4F1A\u8BDD\uFF1A" + r.sessionId + (r.parentSessionId ? "\n\u76F4\u63A5\u7236\u4F1A\u8BDD\uFF1A" + r.parentSessionId : ""), children: [
|
|
3624
|
+
r.sessionDepth ? "\u2514 ".repeat(Math.min(r.sessionDepth, 4)) : "",
|
|
3625
|
+
shortId(r.sessionId)
|
|
3626
|
+
] }),
|
|
3627
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: r.sessionId === scopeInfo.sessionId ? "\u5F53\u524D\u4F1A\u8BDD" : sessionType(r) }),
|
|
3628
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmtNum(r.calls) }),
|
|
3629
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmtCompact(r.totalTokens) }),
|
|
3630
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { children: fmtCostCny(r.cost, rateCny) })
|
|
3631
|
+
] }, r.sessionId)) })
|
|
3632
|
+
] }) }, "session-sum-table")
|
|
3633
|
+
);
|
|
3548
3634
|
if (summaryRows.length) bodyNodes.push(
|
|
3549
3635
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "dtok-section-title", children: [
|
|
3550
3636
|
"\u7EDF\u8BA1\u5206\u7EC4: ",
|
|
@@ -3641,6 +3727,13 @@ function TokenLogView(props) {
|
|
|
3641
3727
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", children: "\u5168\u90E8" }),
|
|
3642
3728
|
opts(sessionIds)
|
|
3643
3729
|
] }),
|
|
3730
|
+
sessionId ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
3731
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "\u4F1A\u8BDD\u53E3\u5F84" }),
|
|
3732
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dtok-select", value: sessionScope, "aria-label": "\u4F1A\u8BDD\u7528\u91CF\u53E3\u5F84", onChange: (e) => changeScope(e.target.value), children: [
|
|
3733
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "tree", children: "\u4EFB\u52A1\u7D2F\u8BA1\uFF08\u542B\u5B50\u4EFB\u52A1\uFF09" }),
|
|
3734
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "session", children: "\u4EC5\u672C\u4F1A\u8BDD" })
|
|
3735
|
+
] })
|
|
3736
|
+
] }) : null,
|
|
3644
3737
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { children: "\u63D0\u4F9B\u5546" }),
|
|
3645
3738
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("select", { className: "dtok-select", value: provider, onChange: (e) => {
|
|
3646
3739
|
setProvider(e.target.value);
|
|
@@ -3720,7 +3813,7 @@ function TokenLogHomeStat() {
|
|
|
3720
3813
|
}
|
|
3721
3814
|
function TokenLogChip(props) {
|
|
3722
3815
|
const sid = props && props.sessionId || props && props.session && props.session.sessionId || null;
|
|
3723
|
-
const [snap, setSnap] = (0, import_react2.useState)({ totals: null, rate: 7.2, err: "" });
|
|
3816
|
+
const [snap, setSnap] = (0, import_react2.useState)({ totals: null, directTotals: null, scope: null, rate: 7.2, err: "" });
|
|
3724
3817
|
(0, import_react2.useEffect)(() => {
|
|
3725
3818
|
if (!sid) return;
|
|
3726
3819
|
let cancel = false;
|
|
@@ -3728,9 +3821,9 @@ function TokenLogChip(props) {
|
|
|
3728
3821
|
const load = () => {
|
|
3729
3822
|
if (cancel || isTokenlogRouteGone()) return null;
|
|
3730
3823
|
return rpcCall("query", { sessionId: sid }).then((d) => {
|
|
3731
|
-
if (!cancel) setSnap({ totals: d && d.totals, rate: d && d.rateUsdCny || 7.2, err: "" });
|
|
3824
|
+
if (!cancel) setSnap({ totals: d && d.totals, directTotals: d && d.directTotals, scope: d && d.sessionScope, rate: d && d.rateUsdCny || 7.2, err: "" });
|
|
3732
3825
|
}).catch((e) => {
|
|
3733
|
-
if (!cancel) setSnap((s) => ({
|
|
3826
|
+
if (!cancel) setSnap((s) => ({ ...s, err: String(e && e.message || e) }));
|
|
3734
3827
|
});
|
|
3735
3828
|
};
|
|
3736
3829
|
load();
|
|
@@ -3742,25 +3835,34 @@ function TokenLogChip(props) {
|
|
|
3742
3835
|
}, [sid]);
|
|
3743
3836
|
if (!sid) return null;
|
|
3744
3837
|
const t = snap.totals;
|
|
3838
|
+
const cumulative = snap.scope && snap.scope.scope === "tree";
|
|
3839
|
+
const own = snap.directTotals;
|
|
3840
|
+
const childTokens = cumulative ? Math.max(0, (t && t.totalTokens || 0) - (own && own.totalTokens || 0)) : 0;
|
|
3841
|
+
const childCost = cumulative ? Math.max(0, (t && t.cost || 0) - (own && own.cost || 0)) : 0;
|
|
3745
3842
|
const gone = isTokenlogRouteGone();
|
|
3746
3843
|
const hasData = !!t && !gone && !(snap.err && !t);
|
|
3747
3844
|
const labelIcon = hasData ? "\u26C1 " : "";
|
|
3748
3845
|
const labelMain = gone ? "\u7528\u91CF\xB7\u672A\u542F\u7528" : snap.err && !t ? snap.err.includes("\u91CD\u542F") || snap.err.includes("\u542F\u7528") ? "\u7528\u91CF\xB7\u672A\u542F\u7528" : "\u7528\u91CF\xB7\u5931\u8D25" : t ? fmtCompact(t.totalTokens) : "\u2026";
|
|
3749
3846
|
const labelExtra = hasData && t.cost > 0 ? " \xB7 " + fmtCostCny(t.cost, snap.rate) : "";
|
|
3750
|
-
const title = gone ? routeGoneMessage() + "\n\uFF08\u53EF\u5728\u529F\u80FD\u575E\u91CC\u542F\u7528\u300C\u7528\u91CF\u8BB0\u5F55\u300D\uFF09" : t ? "\u672C\u4F1A\u8BDD " + fmtNum(t.calls) + " \u6B21\u8C03\u7528 \xB7 " + fmtNum(t.totalTokens) + " Token \xB7 " + fmtCostCny(t.cost, snap.rate) + "\uFF08\u4F30\u7B97\uFF09\n\u70B9\u51FB\u5728\u529F\u80FD\u575E\u67E5\u770B\u7528\u91CF\u8BB0\u5F55" : (snap.err ? snap.err + "\n" : "") + "\u70B9\u51FB\u5728\u529F\u80FD\u575E\u67E5\u770B\u7528\u91CF\u8BB0\u5F55";
|
|
3847
|
+
const title = gone ? routeGoneMessage() + "\n\uFF08\u53EF\u5728\u529F\u80FD\u575E\u91CC\u542F\u7528\u300C\u7528\u91CF\u8BB0\u5F55\u300D\uFF09" : t ? (cumulative ? "\u4EFB\u52A1\u7D2F\u8BA1\uFF08\u542B\u5B50\u4EFB\u52A1\uFF09" : "\u4EC5\u672C\u4F1A\u8BDD") + " " + fmtNum(t.calls) + " \u6B21\u8C03\u7528 \xB7 " + fmtNum(t.totalTokens) + " Token \xB7 " + fmtCostCny(t.cost, snap.rate) + "\uFF08\u4F30\u7B97\uFF09" + (cumulative ? "\n\u672C\u4F1A\u8BDD " + fmtCompact(own && own.totalTokens || 0) + " Token / " + fmtCostCny(own && own.cost || 0, snap.rate) + " \xB7 \u5B50\u4EFB\u52A1 " + fmtCompact(childTokens) + " Token / " + fmtCostCny(childCost, snap.rate) + "\uFF08" + snap.scope.descendantCount + " \u4E2A\u4F1A\u8BDD\uFF09" : "") + (cumulative && snap.scope.complete === false ? "\n\u8C31\u7CFB\u90E8\u5206\u7F3A\u5931\uFF0C\u4EC5\u7D2F\u8BA1\u5DF2\u77E5\u4F1A\u8BDD" : "") + "\n\u70B9\u51FB\u5728\u529F\u80FD\u575E\u67E5\u770B\u7528\u91CF\u8BB0\u5F55" : (snap.err ? snap.err + "\n" : "") + "\u70B9\u51FB\u5728\u529F\u80FD\u575E\u67E5\u770B\u7528\u91CF\u8BB0\u5F55";
|
|
3751
3848
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
3752
3849
|
"button",
|
|
3753
3850
|
{
|
|
3754
3851
|
type: "button",
|
|
3755
3852
|
className: "dockchip" + (snap.err && !t && !gone ? " err" : ""),
|
|
3756
3853
|
title,
|
|
3757
|
-
"aria-label": "\u4F1A\u8BDD\u7528\u91CF",
|
|
3854
|
+
"aria-label": cumulative ? "\u4EFB\u52A1\u7D2F\u8BA1\u7528\u91CF\uFF08\u542B\u5B50\u4EFB\u52A1\uFF09" : "\u672C\u4F1A\u8BDD\u7528\u91CF",
|
|
3758
3855
|
onClick: () => openPanel("tokenlog", { sessionId: sid, navAt: Date.now() }),
|
|
3759
3856
|
children: [
|
|
3857
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dockchip-svg", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { viewBox: "0 0 16 16", width: "13", height: "13", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
|
|
3858
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 12.5V9" }),
|
|
3859
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8 12.5V4.5" }),
|
|
3860
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12.5 12.5V7" })
|
|
3861
|
+
] }) }),
|
|
3760
3862
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dockchip-dot", style: { background: gone ? "var(--dsw-alias-label-tertiary,#8b95ab)" : "var(--dk-warn)" } }),
|
|
3761
3863
|
labelIcon ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dockchip-ic", children: labelIcon }) : null,
|
|
3762
|
-
hasData ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dockchip-pre-s", children: "\u7528\u91CF " }) : null,
|
|
3763
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: labelMain }),
|
|
3864
|
+
hasData ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dockchip-pre-s", children: cumulative ? "\u7D2F\u8BA1 " : "\u7528\u91CF " }) : null,
|
|
3865
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dockchip-val", children: labelMain }),
|
|
3764
3866
|
labelExtra ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "dockchip-x", children: labelExtra }) : null
|
|
3765
3867
|
]
|
|
3766
3868
|
}
|
|
@@ -3771,7 +3873,7 @@ var feature = {
|
|
|
3771
3873
|
name: "\u7528\u91CF\u8BB0\u5F55",
|
|
3772
3874
|
order: 110,
|
|
3773
3875
|
accent: "#fbbf24",
|
|
3774
|
-
description: "\u8BB0\u5F55\u5168\u90E8 LLM API \u8C03\u7528\uFF1A\u79D2\u7EA7\
|
|
3876
|
+
description: "\u8BB0\u5F55\u5168\u90E8 LLM API \u8C03\u7528\uFF1A\u79D2\u7EA7\u7B5B\u9009\u3001\u4E3B\u4EFB\u52A1+\u540E\u4EE3\u5B50\u4EFB\u52A1\u7D2F\u8BA1/\u4EC5\u672C\u4F1A\u8BDD\u5207\u6362\u3001\u4F1A\u8BDD\u7528\u91CF\u62C6\u5206\u3001Token/\u8D39\u7528\u7EDF\u8BA1\uFF08\u81EA\u5B9A\u4E49\u5355\u4EF7\u4E0E\u5CF0\u8C37\u4EF7\uFF09\u3001\u5206\u7EC4\u6C47\u603B\u3001\u660E\u7EC6\u68C0\u7D22\u4E0E CSV \u5BFC\u51FA",
|
|
3775
3877
|
css,
|
|
3776
3878
|
View: TokenLogView,
|
|
3777
3879
|
HomeStat: TokenLogHomeStat,
|
|
@@ -4339,10 +4441,10 @@ function ModelsStat() {
|
|
|
4339
4441
|
}
|
|
4340
4442
|
var feature2 = {
|
|
4341
4443
|
id: "modelconfig",
|
|
4342
|
-
name: "\u6A21\u578B\
|
|
4444
|
+
name: "\u6A21\u578B\u80FD\u529B",
|
|
4343
4445
|
order: 100,
|
|
4344
4446
|
accent: "#22d3ee",
|
|
4345
|
-
description: "\u7F16\u8F91\u5404 Provider \u6A21\u578B\u7684\u8F93\u5165\u7C7B\u578B\u4E0E\u601D\u8003\u5F3A\u5EA6\u6863\u4F4D\uFF0C\u5199\u56DE\u5B98\u65B9\u914D\u7F6E\u70ED\u751F\u6548\uFF1BProvider \u81EA\u8EAB\u7684\u589E\u5220\u6539\u5728\u300C\u6A21\u578B\
|
|
4447
|
+
description: "\u7F16\u8F91\u5404 Provider \u6A21\u578B\u7684\u8F93\u5165\u7C7B\u578B\u4E0E\u601D\u8003\u5F3A\u5EA6\u6863\u4F4D\uFF0C\u5199\u56DE\u5B98\u65B9\u914D\u7F6E\u70ED\u751F\u6548\uFF1BProvider \u81EA\u8EAB\u7684\u589E\u5220\u6539\u5728\u300C\u6A21\u578B\u7BA1\u7406\u300D\u91CC\u7BA1\u7406",
|
|
4346
4448
|
css: [
|
|
4347
4449
|
".dkm-note{color:var(--dsw-alias-label-secondary);font-size:12px;}",
|
|
4348
4450
|
".dkm-warn{color:var(--dk-warn);}",
|
|
@@ -4878,11 +4980,11 @@ function ProvidersView(props) {
|
|
|
4878
4980
|
);
|
|
4879
4981
|
const piProviders = providers.filter((p) => p.kind === "pi-ai");
|
|
4880
4982
|
const body = [
|
|
4881
|
-
import_react4.default.createElement("h2", { key: "title", className: "dkp-title" }, "\u6A21\u578B\
|
|
4983
|
+
import_react4.default.createElement("h2", { key: "title", className: "dkp-title" }, "\u6A21\u578B\u7BA1\u7406"),
|
|
4882
4984
|
import_react4.default.createElement(
|
|
4883
4985
|
"p",
|
|
4884
4986
|
{ key: "intro", className: "dkp-intro" },
|
|
4885
|
-
"\u65B0\u589E / \u7F16\u8F91 / \u5220\u9664\u81EA\u5B9A\u4E49\u6A21\u578B Provider\uFF08OpenAI \u517C\u5BB9\u3001Anthropic \u7B49\uFF09\uFF0C\u5199\u5165\u5B98\u65B9\u914D\u7F6E\u5E76\u70ED\u751F\u6548\uFF1BAPI Key \u5B58\u672C\u673A\u51ED\u636E\u5E93\uFF08\u6587\u4EF6\u4EC5 root \u53EF\u8BFB\uFF09\u3002\u5185\u7F6E DeepSeek \u5B98\u65B9 Provider \u5728\u672C\u9875\u53EA\u8BFB\uFF0C\u5176\u6A21\u578B\u76EE\u5F55\u5728\u300C\u6A21\u578B\
|
|
4987
|
+
"\u65B0\u589E / \u7F16\u8F91 / \u5220\u9664\u81EA\u5B9A\u4E49\u6A21\u578B Provider\uFF08OpenAI \u517C\u5BB9\u3001Anthropic \u7B49\uFF09\uFF0C\u5199\u5165\u5B98\u65B9\u914D\u7F6E\u5E76\u70ED\u751F\u6548\uFF1BAPI Key \u5B58\u672C\u673A\u51ED\u636E\u5E93\uFF08\u6587\u4EF6\u4EC5 root \u53EF\u8BFB\uFF09\u3002\u5185\u7F6E DeepSeek \u5B98\u65B9 Provider \u5728\u672C\u9875\u53EA\u8BFB\uFF0C\u5176\u6A21\u578B\u76EE\u5F55\u5728\u300C\u6A21\u578B\u80FD\u529B\u300D\u91CC\u7F16\u8F91\u3002\u672C\u529F\u80FD\u53EF\u5355\u72EC\u505C\u7528\uFF1A\u505C\u7528\u540E\u8FD9\u4E9B\u5199\u914D\u7F6E\u4E0E\u51FA\u7AD9\u8BF7\u6C42\u7684\u8DEF\u7531\u4E00\u5E76\u5173\u95ED\u3002"
|
|
4886
4988
|
)
|
|
4887
4989
|
];
|
|
4888
4990
|
if (snap.error) {
|
|
@@ -4969,8 +5071,8 @@ function ProvidersStat() {
|
|
|
4969
5071
|
}
|
|
4970
5072
|
var feature3 = {
|
|
4971
5073
|
id: "providerconfig",
|
|
4972
|
-
name: "\u6A21\u578B\
|
|
4973
|
-
order:
|
|
5074
|
+
name: "\u6A21\u578B\u7BA1\u7406",
|
|
5075
|
+
order: 99,
|
|
4974
5076
|
accent: "#8b5cf6",
|
|
4975
5077
|
description: "\u7BA1\u7406\u81EA\u5B9A\u4E49\u6A21\u578B Provider\uFF1A\u65B0\u589E/\u7F16\u8F91/\u5220\u9664\u3001\u62C9\u53D6\u4E0A\u6E38\u6A21\u578B\u5217\u8868\u3001\u5199\u5165 API Key\uFF08\u53EF\u5355\u72EC\u505C\u7528\uFF09",
|
|
4976
5078
|
css: [
|
|
@@ -5069,98 +5171,8 @@ var feature3 = {
|
|
|
5069
5171
|
HomeStat: ProvidersStat
|
|
5070
5172
|
};
|
|
5071
5173
|
|
|
5072
|
-
// features/heartbeat/view.js
|
|
5073
|
-
var import_react5 = __toESM(require("react"), 1);
|
|
5074
|
-
var loadedAt = Date.now();
|
|
5075
|
-
function uptimeText() {
|
|
5076
|
-
const sec = Math.max(0, Math.floor((Date.now() - loadedAt) / 1e3));
|
|
5077
|
-
const m = Math.floor(sec / 60);
|
|
5078
|
-
return "\u9762\u677F\u5DF2\u8FD0\u884C " + (m > 0 ? m + " \u5206 " : "") + sec % 60 + " \u79D2";
|
|
5079
|
-
}
|
|
5080
|
-
function HeartbeatView(props) {
|
|
5081
|
-
const ctx = props && props.ctx;
|
|
5082
|
-
const [txt, setTxt] = import_react5.default.useState(uptimeText());
|
|
5083
|
-
import_react5.default.useEffect(() => ctx && typeof ctx.interval === "function" ? ctx.interval(() => setTxt(uptimeText()), 1e3) : void 0, []);
|
|
5084
|
-
return import_react5.default.createElement("div", null, txt);
|
|
5085
|
-
}
|
|
5086
|
-
function HeartbeatStat(props) {
|
|
5087
|
-
const ctx = props && props.ctx;
|
|
5088
|
-
const [txt, setTxt] = import_react5.default.useState(uptimeText());
|
|
5089
|
-
import_react5.default.useEffect(() => ctx && typeof ctx.interval === "function" ? ctx.interval(() => setTxt(uptimeText()), 1e3) : void 0, []);
|
|
5090
|
-
return import_react5.default.createElement("span", null, txt);
|
|
5091
|
-
}
|
|
5092
|
-
var feature4 = {
|
|
5093
|
-
id: "heartbeat",
|
|
5094
|
-
name: "\u5FC3\u8DF3\u76D1\u89C6",
|
|
5095
|
-
order: 140,
|
|
5096
|
-
accent: "#34d399",
|
|
5097
|
-
description: "\u793A\u4F8B\u529F\u80FD\uFF1A\u9762\u677F\u4FA7\u8FD0\u884C\u65F6\u957F\u5FC3\u8DF3\uFF08\u7EAF Client\uFF09",
|
|
5098
|
-
defaultEnabled: false,
|
|
5099
|
-
View: HeartbeatView,
|
|
5100
|
-
HomeStat: HeartbeatStat
|
|
5101
|
-
};
|
|
5102
|
-
|
|
5103
|
-
// features/theme/view.js
|
|
5104
|
-
var import_react6 = __toESM(require("react"), 1);
|
|
5105
|
-
var import_react7 = require("react");
|
|
5106
|
-
var PREFERENCE_LABELS = { light: "\u4EAE\u8272", dark: "\u6697\u8272", system: "\u8DDF\u968F\u7CFB\u7EDF" };
|
|
5107
|
-
var THEME_LABELS = { light: "\u4EAE\u8272", dark: "\u6697\u8272" };
|
|
5108
|
-
function readThemeInfo(ctx) {
|
|
5109
|
-
const theme = ctx && ctx.get ? ctx.get("theme") : void 0;
|
|
5110
|
-
if (!theme || typeof theme.getTheme !== "function") return { err: "theme \u670D\u52A1\u4E0D\u53EF\u7528" };
|
|
5111
|
-
let snap = null;
|
|
5112
|
-
try {
|
|
5113
|
-
snap = theme.getTheme();
|
|
5114
|
-
} catch (err) {
|
|
5115
|
-
return { err: "\u8BFB\u53D6\u5931\u8D25\uFF1A" + String(err && err.message || err) };
|
|
5116
|
-
}
|
|
5117
|
-
const preference = snap && typeof snap.preference === "string" ? snap.preference : "";
|
|
5118
|
-
const activeId = snap && snap.active && typeof snap.active.id === "string" ? snap.active.id : "";
|
|
5119
|
-
const label = (PREFERENCE_LABELS[preference] || preference || "\u672A\u77E5") + (activeId && activeId !== preference && THEME_LABELS[activeId] ? "\uFF08\u5B9E\u9645" + THEME_LABELS[activeId] + "\uFF09" : "");
|
|
5120
|
-
return { label };
|
|
5121
|
-
}
|
|
5122
|
-
function useThemeInfo(ctx) {
|
|
5123
|
-
const [info, setInfo] = (0, import_react7.useState)(() => readThemeInfo(ctx));
|
|
5124
|
-
(0, import_react7.useEffect)(() => {
|
|
5125
|
-
let off = null;
|
|
5126
|
-
try {
|
|
5127
|
-
if (ctx && typeof ctx.on === "function") {
|
|
5128
|
-
off = ctx.on("theme/change", () => setInfo(readThemeInfo(ctx)));
|
|
5129
|
-
}
|
|
5130
|
-
} catch {
|
|
5131
|
-
}
|
|
5132
|
-
return () => {
|
|
5133
|
-
try {
|
|
5134
|
-
if (typeof off === "function") off();
|
|
5135
|
-
} catch {
|
|
5136
|
-
}
|
|
5137
|
-
};
|
|
5138
|
-
}, [ctx]);
|
|
5139
|
-
return info;
|
|
5140
|
-
}
|
|
5141
|
-
function ThemeView(props) {
|
|
5142
|
-
const r = useThemeInfo(props && props.ctx);
|
|
5143
|
-
if (r.err) return import_react6.default.createElement("div", null, r.err);
|
|
5144
|
-
return import_react6.default.createElement("div", null, "\u5F53\u524D\u4E3B\u9898\uFF1A" + r.label);
|
|
5145
|
-
}
|
|
5146
|
-
function ThemeStat(props) {
|
|
5147
|
-
const r = useThemeInfo(props && props.ctx);
|
|
5148
|
-
if (r.err) return import_react6.default.createElement("span", null, r.err);
|
|
5149
|
-
return import_react6.default.createElement("span", null, "\u4E3B\u9898\uFF1A" + r.label);
|
|
5150
|
-
}
|
|
5151
|
-
var feature5 = {
|
|
5152
|
-
id: "theme",
|
|
5153
|
-
name: "\u4E3B\u9898\u4FE1\u606F",
|
|
5154
|
-
order: 150,
|
|
5155
|
-
accent: "#a78bfa",
|
|
5156
|
-
description: "\u8BFB\u53D6\u5F53\u524D\u4E3B\u9898\u5FEB\u7167\uFF1A\u504F\u597D\u4E0E\u5B9E\u9645\u751F\u6548\u4E3B\u9898\uFF08\u7EAF Client\uFF0C\u4E3B\u9898\u5207\u6362\u5B9E\u65F6\u5237\u65B0\uFF09",
|
|
5157
|
-
defaultEnabled: false,
|
|
5158
|
-
View: ThemeView,
|
|
5159
|
-
HomeStat: ThemeStat
|
|
5160
|
-
};
|
|
5161
|
-
|
|
5162
5174
|
// features/balance/view.js
|
|
5163
|
-
var
|
|
5175
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
5164
5176
|
var ACCENT_PALETTE = ["#2563eb", "#0d9488", "#b45309", "#7c3aed", "#be185d", "#0369a1", "#c2410c", "#15803d", "#a21caf", "#0e7490"];
|
|
5165
5177
|
var CURATED_ACCENTS = {
|
|
5166
5178
|
"deepseek-official": "#2563eb",
|
|
@@ -5227,8 +5239,8 @@ var balanceStore = {
|
|
|
5227
5239
|
}
|
|
5228
5240
|
};
|
|
5229
5241
|
function useBalance(ctx) {
|
|
5230
|
-
const [snap, setSnap] =
|
|
5231
|
-
|
|
5242
|
+
const [snap, setSnap] = import_react5.default.useState(balanceStore.snap);
|
|
5243
|
+
import_react5.default.useEffect(() => {
|
|
5232
5244
|
const off = balanceStore.subscribe(() => setSnap(balanceStore.snap));
|
|
5233
5245
|
if (!balanceStore.snap.data && !balanceStore.snap.loading) balanceStore.load();
|
|
5234
5246
|
const disposer = ctx && typeof ctx.interval === "function" ? ctx.interval(() => balanceStore.load(), 5 * 60 * 1e3) : null;
|
|
@@ -5242,7 +5254,7 @@ function useBalance(ctx) {
|
|
|
5242
5254
|
function BalanceView(props) {
|
|
5243
5255
|
const snap = useBalance(props && props.ctx);
|
|
5244
5256
|
const load = () => balanceStore.load();
|
|
5245
|
-
|
|
5257
|
+
import_react5.default.useEffect(() => {
|
|
5246
5258
|
const pid = props && props.params && props.params.provider;
|
|
5247
5259
|
if (!pid || typeof document === "undefined") return;
|
|
5248
5260
|
const t = setTimeout(() => {
|
|
@@ -5265,15 +5277,15 @@ function BalanceView(props) {
|
|
|
5265
5277
|
const def = data && data.default ? data.default.provider : null;
|
|
5266
5278
|
const body = [];
|
|
5267
5279
|
if (snap.error) {
|
|
5268
|
-
body.push(
|
|
5280
|
+
body.push(import_react5.default.createElement("div", { key: "err", className: "dkb-note dkb-error" }, "\u4F59\u989D\u67E5\u8BE2\u5931\u8D25\uFF1A" + snap.error));
|
|
5269
5281
|
} else if (!data) {
|
|
5270
|
-
body.push(
|
|
5282
|
+
body.push(import_react5.default.createElement("div", { key: "loading", className: "dkb-note" }, snap.loading ? "\u6B63\u5728\u62C9\u53D6\u4F59\u989D\u2026" : "\u8FD8\u6CA1\u6709\u6570\u636E\uFF0C\u70B9\u51FB\u4E0B\u65B9\u5237\u65B0"));
|
|
5271
5283
|
} else if (providers.length === 0) {
|
|
5272
|
-
body.push(
|
|
5284
|
+
body.push(import_react5.default.createElement("div", { key: "empty", className: "dkb-note" }, "\u6CA1\u6709\u627E\u5230\u5DF2\u914D\u7F6E\u7684\u6A21\u578B Provider"));
|
|
5273
5285
|
} else {
|
|
5274
5286
|
const rank = (p) => p.balance && p.balance.status === "ok" ? 0 : p.balance && p.balance.status === "login-required" ? 1 : 2;
|
|
5275
5287
|
const sorted = providers.slice().sort((a, b) => rank(a) - rank(b));
|
|
5276
|
-
body.push(
|
|
5288
|
+
body.push(import_react5.default.createElement(
|
|
5277
5289
|
"div",
|
|
5278
5290
|
{ key: "rows", className: "dkb-rows" },
|
|
5279
5291
|
sorted.map((p) => {
|
|
@@ -5290,76 +5302,76 @@ function BalanceView(props) {
|
|
|
5290
5302
|
let balBody = null;
|
|
5291
5303
|
if (b && b.status === "ok" && b.kind === "quota") {
|
|
5292
5304
|
const dims = Array.isArray(b.dims) ? b.dims : [];
|
|
5293
|
-
balBody =
|
|
5294
|
-
|
|
5305
|
+
balBody = import_react5.default.createElement(
|
|
5306
|
+
import_react5.default.Fragment,
|
|
5295
5307
|
null,
|
|
5296
|
-
|
|
5308
|
+
import_react5.default.createElement(
|
|
5297
5309
|
"div",
|
|
5298
5310
|
{ className: "dkb-main" },
|
|
5299
|
-
|
|
5300
|
-
|
|
5301
|
-
|
|
5311
|
+
import_react5.default.createElement("span", { className: "dkb-main-label" }, "\u5269\u4F59\u989D\u5EA6"),
|
|
5312
|
+
import_react5.default.createElement("span", { className: "dkb-main-value" }, fmt(b.remaining) + (b.unit ? " " + b.unit : "")),
|
|
5313
|
+
import_react5.default.createElement(
|
|
5302
5314
|
"span",
|
|
5303
5315
|
{ className: "dkb-main-part" },
|
|
5304
5316
|
"\u5DF2\u7528 " + fmt(b.used) + " / \u603B " + fmt(b.limit),
|
|
5305
|
-
b.resetTime ?
|
|
5317
|
+
b.resetTime ? import_react5.default.createElement("span", null, " \xB7 \u91CD\u7F6E " + String(b.resetTime).slice(0, 10)) : null
|
|
5306
5318
|
)
|
|
5307
5319
|
),
|
|
5308
|
-
dims.map((d, i) =>
|
|
5320
|
+
dims.map((d, i) => import_react5.default.createElement(
|
|
5309
5321
|
"div",
|
|
5310
5322
|
{ key: "d" + i, className: "dkb-dim" },
|
|
5311
|
-
|
|
5312
|
-
|
|
5323
|
+
import_react5.default.createElement("span", { className: "dkb-dim-label" }, d.window === "weekly" ? "\u5468\u989D\u5EA6" : "\u5C0F\u65F6\u989D\u5EA6"),
|
|
5324
|
+
import_react5.default.createElement(
|
|
5313
5325
|
"span",
|
|
5314
5326
|
{ className: "dkb-dim-bar" },
|
|
5315
|
-
|
|
5327
|
+
import_react5.default.createElement("span", { className: "dkb-dim-fill", style: { width: (d.limit > 0 ? Math.min(100, Math.round(d.remaining / d.limit * 100)) : 0) + "%" } })
|
|
5316
5328
|
),
|
|
5317
|
-
|
|
5329
|
+
import_react5.default.createElement("span", { className: "dkb-dim-text" }, "\u5269 " + fmt(d.remaining) + " / " + fmt(d.limit))
|
|
5318
5330
|
))
|
|
5319
5331
|
);
|
|
5320
5332
|
} else if (b && b.status === "ok") {
|
|
5321
5333
|
const infos = Array.isArray(b.infos) ? b.infos : [];
|
|
5322
|
-
balBody =
|
|
5334
|
+
balBody = import_react5.default.createElement(
|
|
5323
5335
|
"div",
|
|
5324
5336
|
{ className: "dkb-mains" },
|
|
5325
5337
|
infos.map((rawInfo, idx) => {
|
|
5326
5338
|
const i = cnyBalanceInfo(rawInfo);
|
|
5327
|
-
return
|
|
5339
|
+
return import_react5.default.createElement(
|
|
5328
5340
|
"div",
|
|
5329
5341
|
{ key: idx, className: "dkb-main" },
|
|
5330
|
-
|
|
5331
|
-
|
|
5332
|
-
|
|
5342
|
+
import_react5.default.createElement("span", { className: "dkb-main-label", style: { color: accent } }, i.currency),
|
|
5343
|
+
import_react5.default.createElement("span", { className: "dkb-main-value" }, moneyText(i.totalBalance)),
|
|
5344
|
+
import_react5.default.createElement(
|
|
5333
5345
|
"span",
|
|
5334
5346
|
{ className: "dkb-main-parts" },
|
|
5335
|
-
i.grantedBalance != null ?
|
|
5336
|
-
i.toppedUpBalance != null ?
|
|
5347
|
+
i.grantedBalance != null ? import_react5.default.createElement("span", { className: "dkb-main-part", style: { color: C_GRANTED } }, "\u8D60\u9001 " + moneyText(i.grantedBalance)) : null,
|
|
5348
|
+
i.toppedUpBalance != null ? import_react5.default.createElement("span", { className: "dkb-main-part", style: { color: C_TOPUP } }, "\u5145\u503C " + moneyText(i.toppedUpBalance)) : null
|
|
5337
5349
|
)
|
|
5338
5350
|
);
|
|
5339
5351
|
})
|
|
5340
5352
|
);
|
|
5341
5353
|
} else if (b && b.status === "login-required" && b.consoleUrl) {
|
|
5342
|
-
balBody =
|
|
5354
|
+
balBody = import_react5.default.createElement(
|
|
5343
5355
|
"div",
|
|
5344
5356
|
{ className: "dkb-main" },
|
|
5345
|
-
|
|
5357
|
+
import_react5.default.createElement("a", { href: b.consoleUrl, target: "_blank", rel: "noreferrer", className: "dkb-link", style: { color: accent } }, "\u53BB\u63A7\u5236\u53F0\u67E5\u770B\u4F59\u989D \u2192")
|
|
5346
5358
|
);
|
|
5347
5359
|
} else {
|
|
5348
|
-
balBody = b && b.message ?
|
|
5360
|
+
balBody = b && b.message ? import_react5.default.createElement("div", { className: "dkb-note" }, b.message) : import_react5.default.createElement("div", { className: "dkb-note" }, "\u8BE5 Provider \u6CA1\u6709\u5DF2\u77E5\u7684\u4F59\u989D\u67E5\u8BE2\u63A5\u53E3");
|
|
5349
5361
|
}
|
|
5350
5362
|
const sub = ["ID " + p.id, p.api, p.baseURL ? p.baseURL.replace(/^https?:\/\//, "") : null].filter(Boolean).join(" \xB7 ");
|
|
5351
|
-
return
|
|
5363
|
+
return import_react5.default.createElement(
|
|
5352
5364
|
"div",
|
|
5353
5365
|
{ key: p.id, className: "dkb-row", "data-dock-provider": p.id },
|
|
5354
|
-
|
|
5366
|
+
import_react5.default.createElement(
|
|
5355
5367
|
"div",
|
|
5356
5368
|
{ className: "dkb-row-head" },
|
|
5357
|
-
|
|
5358
|
-
|
|
5359
|
-
def === p.id ?
|
|
5360
|
-
|
|
5369
|
+
import_react5.default.createElement("span", { className: "dkb-dot", style: { background: accent } }),
|
|
5370
|
+
import_react5.default.createElement("span", { className: "dkb-name", style: { color: accent } }, p.displayName),
|
|
5371
|
+
def === p.id ? import_react5.default.createElement("span", { className: "dkb-default" }, "\u9ED8\u8BA4") : null,
|
|
5372
|
+
import_react5.default.createElement("span", { className: "dkb-badge" + (badge[1] ? " " + badge[1] : ""), style: badge[1] === "err" ? { color: C_ERR, borderColor: C_ERR } : null }, badge[0]),
|
|
5361
5373
|
// 模型数折叠提示(点开展开 chips)
|
|
5362
|
-
p.models && p.models.length > 0 ?
|
|
5374
|
+
p.models && p.models.length > 0 ? import_react5.default.createElement("button", {
|
|
5363
5375
|
type: "button",
|
|
5364
5376
|
className: "dkb-models-toggle",
|
|
5365
5377
|
title: p.models.join(", "),
|
|
@@ -5369,13 +5381,13 @@ function BalanceView(props) {
|
|
|
5369
5381
|
}
|
|
5370
5382
|
}, p.models.length + " \u4E2A\u6A21\u578B \u25BE") : null
|
|
5371
5383
|
),
|
|
5372
|
-
sub ?
|
|
5373
|
-
p.apiKeyEnv ?
|
|
5374
|
-
p.models && p.models.length > 0 ?
|
|
5384
|
+
sub ? import_react5.default.createElement("div", { className: "dkb-sub" }, sub) : null,
|
|
5385
|
+
p.apiKeyEnv ? import_react5.default.createElement("div", { className: "dkb-sub" }, "\u5BC6\u94A5: " + p.apiKeyEnv + (p.credentialConfigured ? " \u2713" : " \u2717")) : null,
|
|
5386
|
+
p.models && p.models.length > 0 ? import_react5.default.createElement(
|
|
5375
5387
|
"div",
|
|
5376
5388
|
{ className: "dkb-chips" },
|
|
5377
|
-
p.models.slice(0, 8).map((m) =>
|
|
5378
|
-
p.models.length > 8 ?
|
|
5389
|
+
p.models.slice(0, 8).map((m) => import_react5.default.createElement("span", { key: m, className: "dkb-chip", style: { border: "1px solid " + accent, color: accent, background: accent + "1a" } }, m)),
|
|
5390
|
+
p.models.length > 8 ? import_react5.default.createElement("span", { key: "more", className: "dkb-chip" }, "+" + (p.models.length - 8)) : null
|
|
5379
5391
|
) : null,
|
|
5380
5392
|
balBody
|
|
5381
5393
|
);
|
|
@@ -5383,20 +5395,20 @@ function BalanceView(props) {
|
|
|
5383
5395
|
));
|
|
5384
5396
|
}
|
|
5385
5397
|
const now = new Date(data && data.generatedAt ? data.generatedAt : Date.now());
|
|
5386
|
-
return
|
|
5398
|
+
return import_react5.default.createElement(
|
|
5387
5399
|
"div",
|
|
5388
5400
|
{ className: "dkb-rows" },
|
|
5389
|
-
|
|
5401
|
+
import_react5.default.createElement(
|
|
5390
5402
|
"div",
|
|
5391
5403
|
{ className: "dkb-note" },
|
|
5392
5404
|
data && !snap.error && providers.length > 0 ? okCount + "/" + providers.length + " \u4E2A Provider \u53EF\u67E5\u4F59\u989D\uFF08\u53EF\u67E5\u7684\u6392\u524D\u9762\uFF09" : "\u6A21\u578B\u4F59\u989D \xB7 Host \u534A\u90E8\u5B9E\u65F6\u62C9\u53D6"
|
|
5393
5405
|
),
|
|
5394
5406
|
body,
|
|
5395
|
-
|
|
5407
|
+
import_react5.default.createElement(
|
|
5396
5408
|
"div",
|
|
5397
5409
|
{ className: "dkb-foot" },
|
|
5398
|
-
|
|
5399
|
-
|
|
5410
|
+
import_react5.default.createElement("span", null, snap.loading ? "\u5237\u65B0\u4E2D\u2026" : "\u66F4\u65B0\u4E8E " + now.toLocaleTimeString()),
|
|
5411
|
+
import_react5.default.createElement("button", { type: "button", className: "dkb-refresh", onClick: load }, "\u5237\u65B0")
|
|
5400
5412
|
)
|
|
5401
5413
|
);
|
|
5402
5414
|
}
|
|
@@ -5404,14 +5416,14 @@ function BalanceStat(props) {
|
|
|
5404
5416
|
const snap = useBalance(props && props.ctx);
|
|
5405
5417
|
const data = snap.data;
|
|
5406
5418
|
const providers = data && Array.isArray(data.providers) ? data.providers : [];
|
|
5407
|
-
if (snap.error) return
|
|
5408
|
-
if (!data) return
|
|
5419
|
+
if (snap.error) return import_react5.default.createElement("span", { className: "dockm-err" }, "\u4F59\u989D\u67E5\u8BE2\u5931\u8D25\uFF08\u70B9\u51FB\u8FDB\u5165\u67E5\u770B\u8BE6\u60C5\uFF09");
|
|
5420
|
+
if (!data) return import_react5.default.createElement("span", null, snap.loading ? "\u6B63\u5728\u62C9\u53D6\u4F59\u989D\u2026" : "\u7B49\u5F85\u62C9\u53D6\u4F59\u989D");
|
|
5409
5421
|
const ok = providers.filter((p) => p.balance && p.balance.status === "ok").length;
|
|
5410
|
-
return
|
|
5422
|
+
return import_react5.default.createElement("span", null, providers.length + " \u4E2A Provider \xB7 " + ok + " \u4E2A\u53EF\u67E5\u4F59\u989D");
|
|
5411
5423
|
}
|
|
5412
5424
|
function useCurrentProvider(ctx, sessionId) {
|
|
5413
|
-
const [cur, setCur] =
|
|
5414
|
-
|
|
5425
|
+
const [cur, setCur] = import_react5.default.useState(null);
|
|
5426
|
+
import_react5.default.useEffect(() => {
|
|
5415
5427
|
let alive = true, off = null;
|
|
5416
5428
|
try {
|
|
5417
5429
|
const models = ctx && ctx.get ? ctx.get("modelDirectories") : void 0;
|
|
@@ -5474,7 +5486,7 @@ function BalanceChip(props) {
|
|
|
5474
5486
|
const selModel = sel && (sel.model || sel.selected && sel.selected.model) || null;
|
|
5475
5487
|
const title = cur ? (cur.displayName || cur.id) + (selModel ? " \xB7 \u5F53\u524D\u6A21\u578B " + selModel : "") + " \xB7 \u70B9\u51FB\u5728\u529F\u80FD\u575E\u67E5\u770B\u4F59\u989D\u8BE6\u60C5" : "\u70B9\u51FB\u6253\u5F00\u529F\u80FD\u575E \xB7 \u6A21\u578B\u4F59\u989D";
|
|
5476
5488
|
const mm = /^(余额 )([\s\S]*)$/.exec(text);
|
|
5477
|
-
return
|
|
5489
|
+
return import_react5.default.createElement(
|
|
5478
5490
|
"button",
|
|
5479
5491
|
{
|
|
5480
5492
|
type: "button",
|
|
@@ -5483,13 +5495,24 @@ function BalanceChip(props) {
|
|
|
5483
5495
|
"aria-label": "\u6A21\u578B\u4F59\u989D",
|
|
5484
5496
|
onClick: () => openPanel("balance", def ? { provider: def } : null)
|
|
5485
5497
|
},
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
|
|
5498
|
+
// 窄屏只显示这枚小图标:点它进功能坞看余额详情(title 里是完整数值)
|
|
5499
|
+
import_react5.default.createElement(
|
|
5500
|
+
"span",
|
|
5501
|
+
{ className: "dockchip-svg", "aria-hidden": "true" },
|
|
5502
|
+
import_react5.default.createElement(
|
|
5503
|
+
"svg",
|
|
5504
|
+
{ viewBox: "0 0 16 16", width: 13, height: 13, fill: "none", stroke: "currentColor", strokeWidth: 1.5, strokeLinecap: "round", strokeLinejoin: "round" },
|
|
5505
|
+
import_react5.default.createElement("path", { d: "M2.8 6.2h10.4v6.3a1 1 0 0 1-1 1H3.8a1 1 0 0 1-1-1z" }),
|
|
5506
|
+
import_react5.default.createElement("path", { d: "M5.4 6.2V4.6a2.6 2.6 0 0 1 5.2 0v1.6" })
|
|
5507
|
+
)
|
|
5508
|
+
),
|
|
5509
|
+
import_react5.default.createElement("span", { className: "dockchip-dot", style: { background: accent } }),
|
|
5510
|
+
mm ? import_react5.default.createElement("span", { className: "dockchip-pre" }, mm[1]) : null,
|
|
5511
|
+
mm ? import_react5.default.createElement("span", { className: "dockchip-pre-s" }, "\u4F59\u989D ") : null,
|
|
5512
|
+
import_react5.default.createElement("span", { className: "dockchip-val" }, mm ? mm[2] : text)
|
|
5490
5513
|
);
|
|
5491
5514
|
}
|
|
5492
|
-
var
|
|
5515
|
+
var feature4 = {
|
|
5493
5516
|
id: "balance",
|
|
5494
5517
|
name: "\u6A21\u578B\u4F59\u989D",
|
|
5495
5518
|
order: 120,
|
|
@@ -5546,7 +5569,7 @@ var feature6 = {
|
|
|
5546
5569
|
};
|
|
5547
5570
|
|
|
5548
5571
|
// features/animation/view.jsx
|
|
5549
|
-
var
|
|
5572
|
+
var import_react6 = require("react");
|
|
5550
5573
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
5551
5574
|
function rpcCall2(method, args) {
|
|
5552
5575
|
return fetch("dsh-dock/animation/" + method, {
|
|
@@ -5644,13 +5667,13 @@ var animationStore = {
|
|
|
5644
5667
|
}
|
|
5645
5668
|
};
|
|
5646
5669
|
function useAnimation() {
|
|
5647
|
-
const [snap, setSnap] = (0,
|
|
5648
|
-
(0,
|
|
5670
|
+
const [snap, setSnap] = (0, import_react6.useState)(animationStore.snap);
|
|
5671
|
+
(0, import_react6.useEffect)(() => animationStore.subscribe(() => setSnap(animationStore.snap)), []);
|
|
5649
5672
|
return snap;
|
|
5650
5673
|
}
|
|
5651
5674
|
function useTicker(ctx, active) {
|
|
5652
|
-
const [, bump] = (0,
|
|
5653
|
-
(0,
|
|
5675
|
+
const [, bump] = (0, import_react6.useState)(0);
|
|
5676
|
+
(0, import_react6.useEffect)(() => {
|
|
5654
5677
|
if (!active) return;
|
|
5655
5678
|
if (ctx && typeof ctx.interval === "function") return ctx.interval(bump, 1e3);
|
|
5656
5679
|
const t = setInterval(bump, 1e3);
|
|
@@ -5825,7 +5848,7 @@ var MATRIX_CHARS = "01</>;{}=+*#";
|
|
|
5825
5848
|
function AmbientLayer(props) {
|
|
5826
5849
|
const mode = props.mode;
|
|
5827
5850
|
const speed = props.speed;
|
|
5828
|
-
const particles = (0,
|
|
5851
|
+
const particles = (0, import_react6.useMemo)(() => {
|
|
5829
5852
|
if (mode === "matrix") return { matrix: makeBits(34, () => ({
|
|
5830
5853
|
l: Math.random() * 100,
|
|
5831
5854
|
d: 4 + Math.random() * 6,
|
|
@@ -6073,8 +6096,8 @@ function composerDockPoint(side = "right") {
|
|
|
6073
6096
|
};
|
|
6074
6097
|
}
|
|
6075
6098
|
function useSpaceDocks(enabled) {
|
|
6076
|
-
const [docks, setDocks] = (0,
|
|
6077
|
-
(0,
|
|
6099
|
+
const [docks, setDocks] = (0, import_react6.useState)(null);
|
|
6100
|
+
(0, import_react6.useEffect)(() => {
|
|
6078
6101
|
if (!enabled || typeof window === "undefined") {
|
|
6079
6102
|
setDocks(null);
|
|
6080
6103
|
return void 0;
|
|
@@ -6269,25 +6292,25 @@ function ProgrammingStuck(props) {
|
|
|
6269
6292
|
function AnimationOverlay(props) {
|
|
6270
6293
|
const ctx = props && props.ctx;
|
|
6271
6294
|
const snap = useAnimation();
|
|
6272
|
-
const [flourish, setFlourish] = (0,
|
|
6273
|
-
const [bursts, setBursts] = (0,
|
|
6274
|
-
const [deliveries, setDeliveries] = (0,
|
|
6275
|
-
const [departures, setDepartures] = (0,
|
|
6276
|
-
const prevActiveRef = (0,
|
|
6277
|
-
const burstIdRef = (0,
|
|
6278
|
-
const deliveryIdRef = (0,
|
|
6279
|
-
const departureTimersRef = (0,
|
|
6280
|
-
const lastImmediateDepartureRef = (0,
|
|
6281
|
-
(0,
|
|
6295
|
+
const [flourish, setFlourish] = (0, import_react6.useState)(null);
|
|
6296
|
+
const [bursts, setBursts] = (0, import_react6.useState)([]);
|
|
6297
|
+
const [deliveries, setDeliveries] = (0, import_react6.useState)([]);
|
|
6298
|
+
const [departures, setDepartures] = (0, import_react6.useState)([]);
|
|
6299
|
+
const prevActiveRef = (0, import_react6.useRef)(null);
|
|
6300
|
+
const burstIdRef = (0, import_react6.useRef)(0);
|
|
6301
|
+
const deliveryIdRef = (0, import_react6.useRef)(0);
|
|
6302
|
+
const departureTimersRef = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
|
|
6303
|
+
const lastImmediateDepartureRef = (0, import_react6.useRef)(0);
|
|
6304
|
+
(0, import_react6.useEffect)(() => () => {
|
|
6282
6305
|
for (const timer of departureTimersRef.current.values()) clearTimeout(timer);
|
|
6283
6306
|
departureTimersRef.current.clear();
|
|
6284
6307
|
}, []);
|
|
6285
|
-
const pushBurst = (0,
|
|
6308
|
+
const pushBurst = (0, import_react6.useCallback)((type, x, y, bits) => {
|
|
6286
6309
|
const id = ++burstIdRef.current;
|
|
6287
6310
|
setBursts((prev) => prev.concat([{ id, type, x, y, bits }]).slice(-6));
|
|
6288
6311
|
setTimeout(() => setBursts((prev) => prev.filter((b) => b.id !== id)), 2600);
|
|
6289
6312
|
}, []);
|
|
6290
|
-
const launchMission = (0,
|
|
6313
|
+
const launchMission = (0, import_react6.useCallback)(() => {
|
|
6291
6314
|
const cfg2 = animationStore.snap.status && animationStore.snap.status.config;
|
|
6292
6315
|
if (!cfg2 || !cfg2.animationEnabled || cfg2.effectMode !== "space") return false;
|
|
6293
6316
|
const id = ++deliveryIdRef.current;
|
|
@@ -6310,7 +6333,7 @@ function AnimationOverlay(props) {
|
|
|
6310
6333
|
}, departure.duration));
|
|
6311
6334
|
return true;
|
|
6312
6335
|
}, []);
|
|
6313
|
-
(0,
|
|
6336
|
+
(0, import_react6.useEffect)(() => {
|
|
6314
6337
|
if (typeof document === "undefined") return;
|
|
6315
6338
|
const onClick = (e) => {
|
|
6316
6339
|
const t = e.target;
|
|
@@ -6337,8 +6360,8 @@ function AnimationOverlay(props) {
|
|
|
6337
6360
|
document.addEventListener("click", onClick, true);
|
|
6338
6361
|
return () => document.removeEventListener("click", onClick, true);
|
|
6339
6362
|
}, [pushBurst, launchMission]);
|
|
6340
|
-
const taskCountRef = (0,
|
|
6341
|
-
(0,
|
|
6363
|
+
const taskCountRef = (0, import_react6.useRef)(0);
|
|
6364
|
+
(0, import_react6.useEffect)(() => {
|
|
6342
6365
|
const st2 = snap.status;
|
|
6343
6366
|
if (!st2 || !st2.active) return;
|
|
6344
6367
|
const n = st2.active.length;
|
|
@@ -6349,7 +6372,7 @@ function AnimationOverlay(props) {
|
|
|
6349
6372
|
}
|
|
6350
6373
|
taskCountRef.current = n;
|
|
6351
6374
|
}, [snap.status, pushBurst, launchMission]);
|
|
6352
|
-
(0,
|
|
6375
|
+
(0, import_react6.useEffect)(() => {
|
|
6353
6376
|
let stopped = false;
|
|
6354
6377
|
let timer = null;
|
|
6355
6378
|
const loop = async () => {
|
|
@@ -6369,7 +6392,7 @@ function AnimationOverlay(props) {
|
|
|
6369
6392
|
document.removeEventListener("visibilitychange", onVisible);
|
|
6370
6393
|
};
|
|
6371
6394
|
}, []);
|
|
6372
|
-
(0,
|
|
6395
|
+
(0, import_react6.useEffect)(() => {
|
|
6373
6396
|
const st2 = snap.status;
|
|
6374
6397
|
if (!st2 || !st2.active) return;
|
|
6375
6398
|
const prev = prevActiveRef.current;
|
|
@@ -6417,8 +6440,8 @@ function AnimationOverlay(props) {
|
|
|
6417
6440
|
const phase = active.length > 0 ? active.reduce((best, x) => !best || (x.phaseAt || 0) > (best.phaseAt || 0) ? x : best, null).phase : "think";
|
|
6418
6441
|
const waitingTask = active.find((x) => taskWaiting(x)) || null;
|
|
6419
6442
|
const waitWord = waitingTask && taskApprovals(waitingTask).length === 0 ? "\u7B49\u5F85\u56DE\u7B54" : "\u7B49\u5F85\u786E\u8BA4";
|
|
6420
|
-
const sessionTitleRef = (0,
|
|
6421
|
-
const currentTitle = (0,
|
|
6443
|
+
const sessionTitleRef = (0, import_react6.useRef)({ at: 0, title: "" });
|
|
6444
|
+
const currentTitle = (0, import_react6.useMemo)(() => {
|
|
6422
6445
|
const c = sessionTitleRef.current;
|
|
6423
6446
|
if (typeof window === "undefined") return "";
|
|
6424
6447
|
if (Date.now() - c.at < 1e3) return c.title;
|
|
@@ -6426,19 +6449,19 @@ function AnimationOverlay(props) {
|
|
|
6426
6449
|
c.title = currentSessionTitle();
|
|
6427
6450
|
return c.title;
|
|
6428
6451
|
}, [snap.status]);
|
|
6429
|
-
const onScreenTasks = (0,
|
|
6452
|
+
const onScreenTasks = (0, import_react6.useMemo)(() => active.filter((x) => taskOnScreen(x, currentTitle)), [active, currentTitle]);
|
|
6430
6453
|
const waitingTaskOnScreen = onScreenTasks.find((x) => taskWaiting(x)) || null;
|
|
6431
6454
|
useTicker(ctx, animOn);
|
|
6432
6455
|
const now = Date.now();
|
|
6433
6456
|
const elapsed = active.length > 0 ? fmtClock(now - Math.min(...active.map((x) => x.startTime || now))) : "";
|
|
6434
|
-
const [panelOpen, setPanelOpen2] = (0,
|
|
6435
|
-
(0,
|
|
6457
|
+
const [panelOpen, setPanelOpen2] = (0, import_react6.useState)(false);
|
|
6458
|
+
(0, import_react6.useEffect)(() => {
|
|
6436
6459
|
setPanelOpen2(panelNav.open);
|
|
6437
6460
|
return subscribePanel(() => setPanelOpen2(panelNav.open));
|
|
6438
6461
|
}, []);
|
|
6439
|
-
const [speed, setSpeed] = (0,
|
|
6440
|
-
const speedRef = (0,
|
|
6441
|
-
(0,
|
|
6462
|
+
const [speed, setSpeed] = (0, import_react6.useState)(1);
|
|
6463
|
+
const speedRef = (0, import_react6.useRef)({ ticks: -1, at: 0 });
|
|
6464
|
+
(0, import_react6.useEffect)(() => {
|
|
6442
6465
|
if (!st || active.length === 0) {
|
|
6443
6466
|
speedRef.current = { ticks: -1, at: 0 };
|
|
6444
6467
|
setSpeed(1);
|
|
@@ -6464,17 +6487,17 @@ function AnimationOverlay(props) {
|
|
|
6464
6487
|
const stuckTask = onScreenTasks.find((task) => task.phase === "code" && taskStalled(task, now, 18e3)) || null;
|
|
6465
6488
|
const robotScaleFromConfig = Math.max(0.85, Math.min(2.2, Number(cfg && cfg.robotScale) || 1.35));
|
|
6466
6489
|
const speedStyle = { "--dkan-speed": Number(speed).toFixed(2) };
|
|
6467
|
-
const saveRobotScale = (0,
|
|
6490
|
+
const saveRobotScale = (0, import_react6.useCallback)((robotScale) => {
|
|
6468
6491
|
rpcCall2("config", { robotScale }).then((d) => animationStore.applyConfig(d && d.config)).catch(() => {
|
|
6469
6492
|
});
|
|
6470
6493
|
}, []);
|
|
6471
|
-
const [botPos, setBotPos] = (0,
|
|
6472
|
-
const botPosRef = (0,
|
|
6473
|
-
const botDragRef = (0,
|
|
6474
|
-
const botResizeRef = (0,
|
|
6475
|
-
const [botScaleDraft, setBotScaleDraft] = (0,
|
|
6476
|
-
const botClickBlockRef = (0,
|
|
6477
|
-
(0,
|
|
6494
|
+
const [botPos, setBotPos] = (0, import_react6.useState)(null);
|
|
6495
|
+
const botPosRef = (0, import_react6.useRef)(null);
|
|
6496
|
+
const botDragRef = (0, import_react6.useRef)(null);
|
|
6497
|
+
const botResizeRef = (0, import_react6.useRef)(null);
|
|
6498
|
+
const [botScaleDraft, setBotScaleDraft] = (0, import_react6.useState)(null);
|
|
6499
|
+
const botClickBlockRef = (0, import_react6.useRef)(false);
|
|
6500
|
+
(0, import_react6.useEffect)(() => {
|
|
6478
6501
|
try {
|
|
6479
6502
|
if (typeof localStorage === "undefined") return;
|
|
6480
6503
|
const raw = localStorage.getItem("dsh-dock/anim/robot-pos/v1");
|
|
@@ -6526,11 +6549,11 @@ function AnimationOverlay(props) {
|
|
|
6526
6549
|
}, 0);
|
|
6527
6550
|
}
|
|
6528
6551
|
};
|
|
6529
|
-
const [badgePos, setBadgePos] = (0,
|
|
6530
|
-
const badgePosRef = (0,
|
|
6531
|
-
const badgeDragRef = (0,
|
|
6532
|
-
const badgeClickBlockRef = (0,
|
|
6533
|
-
(0,
|
|
6552
|
+
const [badgePos, setBadgePos] = (0, import_react6.useState)(null);
|
|
6553
|
+
const badgePosRef = (0, import_react6.useRef)(null);
|
|
6554
|
+
const badgeDragRef = (0, import_react6.useRef)(null);
|
|
6555
|
+
const badgeClickBlockRef = (0, import_react6.useRef)(false);
|
|
6556
|
+
(0, import_react6.useEffect)(() => {
|
|
6534
6557
|
try {
|
|
6535
6558
|
if (typeof localStorage === "undefined") return;
|
|
6536
6559
|
const raw = localStorage.getItem("dsh-dock/anim/badge-pos/v1");
|
|
@@ -6590,7 +6613,7 @@ function AnimationOverlay(props) {
|
|
|
6590
6613
|
badgePosRef.current = null;
|
|
6591
6614
|
setBadgePos(null);
|
|
6592
6615
|
};
|
|
6593
|
-
const badgeClickTimer = (0,
|
|
6616
|
+
const badgeClickTimer = (0, import_react6.useRef)(null);
|
|
6594
6617
|
const onBadgeClick = () => {
|
|
6595
6618
|
if (badgeClickBlockRef.current) return;
|
|
6596
6619
|
if (badgeClickTimer.current) {
|
|
@@ -6808,11 +6831,11 @@ function ModePreview({ id }) {
|
|
|
6808
6831
|
function AnimationView(props) {
|
|
6809
6832
|
const ctx = props && props.ctx;
|
|
6810
6833
|
const snap = useAnimation(ctx);
|
|
6811
|
-
const [cfg, setCfg] = (0,
|
|
6812
|
-
const [saveErr, setSaveErr] = (0,
|
|
6813
|
-
const cfgRef = (0,
|
|
6814
|
-
const pendingSavesRef = (0,
|
|
6815
|
-
(0,
|
|
6834
|
+
const [cfg, setCfg] = (0, import_react6.useState)(null);
|
|
6835
|
+
const [saveErr, setSaveErr] = (0, import_react6.useState)("");
|
|
6836
|
+
const cfgRef = (0, import_react6.useRef)(null);
|
|
6837
|
+
const pendingSavesRef = (0, import_react6.useRef)(0);
|
|
6838
|
+
(0, import_react6.useEffect)(() => {
|
|
6816
6839
|
const c = snap.status && snap.status.config;
|
|
6817
6840
|
if (!c) return;
|
|
6818
6841
|
if (pendingSavesRef.current > 0) return;
|
|
@@ -6821,7 +6844,7 @@ function AnimationView(props) {
|
|
|
6821
6844
|
setCfg(Object.assign({}, c));
|
|
6822
6845
|
}
|
|
6823
6846
|
}, [snap.status]);
|
|
6824
|
-
(0,
|
|
6847
|
+
(0, import_react6.useEffect)(() => {
|
|
6825
6848
|
if (!animationStore.snap.status) animationStore.refresh();
|
|
6826
6849
|
}, []);
|
|
6827
6850
|
const patch = (p) => {
|
|
@@ -7296,7 +7319,7 @@ var css2 = [
|
|
|
7296
7319
|
// 减少动态时停止空间位移,保留屏幕亮暗与思考状态的淡入反馈。
|
|
7297
7320
|
"@media (prefers-reduced-motion:reduce){.dkan-amb *,.dkan-prev *,.dkan-space-system,.dkan-space-dust,.dkan-space-runner,.dkan-delivery,.dkan-departure,.dkan-freighter-engine i,.dkan-stuck-code::after,.dkan-stuck-code i{animation:none!important}.dkan-space-runner,.dkan-departure{display:none}.dkan-delivery{opacity:1;transform:translate3d(var(--dkan-to-x),var(--dkan-to-y),0)}.dkan-delivery-trail{display:none}.dk3-person,.dk3-upper3,.dk3-head3,.dk3-arm3,.dk3-elbow,.dk3-wrist3,.dk3-wheel,.dk3-code,.dk3-search-results{animation:none!important;transition:none!important}.dk3-screen,.dkan-bubble{transition:opacity .2s cubic-bezier(.23,1,.32,1)!important}}"
|
|
7298
7321
|
].join("\n");
|
|
7299
|
-
var
|
|
7322
|
+
var feature5 = {
|
|
7300
7323
|
id: "animation",
|
|
7301
7324
|
name: "\u4EFB\u52A1\u52A8\u753B",
|
|
7302
7325
|
order: 130,
|
|
@@ -7309,7 +7332,7 @@ var feature7 = {
|
|
|
7309
7332
|
};
|
|
7310
7333
|
|
|
7311
7334
|
// features/notify/view.jsx
|
|
7312
|
-
var
|
|
7335
|
+
var import_react7 = require("react");
|
|
7313
7336
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
7314
7337
|
function rpcCall3(method, args) {
|
|
7315
7338
|
return fetch("dsh-dock/notify/" + method, {
|
|
@@ -7454,8 +7477,8 @@ function voiceAllowed(cfg) {
|
|
|
7454
7477
|
return !!cfg && cfg.voiceNotify === true && voiceClientEnabled();
|
|
7455
7478
|
}
|
|
7456
7479
|
function useVoiceClientEnabled() {
|
|
7457
|
-
const [on, setOn] = (0,
|
|
7458
|
-
(0,
|
|
7480
|
+
const [on, setOn] = (0, import_react7.useState)(() => voiceClientEnabled());
|
|
7481
|
+
(0, import_react7.useEffect)(() => {
|
|
7459
7482
|
const sync = () => setOn(voiceClientEnabled());
|
|
7460
7483
|
if (typeof window === "undefined" || typeof window.addEventListener !== "function") return void 0;
|
|
7461
7484
|
window.addEventListener("storage", sync);
|
|
@@ -7463,7 +7486,7 @@ function useVoiceClientEnabled() {
|
|
|
7463
7486
|
if (typeof window.removeEventListener === "function") window.removeEventListener("storage", sync);
|
|
7464
7487
|
};
|
|
7465
7488
|
}, []);
|
|
7466
|
-
const set = (0,
|
|
7489
|
+
const set = (0, import_react7.useCallback)((next) => {
|
|
7467
7490
|
const v = next !== false;
|
|
7468
7491
|
setVoiceClientEnabled(v);
|
|
7469
7492
|
setOn(v);
|
|
@@ -7571,8 +7594,8 @@ function effectiveNotifyConfig(serverCfg) {
|
|
|
7571
7594
|
return mergeClientNotifyConfig(server, local);
|
|
7572
7595
|
}
|
|
7573
7596
|
function useNotifyConfigSource() {
|
|
7574
|
-
const [source, setSource] = (0,
|
|
7575
|
-
const set = (0,
|
|
7597
|
+
const [source, setSource] = (0, import_react7.useState)(() => notifyConfigSource());
|
|
7598
|
+
const set = (0, import_react7.useCallback)((next) => {
|
|
7576
7599
|
const value = next === "client" ? "client" : "server";
|
|
7577
7600
|
setNotifyConfigSource(value);
|
|
7578
7601
|
setSource(value);
|
|
@@ -7632,10 +7655,10 @@ function pickVoice(cfg, text) {
|
|
|
7632
7655
|
return null;
|
|
7633
7656
|
}
|
|
7634
7657
|
function useLocalVoices() {
|
|
7635
|
-
const [, force] = (0,
|
|
7636
|
-
const ref = (0,
|
|
7658
|
+
const [, force] = (0, import_react7.useState)(0);
|
|
7659
|
+
const ref = (0, import_react7.useRef)(null);
|
|
7637
7660
|
if (ref.current === null) ref.current = localVoices();
|
|
7638
|
-
(0,
|
|
7661
|
+
(0, import_react7.useEffect)(() => {
|
|
7639
7662
|
const s = synthOf();
|
|
7640
7663
|
const onChange = () => {
|
|
7641
7664
|
ref.current = localVoices();
|
|
@@ -7735,11 +7758,14 @@ function endBroadcastText(success, record, task, cfg) {
|
|
|
7735
7758
|
const mode = voiceTone(cfg);
|
|
7736
7759
|
const reason = record && record.endReason || "";
|
|
7737
7760
|
const title = record && record.title || task && task.title || "";
|
|
7761
|
+
const sub = !!(record && record.isSubtask || task && task.isSubtask);
|
|
7762
|
+
const parentTitle = record && record.parentTitle || task && task.parentTitle || "";
|
|
7738
7763
|
if (mode === "brief") {
|
|
7764
|
+
if (sub) return success ? "\u5B50\u4EFB\u52A1\u5B8C\u6210" : "\u5B50\u4EFB\u52A1\u505C\u6B62\u4E86";
|
|
7739
7765
|
return success ? "\u4EFB\u52A1\u5B8C\u6210" : "\u4EFB\u52A1\u505C\u6B62\u4E86";
|
|
7740
7766
|
}
|
|
7741
7767
|
if (mode === "medium") {
|
|
7742
|
-
const who = title ? "\u4EFB\u52A1\u300C" + truncate2(title, 30) + "\u300D" : "\u4EFB\u52A1";
|
|
7768
|
+
const who = sub ? (parentTitle ? "\u4E3B\u4EFB\u52A1\u300C" + truncate2(parentTitle, 20) + "\u300D\u7684" : "") + (title ? "\u5B50\u4EFB\u52A1\u300C" + truncate2(title, 30) + "\u300D" : "\u5B50\u4EFB\u52A1") : title ? "\u4EFB\u52A1\u300C" + truncate2(title, 30) + "\u300D" : "\u4EFB\u52A1";
|
|
7743
7769
|
const parts2 = [success ? who + "\u5B8C\u6210\u4E86" : who + "\u505C\u6B62\u4E86"];
|
|
7744
7770
|
if (!success) parts2.push("\uFF0C\u539F\u56E0\uFF1A" + endReasonSpeech(reason));
|
|
7745
7771
|
const dur2 = record && record.duration || 0;
|
|
@@ -7748,7 +7774,8 @@ function endBroadcastText(success, record, task, cfg) {
|
|
|
7748
7774
|
return parts2.join("");
|
|
7749
7775
|
}
|
|
7750
7776
|
const parts = [];
|
|
7751
|
-
if (
|
|
7777
|
+
if (sub && parentTitle) parts.push("\u4E3B\u4EFB\u52A1\uFF1A" + truncate2(parentTitle, 30) + "\u3002");
|
|
7778
|
+
if (title) parts.push((sub ? "\u5B50\u4EFB\u52A1\uFF1A" : "\u4EFB\u52A1\uFF1A") + truncate2(title, 30) + "\u3002");
|
|
7752
7779
|
parts.push(success ? "\u5DF2\u5B8C\u6210\u3002" : "\u7ED3\u675F\uFF0C\u539F\u56E0\uFF1A" + endReasonSpeech(reason) + "\u3002");
|
|
7753
7780
|
const dur = record && record.duration || 0;
|
|
7754
7781
|
if (dur > 0) parts.push("\u8017\u65F6" + fmtDur(dur) + "\u3002");
|
|
@@ -7854,8 +7881,8 @@ var notifyStore = {
|
|
|
7854
7881
|
}
|
|
7855
7882
|
};
|
|
7856
7883
|
function useNotify() {
|
|
7857
|
-
const [snap, setSnap] = (0,
|
|
7858
|
-
(0,
|
|
7884
|
+
const [snap, setSnap] = (0, import_react7.useState)(notifyStore.snap);
|
|
7885
|
+
(0, import_react7.useEffect)(() => notifyStore.subscribe(() => setSnap(notifyStore.snap)), []);
|
|
7859
7886
|
return snap;
|
|
7860
7887
|
}
|
|
7861
7888
|
function pageVisible() {
|
|
@@ -7924,19 +7951,19 @@ function openSessionByTitle(title) {
|
|
|
7924
7951
|
}
|
|
7925
7952
|
function Toast(props) {
|
|
7926
7953
|
const t = props.t;
|
|
7927
|
-
const [closing, setClosing] = (0,
|
|
7928
|
-
const close = (0,
|
|
7954
|
+
const [closing, setClosing] = (0, import_react7.useState)(!!t.closing);
|
|
7955
|
+
const close = (0, import_react7.useCallback)(() => {
|
|
7929
7956
|
setClosing(true);
|
|
7930
7957
|
}, []);
|
|
7931
|
-
const jump = (0,
|
|
7958
|
+
const jump = (0, import_react7.useCallback)(() => {
|
|
7932
7959
|
if (!t.sessionTitle && !t.sessionId) return;
|
|
7933
7960
|
const ok = openSessionById(t.sessionId) || (t.fallbackSessionId ? openSessionById(t.fallbackSessionId) : false) || (t.sessionTitle ? openSessionByTitle(t.sessionTitle) : false);
|
|
7934
7961
|
if (ok && t.kind !== "confirm" && t.kind !== "stuck") setClosing(true);
|
|
7935
7962
|
}, [t.sessionId, t.sessionTitle, t.fallbackSessionId, t.kind]);
|
|
7936
|
-
(0,
|
|
7963
|
+
(0, import_react7.useEffect)(() => {
|
|
7937
7964
|
if (t.closing && !closing) setClosing(true);
|
|
7938
7965
|
}, [t.closing, closing]);
|
|
7939
|
-
(0,
|
|
7966
|
+
(0, import_react7.useEffect)(() => {
|
|
7940
7967
|
if (!closing) return;
|
|
7941
7968
|
const timer = setTimeout(() => props.onClose(t.id), 240);
|
|
7942
7969
|
return () => clearTimeout(timer);
|
|
@@ -7977,23 +8004,23 @@ function Toast(props) {
|
|
|
7977
8004
|
function NotifyOverlay(props) {
|
|
7978
8005
|
if (props && props.ctx) overlayCtx = props.ctx;
|
|
7979
8006
|
const snap = useNotify();
|
|
7980
|
-
const [toasts, setToasts] = (0,
|
|
7981
|
-
const [stackHover, setStackHover] = (0,
|
|
7982
|
-
const prevActiveRef = (0,
|
|
7983
|
-
const remindedApprovalsRef = (0,
|
|
7984
|
-
const remindedQuestionsRef = (0,
|
|
7985
|
-
const toastSeqRef = (0,
|
|
7986
|
-
const pushToast = (0,
|
|
8007
|
+
const [toasts, setToasts] = (0, import_react7.useState)([]);
|
|
8008
|
+
const [stackHover, setStackHover] = (0, import_react7.useState)(false);
|
|
8009
|
+
const prevActiveRef = (0, import_react7.useRef)(null);
|
|
8010
|
+
const remindedApprovalsRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
8011
|
+
const remindedQuestionsRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
8012
|
+
const toastSeqRef = (0, import_react7.useRef)(0);
|
|
8013
|
+
const pushToast = (0, import_react7.useCallback)((toast) => {
|
|
7987
8014
|
const st = notifyStore.snap.status;
|
|
7988
8015
|
const cfg = st ? effectiveNotifyConfig(st.config) : null;
|
|
7989
8016
|
if (cfg && cfg.notifyCards === false) return;
|
|
7990
8017
|
setToasts((prev) => prev.concat([toast]).slice(-12));
|
|
7991
8018
|
}, []);
|
|
7992
|
-
(0,
|
|
8019
|
+
(0, import_react7.useEffect)(() => {
|
|
7993
8020
|
const cfg = snap.status ? effectiveNotifyConfig(snap.status.config) : null;
|
|
7994
8021
|
if (cfg && cfg.notifyCards === false) setToasts((prev) => prev.length ? [] : prev);
|
|
7995
8022
|
}, [snap.status]);
|
|
7996
|
-
(0,
|
|
8023
|
+
(0, import_react7.useEffect)(() => {
|
|
7997
8024
|
let stopped = false;
|
|
7998
8025
|
let timer = null;
|
|
7999
8026
|
const loop = async () => {
|
|
@@ -8013,7 +8040,7 @@ function NotifyOverlay(props) {
|
|
|
8013
8040
|
document.removeEventListener("visibilitychange", onVisible);
|
|
8014
8041
|
};
|
|
8015
8042
|
}, []);
|
|
8016
|
-
(0,
|
|
8043
|
+
(0, import_react7.useEffect)(() => {
|
|
8017
8044
|
const st = snap.status;
|
|
8018
8045
|
if (!st || !st.active) return;
|
|
8019
8046
|
const prev = prevActiveRef.current;
|
|
@@ -8027,7 +8054,7 @@ function NotifyOverlay(props) {
|
|
|
8027
8054
|
}
|
|
8028
8055
|
prevActiveRef.current = st.active.slice();
|
|
8029
8056
|
}, [snap.status]);
|
|
8030
|
-
(0,
|
|
8057
|
+
(0, import_react7.useEffect)(() => {
|
|
8031
8058
|
const st = snap.status;
|
|
8032
8059
|
if (!st || !st.active) return;
|
|
8033
8060
|
const cfg = effectiveNotifyConfig(st.config || {});
|
|
@@ -8087,7 +8114,7 @@ function NotifyOverlay(props) {
|
|
|
8087
8114
|
}
|
|
8088
8115
|
}
|
|
8089
8116
|
}, [snap.status]);
|
|
8090
|
-
(0,
|
|
8117
|
+
(0, import_react7.useEffect)(() => {
|
|
8091
8118
|
const st = snap.status;
|
|
8092
8119
|
if (!st || !st.active) return;
|
|
8093
8120
|
const cfg = effectiveNotifyConfig(st.config || {});
|
|
@@ -8142,7 +8169,7 @@ function NotifyOverlay(props) {
|
|
|
8142
8169
|
}
|
|
8143
8170
|
}
|
|
8144
8171
|
}, [snap.status]);
|
|
8145
|
-
(0,
|
|
8172
|
+
(0, import_react7.useEffect)(() => {
|
|
8146
8173
|
const st = snap.status;
|
|
8147
8174
|
if (!st || !st.active) return;
|
|
8148
8175
|
const live = /* @__PURE__ */ new Set();
|
|
@@ -8162,7 +8189,7 @@ function NotifyOverlay(props) {
|
|
|
8162
8189
|
return changed ? next : prev;
|
|
8163
8190
|
});
|
|
8164
8191
|
}, [snap.status]);
|
|
8165
|
-
(0,
|
|
8192
|
+
(0, import_react7.useEffect)(() => {
|
|
8166
8193
|
const timer = setInterval(() => {
|
|
8167
8194
|
if (!pageVisible()) return;
|
|
8168
8195
|
const cur = currentSelectedSession();
|
|
@@ -8182,8 +8209,8 @@ function NotifyOverlay(props) {
|
|
|
8182
8209
|
}, 500);
|
|
8183
8210
|
return () => clearInterval(timer);
|
|
8184
8211
|
}, []);
|
|
8185
|
-
const stuckSeenRef = (0,
|
|
8186
|
-
(0,
|
|
8212
|
+
const stuckSeenRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
8213
|
+
(0, import_react7.useEffect)(() => {
|
|
8187
8214
|
const st = snap.status;
|
|
8188
8215
|
if (!st || !st.active) return;
|
|
8189
8216
|
const cfg = effectiveNotifyConfig(st.config || {});
|
|
@@ -8239,7 +8266,7 @@ function NotifyOverlay(props) {
|
|
|
8239
8266
|
});
|
|
8240
8267
|
}
|
|
8241
8268
|
}, [snap.status]);
|
|
8242
|
-
(0,
|
|
8269
|
+
(0, import_react7.useEffect)(() => {
|
|
8243
8270
|
const st = snap.status;
|
|
8244
8271
|
if (!st || !st.active) return;
|
|
8245
8272
|
const byId = new Map(st.active.map((x) => [x.sessionId, x]));
|
|
@@ -8261,22 +8288,31 @@ function NotifyOverlay(props) {
|
|
|
8261
8288
|
const success = isSuccessReason2(reason);
|
|
8262
8289
|
const info = endInfo(reason);
|
|
8263
8290
|
const event = success ? "complete" : "error";
|
|
8291
|
+
const sub = !!(record && record.isSubtask || task.isSubtask);
|
|
8292
|
+
const parentId = record && record.parentSessionId || task.parentSessionId || "";
|
|
8293
|
+
let parentTitle = record && record.parentTitle || task.parentTitle || "";
|
|
8294
|
+
if (sub && !parentTitle && parentId) {
|
|
8295
|
+
const p = (snap.status && snap.status.active || []).find((x) => x.sessionId === parentId);
|
|
8296
|
+
if (p && p.title) parentTitle = p.title;
|
|
8297
|
+
}
|
|
8298
|
+
const endRecord = Object.assign({}, record || {}, { isSubtask: sub, parentTitle });
|
|
8264
8299
|
const cardWanted = eventEnabled(cfg, "card", event);
|
|
8265
8300
|
const soundWanted = cfg.soundNotify !== false && eventEnabled(cfg, "sound", event);
|
|
8266
8301
|
const systemWanted = !!cfg.systemNotify && eventEnabled(cfg, "system", event);
|
|
8267
8302
|
if (voiceAllowed(cfg) && eventEnabled(cfg, "voice", event)) {
|
|
8268
|
-
speakVoice(endBroadcastText(success,
|
|
8303
|
+
speakVoice(endBroadcastText(success, endRecord, task, cfg), cfg);
|
|
8269
8304
|
}
|
|
8270
8305
|
const models = record && record.models && record.models.length ? record.models.join(", ") : task.models && task.models.length ? task.models.join(", ") : "\u672A\u77E5\u6A21\u578B";
|
|
8271
8306
|
const provider = record && record.provider || task.provider || "";
|
|
8272
8307
|
const startTs = record && record.startTime || task.startTime;
|
|
8273
8308
|
const endTs = record && record.endTime || Date.now();
|
|
8274
8309
|
const durText = fmtDur(record && record.duration || endTs - startTs);
|
|
8275
|
-
const title = success ? "\u4EFB\u52A1\u5B8C\u6210" : "\u4EFB\u52A1" + info.label;
|
|
8310
|
+
const title = success ? sub ? "\u5B50\u4EFB\u52A1\u5B8C\u6210" : "\u4EFB\u52A1\u5B8C\u6210" : (sub ? "\u5B50\u4EFB\u52A1" : "\u4EFB\u52A1") + info.label;
|
|
8276
8311
|
const showTitle = record && record.title || task.title || "(\u65E0\u6807\u9898)";
|
|
8277
8312
|
if (cardWanted) {
|
|
8278
8313
|
const tone = cardTone(cfg);
|
|
8279
|
-
const lines = ["\u4EFB\u52A1\uFF1A" + showTitle];
|
|
8314
|
+
const lines = [(sub ? "\u5B50\u4EFB\u52A1\uFF1A" : "\u4EFB\u52A1\uFF1A") + showTitle];
|
|
8315
|
+
if (sub) lines.push("\u4E3B\u4EFB\u52A1\uFF1A" + (parentTitle || "\uFF08\u672A\u77E5\uFF09"));
|
|
8280
8316
|
if (tone !== "brief") lines.push("\u6A21\u578B\uFF1A" + models + (provider ? "\uFF08" + provider + "\uFF09" : ""));
|
|
8281
8317
|
lines.push(tone === "brief" ? "\u8017\u65F6\uFF1A" + durText : "\u8017\u65F6\uFF1A" + durText + "\uFF08" + fmtTime2(startTs) + " \u2192 " + fmtTime2(endTs) + "\uFF09");
|
|
8282
8318
|
if (tone === "detailed") {
|
|
@@ -8294,14 +8330,16 @@ function NotifyOverlay(props) {
|
|
|
8294
8330
|
// 看到了结果,巡检 effect 据此自动收起卡片。没看过就一直挂着。
|
|
8295
8331
|
// sessionId 是权威标识(跳转/对账都用它),标题只作旧宿主回退。
|
|
8296
8332
|
sessionId: task.sessionId || "",
|
|
8297
|
-
sessionTitle: showTitle
|
|
8333
|
+
sessionTitle: showTitle,
|
|
8334
|
+
// 子任务会话通常不在侧栏里:跳不到自己时回退到父会话(与卡住卡同款)
|
|
8335
|
+
fallbackSessionId: sub && parentId ? parentId : ""
|
|
8298
8336
|
});
|
|
8299
8337
|
}
|
|
8300
8338
|
if (soundWanted) playDoneSound(success, cfg.soundEffect);
|
|
8301
8339
|
if (systemWanted && typeof document !== "undefined" && document.hidden && typeof Notification !== "undefined" && Notification.permission === "granted") {
|
|
8302
8340
|
try {
|
|
8303
8341
|
new Notification("dsh " + title, {
|
|
8304
|
-
body: showTitle + " \xB7 " + durText,
|
|
8342
|
+
body: (sub ? (parentTitle ? "\u4E3B\u4EFB\u52A1\u300C" + truncate2(parentTitle, 20) + "\u300D\u7684" : "") + "\u5B50\u4EFB\u52A1\u300C" + showTitle + "\u300D" : showTitle) + " \xB7 " + durText,
|
|
8305
8343
|
tag: "dsh-dock-notify-" + task.sessionId
|
|
8306
8344
|
});
|
|
8307
8345
|
} catch {
|
|
@@ -8435,20 +8473,20 @@ function NotifyView(props) {
|
|
|
8435
8473
|
const voices = useLocalVoices();
|
|
8436
8474
|
const [voiceClientOn, setVoiceClientOn] = useVoiceClientEnabled();
|
|
8437
8475
|
const [source, setSource] = useNotifyConfigSource();
|
|
8438
|
-
const [tab, setTab] = (0,
|
|
8439
|
-
const [clientCfg, setClientCfg] = (0,
|
|
8440
|
-
const [serverDraft, setServerDraft] = (0,
|
|
8441
|
-
const [saveErr, setSaveErr] = (0,
|
|
8442
|
-
const [testing, setTesting] = (0,
|
|
8443
|
-
const [testState, setTestState] = (0,
|
|
8444
|
-
const [feishuTesting, setFeishuTesting] = (0,
|
|
8445
|
-
const [feishuTestState, setFeishuTestState] = (0,
|
|
8446
|
-
const cfgRef = (0,
|
|
8447
|
-
const pendingSavesRef = (0,
|
|
8448
|
-
const editingWebhookRef = (0,
|
|
8449
|
-
const editingFeishuRef = (0,
|
|
8476
|
+
const [tab, setTab] = (0, import_react7.useState)("events");
|
|
8477
|
+
const [clientCfg, setClientCfg] = (0, import_react7.useState)(() => readClientNotifyConfig());
|
|
8478
|
+
const [serverDraft, setServerDraft] = (0, import_react7.useState)(null);
|
|
8479
|
+
const [saveErr, setSaveErr] = (0, import_react7.useState)("");
|
|
8480
|
+
const [testing, setTesting] = (0, import_react7.useState)(false);
|
|
8481
|
+
const [testState, setTestState] = (0, import_react7.useState)(null);
|
|
8482
|
+
const [feishuTesting, setFeishuTesting] = (0, import_react7.useState)(false);
|
|
8483
|
+
const [feishuTestState, setFeishuTestState] = (0, import_react7.useState)(null);
|
|
8484
|
+
const cfgRef = (0, import_react7.useRef)(null);
|
|
8485
|
+
const pendingSavesRef = (0, import_react7.useRef)(0);
|
|
8486
|
+
const editingWebhookRef = (0, import_react7.useRef)(false);
|
|
8487
|
+
const editingFeishuRef = (0, import_react7.useRef)(false);
|
|
8450
8488
|
const serverCfg = snap.status && snap.status.config;
|
|
8451
|
-
(0,
|
|
8489
|
+
(0, import_react7.useEffect)(() => {
|
|
8452
8490
|
if (!serverCfg) return;
|
|
8453
8491
|
if (pendingSavesRef.current > 0 || editingWebhookRef.current || editingFeishuRef.current) return;
|
|
8454
8492
|
if (serverCfg !== cfgRef.current) {
|
|
@@ -8456,13 +8494,13 @@ function NotifyView(props) {
|
|
|
8456
8494
|
setServerDraft(Object.assign({}, serverCfg));
|
|
8457
8495
|
}
|
|
8458
8496
|
}, [snap.status]);
|
|
8459
|
-
(0,
|
|
8497
|
+
(0, import_react7.useEffect)(() => {
|
|
8460
8498
|
if (source !== "client" || clientCfg || !serverCfg) return;
|
|
8461
8499
|
const clone = pickClientConfig(serverCfg);
|
|
8462
8500
|
writeClientNotifyConfig(clone);
|
|
8463
8501
|
setClientCfg(clone);
|
|
8464
8502
|
}, [source, clientCfg, serverCfg]);
|
|
8465
|
-
(0,
|
|
8503
|
+
(0, import_react7.useEffect)(() => {
|
|
8466
8504
|
if (!notifyStore.snap.status) notifyStore.refresh();
|
|
8467
8505
|
}, []);
|
|
8468
8506
|
const cfg = source === "client" ? clientCfg ? mergeClientNotifyConfig(serverCfg, clientCfg) : null : serverDraft || serverCfg;
|
|
@@ -8669,7 +8707,7 @@ function NotifyView(props) {
|
|
|
8669
8707
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dknt-row", children: [
|
|
8670
8708
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-label", children: "\u6B63\u6587\u53E3\u5F84" }),
|
|
8671
8709
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModePicker, { value: cardTone(cfg), title: "\u9875\u5185\u5361\u7247\u6B63\u6587", onChange: (v) => patch({ cardMode: v }) }),
|
|
8672
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-sub", children: "\u7B80\u6D01\uFF1D\u4EFB\u52A1\u4E0E\u8017\u65F6 / \u8C01\u5361\u4F4F\uFF1B\u9002\u4E2D\uFF1D\u52A0\u6A21\u578B\u3001\u8D77\u6B62\u65F6\u95F4\u3001\u505C\u6EDE\u65F6\u957F\uFF1B\u8BE6\u7EC6\uFF1D\u5168\u90E8\uFF08\u56DE\u5408\u6B65\u9AA4\u3001Token\u3001\u6458\u8981\u6216\u9519\u8BEF\u3001\u6700\u540E\u52A8\u4F5C\uFF09" })
|
|
8710
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-sub", children: "\u7B80\u6D01\uFF1D\u4EFB\u52A1\u4E0E\u8017\u65F6 / \u8C01\u5361\u4F4F\uFF1B\u9002\u4E2D\uFF1D\u52A0\u6A21\u578B\u3001\u8D77\u6B62\u65F6\u95F4\u3001\u505C\u6EDE\u65F6\u957F\uFF1B\u8BE6\u7EC6\uFF1D\u5168\u90E8\uFF08\u56DE\u5408\u6B65\u9AA4\u3001Token\u3001\u6458\u8981\u6216\u9519\u8BEF\u3001\u6700\u540E\u52A8\u4F5C\uFF09\u3002\u5B50\u4EFB\u52A1\u7ED3\u675F\u6807\u300C\u5B50\u4EFB\u52A1\u300D\u5E76\u70B9\u540D\u4E3B\u4EFB\u52A1\uFF08\u4E09\u6321\u90FD\u5E26\u5F52\u5C5E\uFF09" })
|
|
8673
8711
|
] }),
|
|
8674
8712
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dknt-row", children: [
|
|
8675
8713
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-label", children: "\u5361\u7247\u6536\u7EB3" }),
|
|
@@ -8818,7 +8856,7 @@ function NotifyView(props) {
|
|
|
8818
8856
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dknt-row", children: [
|
|
8819
8857
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-label", children: "\u64AD\u62A5\u53E3\u5F84" }),
|
|
8820
8858
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModePicker, { value: voiceTone(cfg), title: "\u8BED\u97F3\u64AD\u62A5", onChange: (v) => patch({ voiceMode: v }) }),
|
|
8821
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-sub", children: "\u7B80\u6D01\uFF1A\u4E00\u53E5\u300C\u4EFB\u52A1\u5B8C\u6210 / \u4EFB\u52A1\u505C\u6B62\u4E86 / \u4EFB\u52A1\u9700\u8981\u6388\u6743 / \u4E3B\u4EFB\u52A1\uFF08\u6216\u5B50\u4EFB\u52A1\uFF09\xB7\u6807\u9898 \u5361\u4F4F\u4E86\u300D\uFF1B\u9002\u4E2D\uFF1A\u70B9\u540D\u4EFB\u52A1\uFF0C\u7ED3\u675F\u5E26\u539F\u56E0\u4E0E\u8017\u65F6\u3001\u5361\u4F4F\u5E26\u505C\u6EDE\u65F6\u957F\uFF1B\u8BE6\u7EC6\uFF1A\u7ED3\u675F\u5E26\u56DE\u5408\u7EDF\u8BA1\u4E0E\u56DE\u590D\u6458\u8981\uFF0C\u9700\u6388\u6743\u5E26\u5DE5\u5177\u540D\uFF0C\u5361\u4F4F\u5E26\u6700\u540E\u52A8\u4F5C\u3002" })
|
|
8859
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-sub", children: "\u7B80\u6D01\uFF1A\u4E00\u53E5\u300C\u4EFB\u52A1\u5B8C\u6210 / \u5B50\u4EFB\u52A1\u5B8C\u6210 / \u4EFB\u52A1\u505C\u6B62\u4E86 / \u4EFB\u52A1\u9700\u8981\u6388\u6743 / \u4E3B\u4EFB\u52A1\uFF08\u6216\u5B50\u4EFB\u52A1\uFF09\xB7\u6807\u9898 \u5361\u4F4F\u4E86\u300D\uFF1B\u9002\u4E2D\uFF1A\u70B9\u540D\u4EFB\u52A1\uFF08\u5B50\u4EFB\u52A1\u8FDE\u4E3B\u4EFB\u52A1\u4E00\u8D77\u70B9\u540D\uFF09\uFF0C\u7ED3\u675F\u5E26\u539F\u56E0\u4E0E\u8017\u65F6\u3001\u5361\u4F4F\u5E26\u505C\u6EDE\u65F6\u957F\uFF1B\u8BE6\u7EC6\uFF1A\u7ED3\u675F\u5E26\u56DE\u5408\u7EDF\u8BA1\u4E0E\u56DE\u590D\u6458\u8981\uFF0C\u9700\u6388\u6743\u5E26\u5DE5\u5177\u540D\uFF0C\u5361\u4F4F\u5E26\u6700\u540E\u52A8\u4F5C\u3002" })
|
|
8822
8860
|
] }),
|
|
8823
8861
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dknt-row", children: [
|
|
8824
8862
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-label", children: "\u64AD\u62A5\u4E8B\u4EF6" }),
|
|
@@ -8978,7 +9016,7 @@ function NotifyView(props) {
|
|
|
8978
9016
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dknt-row", children: [
|
|
8979
9017
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-label", children: "\u6D88\u606F\u53E3\u5F84" }),
|
|
8980
9018
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModePicker, { value: cfg.pushMode || "detailed", title: "\u9489\u9489\u6D88\u606F", onChange: (v) => patch({ pushMode: v }) }),
|
|
8981
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-sub", children: "\u7B80\u6D01\uFF1D\u4EFB\u52A1\u4E0E\u7ED3\u679C\uFF1B\u9002\u4E2D\uFF1D\u52A0\u6A21\u578B/\u8017\u65F6\uFF1B\u8BE6\u7EC6\uFF1D\u518D\u52A0\u56DE\u5408\u3001Token \u4E0E\u6458\u8981\u3002" })
|
|
9019
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-sub", children: "\u7B80\u6D01\uFF1D\u4EFB\u52A1\u4E0E\u7ED3\u679C\uFF1B\u9002\u4E2D\uFF1D\u52A0\u6A21\u578B/\u8017\u65F6\uFF1B\u8BE6\u7EC6\uFF1D\u518D\u52A0\u56DE\u5408\u3001Token \u4E0E\u6458\u8981\u3002\u5B50\u4EFB\u52A1\u7ED3\u675F\u6807\u300C\u5B50\u4EFB\u52A1\u300D\u5E76\u70B9\u540D\u4E3B\u4EFB\u52A1\uFF08\u4E09\u6321\u90FD\u5E26\u5F52\u5C5E\uFF09\u3002" })
|
|
8982
9020
|
] }),
|
|
8983
9021
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dknt-row dknt-row-webhook", children: [
|
|
8984
9022
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-label", children: "Webhook" }),
|
|
@@ -9046,7 +9084,7 @@ function NotifyView(props) {
|
|
|
9046
9084
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dknt-row", children: [
|
|
9047
9085
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-label", children: "\u6D88\u606F\u53E3\u5F84" }),
|
|
9048
9086
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ModePicker, { value: cfg.pushMode || "detailed", title: "\u98DE\u4E66\u6D88\u606F", onChange: (v) => patch({ pushMode: v }) }),
|
|
9049
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-sub", children: "\u7B80\u6D01\uFF1D\u4EFB\u52A1\u4E0E\u7ED3\u679C\uFF1B\u9002\u4E2D\uFF1D\u52A0\u6A21\u578B/\u8017\u65F6\uFF1B\u8BE6\u7EC6\uFF1D\u518D\u52A0\u56DE\u5408\u3001Token \u4E0E\u6458\u8981\u3002" })
|
|
9087
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-sub", children: "\u7B80\u6D01\uFF1D\u4EFB\u52A1\u4E0E\u7ED3\u679C\uFF1B\u9002\u4E2D\uFF1D\u52A0\u6A21\u578B/\u8017\u65F6\uFF1B\u8BE6\u7EC6\uFF1D\u518D\u52A0\u56DE\u5408\u3001Token \u4E0E\u6458\u8981\u3002\u5B50\u4EFB\u52A1\u7ED3\u675F\u6807\u300C\u5B50\u4EFB\u52A1\u300D\u5E76\u70B9\u540D\u4E3B\u4EFB\u52A1\uFF08\u4E09\u6321\u90FD\u5E26\u5F52\u5C5E\uFF09\u3002" })
|
|
9050
9088
|
] }),
|
|
9051
9089
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "dknt-row dknt-row-webhook", children: [
|
|
9052
9090
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "dknt-row-label", children: "Webhook" }),
|
|
@@ -9216,7 +9254,7 @@ var css3 = [
|
|
|
9216
9254
|
".dknt-btn:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
9217
9255
|
".dknt-btn[disabled]{opacity:.5;cursor:default;}"
|
|
9218
9256
|
].join("\n");
|
|
9219
|
-
var
|
|
9257
|
+
var feature6 = {
|
|
9220
9258
|
id: "notify",
|
|
9221
9259
|
name: "\u4EFB\u52A1\u901A\u77E5",
|
|
9222
9260
|
order: 140,
|
|
@@ -9229,7 +9267,7 @@ var feature8 = {
|
|
|
9229
9267
|
};
|
|
9230
9268
|
|
|
9231
9269
|
// features/runstate/view.jsx
|
|
9232
|
-
var
|
|
9270
|
+
var import_react8 = require("react");
|
|
9233
9271
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
9234
9272
|
function rpcCall4(method, args) {
|
|
9235
9273
|
return fetch("dsh-dock/runstate/" + method, {
|
|
@@ -9316,8 +9354,8 @@ var runStateStore = {
|
|
|
9316
9354
|
}
|
|
9317
9355
|
};
|
|
9318
9356
|
function useRunState() {
|
|
9319
|
-
const [snap, setSnap] = (0,
|
|
9320
|
-
(0,
|
|
9357
|
+
const [snap, setSnap] = (0, import_react8.useState)(runStateStore.snap);
|
|
9358
|
+
(0, import_react8.useEffect)(() => runStateStore.subscribe(() => setSnap(runStateStore.snap)), []);
|
|
9321
9359
|
return snap;
|
|
9322
9360
|
}
|
|
9323
9361
|
function waitingOf(active) {
|
|
@@ -9356,7 +9394,7 @@ function RunStateView() {
|
|
|
9356
9394
|
const waitApprovals = (active || []).reduce((n, t) => n + taskApprovals(t).length, 0);
|
|
9357
9395
|
const waitQuestions = (active || []).reduce((n, t) => n + taskQuestions(t).length, 0);
|
|
9358
9396
|
const waitBannerHint = waitApprovals > 0 && waitQuestions > 0 ? waitApprovals + " \u9879\u7B49\u6279\u51C6\u3001" + waitQuestions + " \u9879\u7B49\u4F60\u56DE\u7B54" : waitApprovals > 0 ? "\u4EFB\u52A1\u505C\u5728\u9700\u8981\u4F60\u6279\u51C6\u7684\u6B65\u9AA4\u4E0A" : "\u4EFB\u52A1\u5728\u7B49\u4F60\u56DE\u7B54\u95EE\u9898";
|
|
9359
|
-
(0,
|
|
9397
|
+
(0, import_react8.useEffect)(() => {
|
|
9360
9398
|
let stopped = false;
|
|
9361
9399
|
let timer = null;
|
|
9362
9400
|
const loop = async () => {
|
|
@@ -9397,7 +9435,7 @@ function RunStateView() {
|
|
|
9397
9435
|
}
|
|
9398
9436
|
function RunStateStat(props) {
|
|
9399
9437
|
const snap = useRunState();
|
|
9400
|
-
(0,
|
|
9438
|
+
(0, import_react8.useEffect)(() => {
|
|
9401
9439
|
if (!runStateStore.snap.status) runStateStore.refresh();
|
|
9402
9440
|
}, []);
|
|
9403
9441
|
const st = snap.status;
|
|
@@ -9448,7 +9486,7 @@ var css4 = [
|
|
|
9448
9486
|
".dkrs-tag.err{color:var(--dsw-alias-state-error-primary);border-color:currentColor;}",
|
|
9449
9487
|
".dkrs-tag.warn{color:var(--dk-warn);border-color:currentColor;}"
|
|
9450
9488
|
].join("\n");
|
|
9451
|
-
var
|
|
9489
|
+
var feature7 = {
|
|
9452
9490
|
id: "runstate",
|
|
9453
9491
|
name: "\u8FD0\u884C\u72B6\u6001",
|
|
9454
9492
|
order: 150,
|
|
@@ -9460,7 +9498,7 @@ var feature9 = {
|
|
|
9460
9498
|
};
|
|
9461
9499
|
|
|
9462
9500
|
// features/tts/view.jsx
|
|
9463
|
-
var
|
|
9501
|
+
var import_react9 = __toESM(require("react"), 1);
|
|
9464
9502
|
function synth() {
|
|
9465
9503
|
try {
|
|
9466
9504
|
const g = typeof globalThis !== "undefined" ? globalThis : null;
|
|
@@ -9560,8 +9598,8 @@ function subscribeConfig(fn) {
|
|
|
9560
9598
|
};
|
|
9561
9599
|
}
|
|
9562
9600
|
function useConfig() {
|
|
9563
|
-
const [, force] = (0,
|
|
9564
|
-
(0,
|
|
9601
|
+
const [, force] = (0, import_react9.useState)(0);
|
|
9602
|
+
(0, import_react9.useEffect)(() => subscribeConfig(() => force((n) => n + 1)), []);
|
|
9565
9603
|
return configStore.value;
|
|
9566
9604
|
}
|
|
9567
9605
|
var HOST_SAVE_DEBOUNCE_MS = 400;
|
|
@@ -9782,8 +9820,8 @@ function subscribeEngine(fn) {
|
|
|
9782
9820
|
};
|
|
9783
9821
|
}
|
|
9784
9822
|
function useEngineState() {
|
|
9785
|
-
const [snap, setSnap] = (0,
|
|
9786
|
-
(0,
|
|
9823
|
+
const [snap, setSnap] = (0, import_react9.useState)(engineSnapshot());
|
|
9824
|
+
(0, import_react9.useEffect)(() => subscribeEngine(() => setSnap(engineSnapshot())), []);
|
|
9787
9825
|
return snap;
|
|
9788
9826
|
}
|
|
9789
9827
|
function setEngineState(next) {
|
|
@@ -9962,7 +10000,7 @@ function closingMarkdown(owner) {
|
|
|
9962
10000
|
for (const b of blocks) if (b && b.kind === "text" && typeof b.text === "string") parts.push(b.text);
|
|
9963
10001
|
return parts.join("");
|
|
9964
10002
|
}
|
|
9965
|
-
var ICON_SPEAKER =
|
|
10003
|
+
var ICON_SPEAKER = import_react9.default.createElement(
|
|
9966
10004
|
"svg",
|
|
9967
10005
|
{
|
|
9968
10006
|
viewBox: "0 0 24 24",
|
|
@@ -9973,11 +10011,11 @@ var ICON_SPEAKER = import_react12.default.createElement(
|
|
|
9973
10011
|
strokeLinejoin: "round",
|
|
9974
10012
|
"aria-hidden": "true"
|
|
9975
10013
|
},
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
10014
|
+
import_react9.default.createElement("path", { d: "M11 5 6 9H3v6h3l5 4z" }),
|
|
10015
|
+
import_react9.default.createElement("path", { d: "M15.5 8.5a5 5 0 0 1 0 7" }),
|
|
10016
|
+
import_react9.default.createElement("path", { d: "M18.5 5.5a9 9 0 0 1 0 13" })
|
|
9979
10017
|
);
|
|
9980
|
-
var ICON_PAUSE =
|
|
10018
|
+
var ICON_PAUSE = import_react9.default.createElement(
|
|
9981
10019
|
"svg",
|
|
9982
10020
|
{
|
|
9983
10021
|
viewBox: "0 0 24 24",
|
|
@@ -9987,10 +10025,10 @@ var ICON_PAUSE = import_react12.default.createElement(
|
|
|
9987
10025
|
strokeLinecap: "round",
|
|
9988
10026
|
"aria-hidden": "true"
|
|
9989
10027
|
},
|
|
9990
|
-
|
|
9991
|
-
|
|
10028
|
+
import_react9.default.createElement("path", { d: "M9 6v12" }),
|
|
10029
|
+
import_react9.default.createElement("path", { d: "M15 6v12" })
|
|
9992
10030
|
);
|
|
9993
|
-
var ICON_RESUME =
|
|
10031
|
+
var ICON_RESUME = import_react9.default.createElement(
|
|
9994
10032
|
"svg",
|
|
9995
10033
|
{
|
|
9996
10034
|
viewBox: "0 0 24 24",
|
|
@@ -10001,9 +10039,9 @@ var ICON_RESUME = import_react12.default.createElement(
|
|
|
10001
10039
|
strokeLinejoin: "round",
|
|
10002
10040
|
"aria-hidden": "true"
|
|
10003
10041
|
},
|
|
10004
|
-
|
|
10042
|
+
import_react9.default.createElement("path", { d: "M8 5.5v13l11-6.5z" })
|
|
10005
10043
|
);
|
|
10006
|
-
var ICON_RESTART =
|
|
10044
|
+
var ICON_RESTART = import_react9.default.createElement(
|
|
10007
10045
|
"svg",
|
|
10008
10046
|
{
|
|
10009
10047
|
viewBox: "0 0 24 24",
|
|
@@ -10014,11 +10052,11 @@ var ICON_RESTART = import_react12.default.createElement(
|
|
|
10014
10052
|
strokeLinejoin: "round",
|
|
10015
10053
|
"aria-hidden": "true"
|
|
10016
10054
|
},
|
|
10017
|
-
|
|
10018
|
-
|
|
10019
|
-
|
|
10055
|
+
import_react9.default.createElement("path", { d: "M3.5 8.5V4.5" }),
|
|
10056
|
+
import_react9.default.createElement("path", { d: "M3.5 8.5h4" }),
|
|
10057
|
+
import_react9.default.createElement("path", { d: "M5.6 5.1a8.5 8.5 0 1 1-2.1 5.4" })
|
|
10020
10058
|
);
|
|
10021
|
-
var ICON_STOP =
|
|
10059
|
+
var ICON_STOP = import_react9.default.createElement(
|
|
10022
10060
|
"svg",
|
|
10023
10061
|
{
|
|
10024
10062
|
viewBox: "0 0 24 24",
|
|
@@ -10028,9 +10066,9 @@ var ICON_STOP = import_react12.default.createElement(
|
|
|
10028
10066
|
strokeLinejoin: "round",
|
|
10029
10067
|
"aria-hidden": "true"
|
|
10030
10068
|
},
|
|
10031
|
-
|
|
10069
|
+
import_react9.default.createElement("rect", { x: "6.5", y: "6.5", width: "11", height: "11", rx: "2" })
|
|
10032
10070
|
);
|
|
10033
|
-
var ICON_GEAR =
|
|
10071
|
+
var ICON_GEAR = import_react9.default.createElement(
|
|
10034
10072
|
"svg",
|
|
10035
10073
|
{
|
|
10036
10074
|
viewBox: "0 0 24 24",
|
|
@@ -10041,14 +10079,14 @@ var ICON_GEAR = import_react12.default.createElement(
|
|
|
10041
10079
|
strokeLinejoin: "round",
|
|
10042
10080
|
"aria-hidden": "true"
|
|
10043
10081
|
},
|
|
10044
|
-
|
|
10045
|
-
|
|
10082
|
+
import_react9.default.createElement("circle", { cx: "12", cy: "12", r: "3.2" }),
|
|
10083
|
+
import_react9.default.createElement("path", { d: "M12 2.8v3M12 18.2v3M2.8 12h3M18.2 12h3M5.5 5.5l2.1 2.1M16.4 16.4l2.1 2.1M18.5 5.5l-2.1 2.1M7.6 16.4l-2.1 2.1" })
|
|
10046
10084
|
);
|
|
10047
10085
|
function TtsQuickPop(props) {
|
|
10048
10086
|
const cfg = useConfig();
|
|
10049
10087
|
const anchor = props.anchor || { x: 120, y: 120 };
|
|
10050
|
-
const boxRef = (0,
|
|
10051
|
-
(0,
|
|
10088
|
+
const boxRef = (0, import_react9.useRef)(null);
|
|
10089
|
+
(0, import_react9.useEffect)(() => {
|
|
10052
10090
|
if (typeof document === "undefined") return void 0;
|
|
10053
10091
|
const onDown = (e) => {
|
|
10054
10092
|
if (boxRef.current && !boxRef.current.contains(e.target)) props.onClose();
|
|
@@ -10066,7 +10104,7 @@ function TtsQuickPop(props) {
|
|
|
10066
10104
|
const vw = typeof globalThis !== "undefined" && globalThis.innerWidth ? globalThis.innerWidth : 1440;
|
|
10067
10105
|
const left = Math.max(8, Math.min(anchor.x - 4, vw - 256));
|
|
10068
10106
|
const portalTarget = typeof document !== "undefined" && document.body ? document.body : null;
|
|
10069
|
-
const pop =
|
|
10107
|
+
const pop = import_react9.default.createElement(
|
|
10070
10108
|
"div",
|
|
10071
10109
|
{
|
|
10072
10110
|
ref: boxRef,
|
|
@@ -10075,11 +10113,11 @@ function TtsQuickPop(props) {
|
|
|
10075
10113
|
role: "dialog",
|
|
10076
10114
|
"aria-label": "\u6717\u8BFB\u5FEB\u901F\u8BBE\u7F6E"
|
|
10077
10115
|
},
|
|
10078
|
-
|
|
10116
|
+
import_react9.default.createElement(
|
|
10079
10117
|
"div",
|
|
10080
10118
|
{ className: "dktts-pop-h" },
|
|
10081
|
-
|
|
10082
|
-
|
|
10119
|
+
import_react9.default.createElement("b", null, "\u6717\u8BFB\u8BBE\u7F6E"),
|
|
10120
|
+
import_react9.default.createElement("button", {
|
|
10083
10121
|
type: "button",
|
|
10084
10122
|
className: "dktts-pop-x",
|
|
10085
10123
|
"aria-label": "\u5173\u95ED",
|
|
@@ -10087,11 +10125,11 @@ function TtsQuickPop(props) {
|
|
|
10087
10125
|
onClick: props.onClose
|
|
10088
10126
|
}, "\u2715")
|
|
10089
10127
|
),
|
|
10090
|
-
|
|
10128
|
+
import_react9.default.createElement(
|
|
10091
10129
|
"div",
|
|
10092
10130
|
{ className: "dktts-pop-row" },
|
|
10093
|
-
|
|
10094
|
-
|
|
10131
|
+
import_react9.default.createElement("span", null, "\u8BED\u901F"),
|
|
10132
|
+
import_react9.default.createElement("input", {
|
|
10095
10133
|
type: "range",
|
|
10096
10134
|
min: "0.5",
|
|
10097
10135
|
max: "2",
|
|
@@ -10100,13 +10138,13 @@ function TtsQuickPop(props) {
|
|
|
10100
10138
|
"aria-label": "\u8BED\u901F",
|
|
10101
10139
|
onChange: (e) => setConfig({ rate: Number(e.target.value) || 1 })
|
|
10102
10140
|
}),
|
|
10103
|
-
|
|
10141
|
+
import_react9.default.createElement("span", { className: "dktts-pop-val" }, cfg.rate.toFixed(2) + "\xD7")
|
|
10104
10142
|
),
|
|
10105
|
-
|
|
10143
|
+
import_react9.default.createElement(
|
|
10106
10144
|
"div",
|
|
10107
10145
|
{ className: "dktts-pop-row" },
|
|
10108
|
-
|
|
10109
|
-
|
|
10146
|
+
import_react9.default.createElement("span", null, "\u97F3\u91CF"),
|
|
10147
|
+
import_react9.default.createElement("input", {
|
|
10110
10148
|
type: "range",
|
|
10111
10149
|
min: "0",
|
|
10112
10150
|
max: "1",
|
|
@@ -10115,13 +10153,13 @@ function TtsQuickPop(props) {
|
|
|
10115
10153
|
"aria-label": "\u97F3\u91CF",
|
|
10116
10154
|
onChange: (e) => setConfig({ volume: Number(e.target.value) })
|
|
10117
10155
|
}),
|
|
10118
|
-
|
|
10156
|
+
import_react9.default.createElement("span", { className: "dktts-pop-val" }, Math.round(cfg.volume * 100) + "%")
|
|
10119
10157
|
),
|
|
10120
|
-
|
|
10158
|
+
import_react9.default.createElement(
|
|
10121
10159
|
"div",
|
|
10122
10160
|
{ className: "dktts-pop-foot" },
|
|
10123
|
-
|
|
10124
|
-
|
|
10161
|
+
import_react9.default.createElement("span", { className: "dktts-pop-tip" }, "\u4E0B\u4E00\u53E5\u8D77\u751F\u6548"),
|
|
10162
|
+
import_react9.default.createElement("button", {
|
|
10125
10163
|
type: "button",
|
|
10126
10164
|
className: "dktts-pop-more",
|
|
10127
10165
|
onClick: () => {
|
|
@@ -10131,7 +10169,7 @@ function TtsQuickPop(props) {
|
|
|
10131
10169
|
}, "\u66F4\u591A\u8BBE\u7F6E \u2192")
|
|
10132
10170
|
)
|
|
10133
10171
|
);
|
|
10134
|
-
return portalTarget && typeof
|
|
10172
|
+
return portalTarget && typeof import_react9.default.createPortal === "function" ? import_react9.default.createPortal(pop, portalTarget) : pop;
|
|
10135
10173
|
}
|
|
10136
10174
|
var AUTO_PLAY_FRESH_MS = 8e3;
|
|
10137
10175
|
var BAD_END = { error: 1, aborted: 1, blocked: 1, "max-tokens": 1, interrupted: 1 };
|
|
@@ -10161,7 +10199,7 @@ function TtsTurnTail(props) {
|
|
|
10161
10199
|
const active = hasText && eng.phase !== "idle" && eng.key === key;
|
|
10162
10200
|
const paused = active && eng.phase === "paused";
|
|
10163
10201
|
const playing = active && eng.phase === "playing";
|
|
10164
|
-
(0,
|
|
10202
|
+
(0, import_react9.useEffect)(() => {
|
|
10165
10203
|
ensureConfigLoaded();
|
|
10166
10204
|
}, []);
|
|
10167
10205
|
const startThis = () => {
|
|
@@ -10169,9 +10207,9 @@ function TtsTurnTail(props) {
|
|
|
10169
10207
|
const plain = capSpeechText(plainForSpeech(md, configStore.value), configStore.value);
|
|
10170
10208
|
speak({ key, text: plain, cfg: configStore.value, label: "\u7B2C " + (turnNo + 1) + " \u56DE\u5408" });
|
|
10171
10209
|
};
|
|
10172
|
-
const autoDoneRef = (0,
|
|
10173
|
-
const [quick, setQuick] = (0,
|
|
10174
|
-
(0,
|
|
10210
|
+
const autoDoneRef = (0, import_react9.useRef)(false);
|
|
10211
|
+
const [quick, setQuick] = (0, import_react9.useState)(null);
|
|
10212
|
+
(0, import_react9.useEffect)(() => {
|
|
10175
10213
|
if (autoDoneRef.current) return;
|
|
10176
10214
|
autoDoneRef.current = true;
|
|
10177
10215
|
if (!hasText || !supported) return;
|
|
@@ -10219,10 +10257,10 @@ function TtsTurnTail(props) {
|
|
|
10219
10257
|
ensureConfigLoaded();
|
|
10220
10258
|
setQuick(rect2 ? { x: rect2.left, y: rect2.bottom } : { x: 120, y: 120 });
|
|
10221
10259
|
};
|
|
10222
|
-
return
|
|
10260
|
+
return import_react9.default.createElement(
|
|
10223
10261
|
"div",
|
|
10224
10262
|
{ className: "dktts-tail" },
|
|
10225
|
-
|
|
10263
|
+
import_react9.default.createElement("button", {
|
|
10226
10264
|
type: "button",
|
|
10227
10265
|
className: "dktts-btn" + (active ? " on" : "") + (supported ? "" : " off"),
|
|
10228
10266
|
"aria-label": mainTitle,
|
|
@@ -10230,7 +10268,7 @@ function TtsTurnTail(props) {
|
|
|
10230
10268
|
title: mainTitle,
|
|
10231
10269
|
onClick: onMain
|
|
10232
10270
|
}, playing ? ICON_PAUSE : paused ? ICON_RESUME : ICON_SPEAKER),
|
|
10233
|
-
active ?
|
|
10271
|
+
active ? import_react9.default.createElement("button", {
|
|
10234
10272
|
type: "button",
|
|
10235
10273
|
className: "dktts-btn",
|
|
10236
10274
|
"aria-label": "\u91CD\u65B0\u6717\u8BFB",
|
|
@@ -10239,7 +10277,7 @@ function TtsTurnTail(props) {
|
|
|
10239
10277
|
restartSpeech();
|
|
10240
10278
|
}
|
|
10241
10279
|
}, ICON_RESTART) : null,
|
|
10242
|
-
active ?
|
|
10280
|
+
active ? import_react9.default.createElement("button", {
|
|
10243
10281
|
type: "button",
|
|
10244
10282
|
className: "dktts-btn",
|
|
10245
10283
|
"aria-label": "\u505C\u6B62",
|
|
@@ -10248,7 +10286,7 @@ function TtsTurnTail(props) {
|
|
|
10248
10286
|
stopSpeech();
|
|
10249
10287
|
}
|
|
10250
10288
|
}, ICON_STOP) : null,
|
|
10251
|
-
|
|
10289
|
+
import_react9.default.createElement("button", {
|
|
10252
10290
|
type: "button",
|
|
10253
10291
|
className: "dktts-btn" + (quick ? " on" : ""),
|
|
10254
10292
|
"aria-label": "\u6717\u8BFB\u8BBE\u7F6E\uFF08\u8BED\u901F / \u97F3\u91CF\uFF09",
|
|
@@ -10256,22 +10294,22 @@ function TtsTurnTail(props) {
|
|
|
10256
10294
|
title: "\u6717\u8BFB\u8BBE\u7F6E\uFF08\u8BED\u901F / \u97F3\u91CF\uFF09",
|
|
10257
10295
|
onClick: openQuick
|
|
10258
10296
|
}, ICON_GEAR),
|
|
10259
|
-
|
|
10297
|
+
import_react9.default.createElement(
|
|
10260
10298
|
"span",
|
|
10261
10299
|
{ className: "dktts-state" + (active ? " on" : "") },
|
|
10262
10300
|
playing ? "\u6B63\u5728\u6717\u8BFB\u672C\u56DE\u5408" : paused ? "\u5DF2\u6682\u505C \xB7 \u70B9 \u25B6 \u7EE7\u7EED\uFF0C\u4E0D\u91CD\u5934" : ""
|
|
10263
10301
|
),
|
|
10264
|
-
quick ?
|
|
10302
|
+
quick ? import_react9.default.createElement(TtsQuickPop, { anchor: quick, onClose: () => setQuick(null) }) : null
|
|
10265
10303
|
);
|
|
10266
10304
|
}
|
|
10267
10305
|
function TtsOverlay() {
|
|
10268
10306
|
const cfg = useConfig();
|
|
10269
|
-
const seenRef = (0,
|
|
10270
|
-
const primedRef = (0,
|
|
10271
|
-
(0,
|
|
10307
|
+
const seenRef = (0, import_react9.useRef)(null);
|
|
10308
|
+
const primedRef = (0, import_react9.useRef)(false);
|
|
10309
|
+
(0, import_react9.useEffect)(() => {
|
|
10272
10310
|
ensureConfigLoaded();
|
|
10273
10311
|
}, []);
|
|
10274
|
-
(0,
|
|
10312
|
+
(0, import_react9.useEffect)(() => {
|
|
10275
10313
|
if (!cfg.autoPlay) return void 0;
|
|
10276
10314
|
if (!ttsSupported()) return void 0;
|
|
10277
10315
|
if (seenRef.current === null) seenRef.current = /* @__PURE__ */ new Set();
|
|
@@ -10334,17 +10372,17 @@ function TtsOverlay() {
|
|
|
10334
10372
|
return null;
|
|
10335
10373
|
}
|
|
10336
10374
|
function TtsRow(props) {
|
|
10337
|
-
return
|
|
10375
|
+
return import_react9.default.createElement(
|
|
10338
10376
|
"div",
|
|
10339
10377
|
{ className: "dktts-row" },
|
|
10340
|
-
|
|
10341
|
-
|
|
10342
|
-
props.note ?
|
|
10378
|
+
import_react9.default.createElement("span", { className: "dktts-label" }, props.label),
|
|
10379
|
+
import_react9.default.createElement("span", { className: "dktts-ctl" }, props.children),
|
|
10380
|
+
props.note ? import_react9.default.createElement("span", { className: "dktts-note" }, props.note) : null
|
|
10343
10381
|
);
|
|
10344
10382
|
}
|
|
10345
10383
|
function TtsSwitch(props) {
|
|
10346
10384
|
const on = props.value === true;
|
|
10347
|
-
return
|
|
10385
|
+
return import_react9.default.createElement(
|
|
10348
10386
|
"button",
|
|
10349
10387
|
{
|
|
10350
10388
|
type: "button",
|
|
@@ -10355,17 +10393,17 @@ function TtsSwitch(props) {
|
|
|
10355
10393
|
title: on ? "\u5DF2\u542F\u7528\uFF08\u70B9\u51FB\u505C\u7528\uFF09" : "\u5DF2\u505C\u7528\uFF08\u70B9\u51FB\u542F\u7528\uFF09",
|
|
10356
10394
|
onClick: () => props.onChange(!on)
|
|
10357
10395
|
},
|
|
10358
|
-
|
|
10396
|
+
import_react9.default.createElement("span", { className: "dktts-sw-dot" }),
|
|
10359
10397
|
on ? "\u542F\u7528" : "\u505C\u7528"
|
|
10360
10398
|
);
|
|
10361
10399
|
}
|
|
10362
10400
|
function TtsView() {
|
|
10363
10401
|
const cfg = useConfig();
|
|
10364
10402
|
const eng = useEngineState();
|
|
10365
|
-
const [, force] = (0,
|
|
10366
|
-
const [saved, setSaved] = (0,
|
|
10367
|
-
const voices = (0,
|
|
10368
|
-
(0,
|
|
10403
|
+
const [, force] = (0, import_react9.useState)(0);
|
|
10404
|
+
const [saved, setSaved] = (0, import_react9.useState)("");
|
|
10405
|
+
const voices = (0, import_react9.useRef)(localVoices2());
|
|
10406
|
+
(0, import_react9.useEffect)(() => {
|
|
10369
10407
|
ensureConfigLoaded();
|
|
10370
10408
|
const s = synth();
|
|
10371
10409
|
if (!s || typeof s.addEventListener !== "function") return;
|
|
@@ -10385,7 +10423,7 @@ function TtsView() {
|
|
|
10385
10423
|
}
|
|
10386
10424
|
};
|
|
10387
10425
|
}, []);
|
|
10388
|
-
(0,
|
|
10426
|
+
(0, import_react9.useEffect)(() => {
|
|
10389
10427
|
if (voices.current.length === 0) {
|
|
10390
10428
|
voices.current = localVoices2();
|
|
10391
10429
|
force((n) => n + 1);
|
|
@@ -10422,101 +10460,101 @@ function TtsView() {
|
|
|
10422
10460
|
if (zh.length) grouped.push(["\u4E2D\u6587\u97F3\u8272", zh]);
|
|
10423
10461
|
if (other.length) grouped.push(["\u5176\u4ED6\u97F3\u8272", other]);
|
|
10424
10462
|
}
|
|
10425
|
-
return
|
|
10463
|
+
return import_react9.default.createElement(
|
|
10426
10464
|
"div",
|
|
10427
10465
|
{ className: "dktts-root" },
|
|
10428
|
-
|
|
10466
|
+
import_react9.default.createElement(
|
|
10429
10467
|
"div",
|
|
10430
10468
|
{ className: "dktts-intro" },
|
|
10431
10469
|
"\u773C\u775B\u4E0D\u8212\u670D\u65F6\u8BA9 dsh \u628A\u56DE\u590D\u8BFB\u51FA\u6765\u3002\u7528\u7684\u662F",
|
|
10432
|
-
|
|
10470
|
+
import_react9.default.createElement("b", null, "\u6D4F\u89C8\u5668\u81EA\u5E26\u7684\u8BED\u97F3\u5408\u6210"),
|
|
10433
10471
|
"\uFF08Web Speech API\uFF09\uFF0C\u58F0\u97F3\u4ECE\u4F60\u5F53\u524D\u8FD9\u53F0\u8BBE\u5907\u7684\u626C\u58F0\u5668\u51FA\u6765\uFF0C\u4E0D\u6D88\u8017 token\u3001\u4E0D\u7ECF\u8FC7\u670D\u52A1\u5668\u3002",
|
|
10434
10472
|
"\u6BCF\u6761\u56DE\u590D\u4E0B\u65B9\u4F1A\u51FA\u73B0\u4E00\u4E2A",
|
|
10435
|
-
|
|
10473
|
+
import_react9.default.createElement("b", null, " \u{1F50A} \u5587\u53ED"),
|
|
10436
10474
|
"\uFF0C\u70B9\u4E00\u4E0B\u5C31\u8BFB\u8FD9\u6761\uFF1B\u4E5F\u53EF\u4EE5\u6253\u5F00\u300C\u81EA\u52A8\u6717\u8BFB\u300D\uFF0C\u56DE\u5408\u7ED3\u675F\u540E\u76F4\u63A5\u8BFB\u6700\u540E\u4E00\u6761\u56DE\u590D\u3002"
|
|
10437
10475
|
),
|
|
10438
|
-
!supported ?
|
|
10476
|
+
!supported ? import_react9.default.createElement(
|
|
10439
10477
|
"div",
|
|
10440
10478
|
{ className: "dktts-warn" },
|
|
10441
10479
|
"\u8FD9\u4E2A\u6D4F\u89C8\u5668\u4E0D\u63D0\u4F9B\u8BED\u97F3\u5408\u6210\u80FD\u529B\uFF08speechSynthesis \u4E0D\u53EF\u7528\uFF09\u3002\u6362 Chrome / Edge / Safari \u5373\u53EF\uFF1BLinux \u4E0A\u7684 Chromium \u9700\u8981\u88C5\u8BED\u97F3\u5305\uFF08\u5982 espeak-ng\uFF09\uFF0C\u6216\u5728\u7CFB\u7EDF\u8BBE\u7F6E\u91CC\u6DFB\u52A0\u8BED\u97F3\u3002"
|
|
10442
10480
|
) : null,
|
|
10443
|
-
supported && list.length === 0 ?
|
|
10481
|
+
supported && list.length === 0 ? import_react9.default.createElement(
|
|
10444
10482
|
"div",
|
|
10445
10483
|
{ className: "dktts-warn" },
|
|
10446
10484
|
"\u672C\u673A\u6682\u65F6\u8BFB\u4E0D\u5230\u4EFB\u4F55\u97F3\u8272\u3002\u901A\u5E38\u662F\u7CFB\u7EDF\u8FD8\u6CA1\u88C5/\u6CA1\u542F\u7528\u8BED\u97F3\uFF1AWindows \u5230\u300C\u8BBE\u7F6E \u2192 \u65F6\u95F4\u548C\u8BED\u8A00 \u2192 \u8BED\u97F3\u300D\u6DFB\u52A0\u4E2D\u6587\u8BED\u97F3\uFF0CmacOS \u5230\u300C\u7CFB\u7EDF\u8BBE\u7F6E \u2192 \u65E0\u969C\u788D \u2192 \u6717\u8BFB\u5185\u5BB9\u300D\u6DFB\u52A0\u97F3\u8272\uFF0C\u7136\u540E\u5237\u65B0\u9875\u9762\u3002"
|
|
10447
10485
|
) : null,
|
|
10448
|
-
|
|
10486
|
+
import_react9.default.createElement(
|
|
10449
10487
|
"div",
|
|
10450
10488
|
{ className: "dktts-card" },
|
|
10451
|
-
|
|
10452
|
-
|
|
10489
|
+
import_react9.default.createElement("div", { className: "dktts-card-h" }, "\u6717\u8BFB\u65F6\u673A"),
|
|
10490
|
+
import_react9.default.createElement(TtsRow, {
|
|
10453
10491
|
label: "\u81EA\u52A8\u6717\u8BFB",
|
|
10454
10492
|
note: "\u56DE\u5408\u7ED3\u675F\u540E\u81EA\u52A8\u8BFB\u6700\u540E\u4E00\u6761\u56DE\u590D\uFF1B\u4F60\u6B63\u5728\u770B\u7684\u8FD9\u6761\u4F1A\u8BDD\u624D\u8BFB\uFF0C\u540E\u53F0\u4F1A\u8BDD\u4E0D\u8BFB\u3002"
|
|
10455
|
-
},
|
|
10493
|
+
}, import_react9.default.createElement(TtsSwitch, {
|
|
10456
10494
|
label: "\u81EA\u52A8\u6717\u8BFB",
|
|
10457
10495
|
value: cfg.autoPlay,
|
|
10458
10496
|
onChange: (v) => patch({ autoPlay: v })
|
|
10459
10497
|
})),
|
|
10460
|
-
|
|
10498
|
+
import_react9.default.createElement(TtsRow, {
|
|
10461
10499
|
label: "\u51FA\u9519 / \u4E2D\u6B62\u4E5F\u8BFB",
|
|
10462
10500
|
note: "\u5173\u95ED\u540E\u53EA\u5728\u6B63\u5E38\u5B8C\u6210\u65F6\u8BFB\u3002"
|
|
10463
|
-
},
|
|
10501
|
+
}, import_react9.default.createElement(TtsSwitch, {
|
|
10464
10502
|
label: "\u51FA\u9519\u4E5F\u8BFB",
|
|
10465
10503
|
value: cfg.autoPlayOnFinish,
|
|
10466
10504
|
onChange: (v) => patch({ autoPlayOnFinish: v })
|
|
10467
10505
|
})),
|
|
10468
|
-
|
|
10506
|
+
import_react9.default.createElement(TtsRow, {
|
|
10469
10507
|
label: "\u65B0\u5185\u5BB9\u6253\u65AD\u5F53\u524D\u6717\u8BFB",
|
|
10470
10508
|
note: "\u5173\u95ED\u5219\u6392\u961F\uFF1A\u65B0\u7684\u90A3\u6761\u7B49\u5F53\u524D\u8BFB\u5B8C\u518D\u8BFB\uFF08\u53EA\u4FDD\u7559\u6700\u65B0\u4E00\u6761\uFF09\u3002"
|
|
10471
|
-
},
|
|
10509
|
+
}, import_react9.default.createElement(TtsSwitch, {
|
|
10472
10510
|
label: "\u6253\u65AD",
|
|
10473
10511
|
value: cfg.interruptOnNew,
|
|
10474
10512
|
onChange: (v) => patch({ interruptOnNew: v })
|
|
10475
10513
|
}))
|
|
10476
10514
|
),
|
|
10477
|
-
|
|
10515
|
+
import_react9.default.createElement(
|
|
10478
10516
|
"div",
|
|
10479
10517
|
{ className: "dktts-card" },
|
|
10480
|
-
|
|
10481
|
-
|
|
10518
|
+
import_react9.default.createElement("div", { className: "dktts-card-h" }, "\u58F0\u97F3"),
|
|
10519
|
+
import_react9.default.createElement(
|
|
10482
10520
|
TtsRow,
|
|
10483
10521
|
{ label: "\u97F3\u8272", note: "\u97F3\u8272\u662F\u672C\u673A\u6D4F\u89C8\u5668\u7ED9\u7684\uFF0C\u6362\u8BBE\u5907\u53EF\u80FD\u8981\u91CD\u9009\u3002" },
|
|
10484
|
-
|
|
10522
|
+
import_react9.default.createElement(
|
|
10485
10523
|
"select",
|
|
10486
10524
|
{
|
|
10487
10525
|
className: "dktts-select",
|
|
10488
10526
|
value: cfg.voiceURI,
|
|
10489
10527
|
onChange: (e) => patch({ voiceURI: e.target.value })
|
|
10490
10528
|
},
|
|
10491
|
-
|
|
10492
|
-
grouped.map(([gname, vs]) =>
|
|
10529
|
+
import_react9.default.createElement("option", { value: "" }, "\u81EA\u52A8\uFF08\u6309\u8BED\u8A00\u6311\uFF09"),
|
|
10530
|
+
grouped.map(([gname, vs]) => import_react9.default.createElement(
|
|
10493
10531
|
"optgroup",
|
|
10494
10532
|
{ key: gname, label: gname },
|
|
10495
|
-
vs.map((v) =>
|
|
10533
|
+
vs.map((v) => import_react9.default.createElement("option", {
|
|
10496
10534
|
key: v.voiceURI,
|
|
10497
10535
|
value: v.voiceURI
|
|
10498
10536
|
}, (v.name || v.voiceURI) + "\uFF08" + (v.lang || "?") + "\uFF09"))
|
|
10499
10537
|
))
|
|
10500
10538
|
)
|
|
10501
10539
|
),
|
|
10502
|
-
|
|
10540
|
+
import_react9.default.createElement(
|
|
10503
10541
|
TtsRow,
|
|
10504
10542
|
{ label: "\u5F3A\u5236\u8BED\u8A00", note: "\u7559\u7A7A\u5219\u4E2D\u6587\u6587\u672C\u4F18\u5148\u6311\u4E2D\u6587\u97F3\u8272\u3002" },
|
|
10505
|
-
|
|
10543
|
+
import_react9.default.createElement(
|
|
10506
10544
|
"select",
|
|
10507
10545
|
{
|
|
10508
10546
|
className: "dktts-select",
|
|
10509
10547
|
value: cfg.lang,
|
|
10510
10548
|
onChange: (e) => patch({ lang: e.target.value })
|
|
10511
10549
|
},
|
|
10512
|
-
|
|
10513
|
-
["zh-CN", "zh-TW", "en-US", "en-GB", "ja-JP", "ko-KR"].map((l) =>
|
|
10550
|
+
import_react9.default.createElement("option", { value: "" }, "\u81EA\u52A8"),
|
|
10551
|
+
["zh-CN", "zh-TW", "en-US", "en-GB", "ja-JP", "ko-KR"].map((l) => import_react9.default.createElement("option", {
|
|
10514
10552
|
key: l,
|
|
10515
10553
|
value: l
|
|
10516
10554
|
}, l))
|
|
10517
10555
|
)
|
|
10518
10556
|
),
|
|
10519
|
-
|
|
10557
|
+
import_react9.default.createElement(TtsSlider, {
|
|
10520
10558
|
label: "\u8BED\u901F",
|
|
10521
10559
|
suffix: cfg.rate.toFixed(2) + "\xD7",
|
|
10522
10560
|
min: "0.5",
|
|
@@ -10526,7 +10564,7 @@ function TtsView() {
|
|
|
10526
10564
|
aria: "\u8BED\u901F",
|
|
10527
10565
|
onChange: (v) => patch({ rate: v })
|
|
10528
10566
|
}),
|
|
10529
|
-
|
|
10567
|
+
import_react9.default.createElement(TtsSlider, {
|
|
10530
10568
|
label: "\u97F3\u8C03",
|
|
10531
10569
|
suffix: cfg.pitch.toFixed(2),
|
|
10532
10570
|
min: "0",
|
|
@@ -10536,7 +10574,7 @@ function TtsView() {
|
|
|
10536
10574
|
aria: "\u97F3\u8C03",
|
|
10537
10575
|
onChange: (v) => patch({ pitch: v })
|
|
10538
10576
|
}),
|
|
10539
|
-
|
|
10577
|
+
import_react9.default.createElement(TtsSlider, {
|
|
10540
10578
|
label: "\u97F3\u91CF",
|
|
10541
10579
|
suffix: Math.round(cfg.volume * 100) + "%",
|
|
10542
10580
|
min: "0",
|
|
@@ -10547,24 +10585,24 @@ function TtsView() {
|
|
|
10547
10585
|
onChange: (v) => patch({ volume: v })
|
|
10548
10586
|
})
|
|
10549
10587
|
),
|
|
10550
|
-
|
|
10588
|
+
import_react9.default.createElement(
|
|
10551
10589
|
"div",
|
|
10552
10590
|
{ className: "dktts-card" },
|
|
10553
|
-
|
|
10554
|
-
|
|
10591
|
+
import_react9.default.createElement("div", { className: "dktts-card-h" }, "\u5FF5\u4EC0\u4E48\uFF08\u56DE\u590D\u6B63\u6587\u7684\u6E05\u6D17\uFF09"),
|
|
10592
|
+
import_react9.default.createElement(
|
|
10555
10593
|
TtsRow,
|
|
10556
10594
|
{ label: "\u8DF3\u8FC7\u4EE3\u7801\u5757", note: "\u5173\u95ED\u5219\u8FDE\u4EE3\u7801\u4E00\u8D77\u5FF5\uFF08\u53EA\u53BB\u7B26\u53F7\uFF09\u3002" },
|
|
10557
|
-
|
|
10595
|
+
import_react9.default.createElement(TtsSwitch, { label: "\u8DF3\u8FC7\u4EE3\u7801\u5757", value: cfg.skipCode, onChange: (v) => patch({ skipCode: v }) })
|
|
10558
10596
|
),
|
|
10559
|
-
|
|
10597
|
+
import_react9.default.createElement(
|
|
10560
10598
|
TtsRow,
|
|
10561
10599
|
{ label: "\u8DF3\u8FC7\u8868\u683C", note: "\u8868\u683C\u9010\u683C\u5FF5\u51FA\u6765\u6CA1\u6709\u610F\u4E49\uFF0C\u9ED8\u8BA4\u8DF3\u8FC7\u3002" },
|
|
10562
|
-
|
|
10600
|
+
import_react9.default.createElement(TtsSwitch, { label: "\u8DF3\u8FC7\u8868\u683C", value: cfg.skipTables, onChange: (v) => patch({ skipTables: v }) })
|
|
10563
10601
|
),
|
|
10564
|
-
|
|
10602
|
+
import_react9.default.createElement(
|
|
10565
10603
|
TtsRow,
|
|
10566
10604
|
{ label: "\u53EA\u8BFB\u524D N \u53E5", note: "0 = \u4E0D\u9650\u3002\u60F3\u53EA\u542C\u7ED3\u8BBA\u65F6\u8BBE 3~5 \u53E5\u3002" },
|
|
10567
|
-
|
|
10605
|
+
import_react9.default.createElement("input", {
|
|
10568
10606
|
type: "number",
|
|
10569
10607
|
className: "dktts-num",
|
|
10570
10608
|
min: "0",
|
|
@@ -10575,10 +10613,10 @@ function TtsView() {
|
|
|
10575
10613
|
onChange: (e) => patch({ maxSentences: Math.max(0, Math.round(Number(e.target.value) || 0)) })
|
|
10576
10614
|
})
|
|
10577
10615
|
),
|
|
10578
|
-
|
|
10616
|
+
import_react9.default.createElement(
|
|
10579
10617
|
TtsRow,
|
|
10580
10618
|
{ label: "\u5B57\u6570\u4E0A\u9650", note: "0 = \u4E0D\u9650\uFF1B\u8D85\u51FA\u90E8\u5206\u5FF5\u300C\u4EE5\u4E0B\u7565\u300D\u3002" },
|
|
10581
|
-
|
|
10619
|
+
import_react9.default.createElement("input", {
|
|
10582
10620
|
type: "number",
|
|
10583
10621
|
className: "dktts-num",
|
|
10584
10622
|
min: "0",
|
|
@@ -10591,20 +10629,20 @@ function TtsView() {
|
|
|
10591
10629
|
)
|
|
10592
10630
|
),
|
|
10593
10631
|
// —— 播放控制:试听 + 正在读时的 暂停/继续 · 重新朗读 · 停止 ——
|
|
10594
|
-
|
|
10632
|
+
import_react9.default.createElement(
|
|
10595
10633
|
"div",
|
|
10596
10634
|
{ className: "dktts-card" },
|
|
10597
|
-
|
|
10598
|
-
|
|
10635
|
+
import_react9.default.createElement("div", { className: "dktts-card-h" }, "\u64AD\u653E\u63A7\u5236"),
|
|
10636
|
+
import_react9.default.createElement(
|
|
10599
10637
|
"div",
|
|
10600
10638
|
{ className: "dktts-transport" },
|
|
10601
|
-
|
|
10639
|
+
import_react9.default.createElement("button", {
|
|
10602
10640
|
type: "button",
|
|
10603
10641
|
className: "dktts-primary",
|
|
10604
10642
|
onClick: preview,
|
|
10605
10643
|
disabled: !supported
|
|
10606
10644
|
}, "\u8BD5\u542C"),
|
|
10607
|
-
active ?
|
|
10645
|
+
active ? import_react9.default.createElement("button", {
|
|
10608
10646
|
type: "button",
|
|
10609
10647
|
className: "dktts-ghost",
|
|
10610
10648
|
onClick: () => {
|
|
@@ -10612,38 +10650,38 @@ function TtsView() {
|
|
|
10612
10650
|
else resumeSpeech();
|
|
10613
10651
|
}
|
|
10614
10652
|
}, playing ? "\u6682\u505C" : "\u7EE7\u7EED") : null,
|
|
10615
|
-
active ?
|
|
10653
|
+
active ? import_react9.default.createElement("button", {
|
|
10616
10654
|
type: "button",
|
|
10617
10655
|
className: "dktts-ghost",
|
|
10618
10656
|
onClick: () => {
|
|
10619
10657
|
restartSpeech();
|
|
10620
10658
|
}
|
|
10621
10659
|
}, "\u91CD\u65B0\u6717\u8BFB") : null,
|
|
10622
|
-
active ?
|
|
10660
|
+
active ? import_react9.default.createElement("button", {
|
|
10623
10661
|
type: "button",
|
|
10624
10662
|
className: "dktts-ghost",
|
|
10625
10663
|
onClick: () => {
|
|
10626
10664
|
stopSpeech();
|
|
10627
10665
|
}
|
|
10628
10666
|
}, "\u505C\u6B62") : null,
|
|
10629
|
-
|
|
10667
|
+
import_react9.default.createElement(
|
|
10630
10668
|
"span",
|
|
10631
10669
|
{ className: "dktts-playing" },
|
|
10632
10670
|
playing ? "\u6B63\u5728\u6717\u8BFB\uFF1A" + (eng.label || "\u5185\u5BB9") : paused ? "\u5DF2\u6682\u505C\uFF1A" + (eng.label || "\u5185\u5BB9") + "\uFF08\u70B9\u300C\u7EE7\u7EED\u300D\u4E0D\u91CD\u5934\uFF09" : saved ? "\u2713 " + saved : "\u3000"
|
|
10633
10671
|
)
|
|
10634
10672
|
)
|
|
10635
10673
|
),
|
|
10636
|
-
|
|
10674
|
+
import_react9.default.createElement(
|
|
10637
10675
|
"div",
|
|
10638
10676
|
{ className: "dktts-note-line" },
|
|
10639
10677
|
"\u63D0\u793A\uFF1A\u6D4F\u89C8\u5668\u8981\u6C42\u300C\u5148\u6709\u7528\u6237\u624B\u52BF\u624D\u5141\u8BB8\u51FA\u58F0\u300D\u3002\u521A\u6253\u5F00\u9875\u9762\u5C31\u81EA\u52A8\u6717\u8BFB\u53EF\u80FD\u88AB\u6D4F\u89C8\u5668\u62E6\u6389\u2014\u2014",
|
|
10640
10678
|
"\u70B9\u4E00\u4E0B\u9875\u9762\u4E0A\u4EFB\u610F\u4F4D\u7F6E\uFF0C\u6216\u76F4\u63A5\u7528\u56DE\u590D\u4E0B\u65B9\u7684\u5587\u53ED\u6309\u94AE\u3002"
|
|
10641
10679
|
),
|
|
10642
|
-
configStore.note ?
|
|
10643
|
-
configStore.routeGone ?
|
|
10680
|
+
configStore.note ? import_react9.default.createElement("div", { className: "dktts-warn" }, configStore.note) : null,
|
|
10681
|
+
configStore.routeGone ? import_react9.default.createElement(
|
|
10644
10682
|
"div",
|
|
10645
10683
|
{ className: "dktts-links" },
|
|
10646
|
-
|
|
10684
|
+
import_react9.default.createElement("button", {
|
|
10647
10685
|
type: "button",
|
|
10648
10686
|
className: "dktts-ghost",
|
|
10649
10687
|
onClick: () => {
|
|
@@ -10657,14 +10695,14 @@ function TtsView() {
|
|
|
10657
10695
|
);
|
|
10658
10696
|
}
|
|
10659
10697
|
function TtsSlider(props) {
|
|
10660
|
-
return
|
|
10698
|
+
return import_react9.default.createElement(
|
|
10661
10699
|
"div",
|
|
10662
10700
|
{ className: "dktts-row" },
|
|
10663
|
-
|
|
10664
|
-
|
|
10701
|
+
import_react9.default.createElement("span", { className: "dktts-label" }, props.label),
|
|
10702
|
+
import_react9.default.createElement(
|
|
10665
10703
|
"span",
|
|
10666
10704
|
{ className: "dktts-slider" },
|
|
10667
|
-
|
|
10705
|
+
import_react9.default.createElement("input", {
|
|
10668
10706
|
type: "range",
|
|
10669
10707
|
min: props.min,
|
|
10670
10708
|
max: props.max,
|
|
@@ -10673,17 +10711,17 @@ function TtsSlider(props) {
|
|
|
10673
10711
|
"aria-label": props.aria,
|
|
10674
10712
|
onChange: (e) => props.onChange(Number(e.target.value))
|
|
10675
10713
|
}),
|
|
10676
|
-
|
|
10714
|
+
import_react9.default.createElement("span", { className: "dktts-slider-val" }, props.suffix)
|
|
10677
10715
|
),
|
|
10678
10716
|
null
|
|
10679
10717
|
);
|
|
10680
10718
|
}
|
|
10681
10719
|
function TtsStat() {
|
|
10682
10720
|
const cfg = useConfig();
|
|
10683
|
-
(0,
|
|
10721
|
+
(0, import_react9.useEffect)(() => {
|
|
10684
10722
|
ensureConfigLoaded();
|
|
10685
10723
|
}, []);
|
|
10686
|
-
return
|
|
10724
|
+
return import_react9.default.createElement(
|
|
10687
10725
|
"span",
|
|
10688
10726
|
null,
|
|
10689
10727
|
"\u81EA\u52A8\u6717\u8BFB\uFF1A",
|
|
@@ -10753,7 +10791,7 @@ var CSS = [
|
|
|
10753
10791
|
".dktts-pop-more{border:none;background:transparent;color:var(--dk-accent);cursor:pointer;font-size:12px;padding:2px 0;}",
|
|
10754
10792
|
".dktts-pop-more:hover{text-decoration:underline;}"
|
|
10755
10793
|
].join("\n");
|
|
10756
|
-
var
|
|
10794
|
+
var feature8 = {
|
|
10757
10795
|
id: "tts",
|
|
10758
10796
|
name: "\u8BED\u97F3\u6717\u8BFB",
|
|
10759
10797
|
order: 160,
|
|
@@ -10770,10 +10808,10 @@ var feature10 = {
|
|
|
10770
10808
|
};
|
|
10771
10809
|
|
|
10772
10810
|
// features/games/view.jsx
|
|
10773
|
-
var
|
|
10811
|
+
var import_react19 = require("react");
|
|
10774
10812
|
|
|
10775
10813
|
// features/games/games/shared.jsx
|
|
10776
|
-
var
|
|
10814
|
+
var import_react10 = require("react");
|
|
10777
10815
|
function isTypingTarget(event) {
|
|
10778
10816
|
const tag = event.target && event.target.tagName || "";
|
|
10779
10817
|
if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") return true;
|
|
@@ -10781,9 +10819,9 @@ function isTypingTarget(event) {
|
|
|
10781
10819
|
return false;
|
|
10782
10820
|
}
|
|
10783
10821
|
function useGameControls(stageRef, paused, onKeyDown, onKeyUp) {
|
|
10784
|
-
const pausedRef = (0,
|
|
10822
|
+
const pausedRef = (0, import_react10.useRef)(!!paused);
|
|
10785
10823
|
pausedRef.current = !!paused;
|
|
10786
|
-
(0,
|
|
10824
|
+
(0, import_react10.useEffect)(() => {
|
|
10787
10825
|
if (pausedRef.current) return;
|
|
10788
10826
|
const el = stageRef && stageRef.current;
|
|
10789
10827
|
if (!el) return;
|
|
@@ -10795,7 +10833,7 @@ function useGameControls(stageRef, paused, onKeyDown, onKeyUp) {
|
|
|
10795
10833
|
}, 60);
|
|
10796
10834
|
return () => clearTimeout(t);
|
|
10797
10835
|
}, [paused]);
|
|
10798
|
-
(0,
|
|
10836
|
+
(0, import_react10.useEffect)(() => {
|
|
10799
10837
|
const inStage = (event) => {
|
|
10800
10838
|
const el = stageRef && stageRef.current;
|
|
10801
10839
|
return !!el && (el === event.target || el.contains(event.target));
|
|
@@ -10888,7 +10926,7 @@ function playSfx(name) {
|
|
|
10888
10926
|
}
|
|
10889
10927
|
|
|
10890
10928
|
// features/games/games/tetris.jsx
|
|
10891
|
-
var
|
|
10929
|
+
var import_react11 = require("react");
|
|
10892
10930
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
10893
10931
|
var COLS = 10;
|
|
10894
10932
|
var ROWS = 20;
|
|
@@ -11049,12 +11087,12 @@ var KEY_ACTIONS = {
|
|
|
11049
11087
|
"Enter": "drop"
|
|
11050
11088
|
};
|
|
11051
11089
|
function TetrisGame(props) {
|
|
11052
|
-
const [state, setState] = (0,
|
|
11053
|
-
const [manualPause, setManualPause] = (0,
|
|
11054
|
-
const pausedRef = (0,
|
|
11090
|
+
const [state, setState] = (0, import_react11.useState)(initial);
|
|
11091
|
+
const [manualPause, setManualPause] = (0, import_react11.useState)(false);
|
|
11092
|
+
const pausedRef = (0, import_react11.useRef)(!!(props && props.paused));
|
|
11055
11093
|
pausedRef.current = !!(props && props.paused) || manualPause;
|
|
11056
|
-
const stageRef = (0,
|
|
11057
|
-
const act = (0,
|
|
11094
|
+
const stageRef = (0, import_react11.useRef)(null);
|
|
11095
|
+
const act = (0, import_react11.useCallback)((action) => setState((s) => {
|
|
11058
11096
|
if (pausedRef.current) return s;
|
|
11059
11097
|
if (action === "left") {
|
|
11060
11098
|
playSfx("move");
|
|
@@ -11076,21 +11114,21 @@ function TetrisGame(props) {
|
|
|
11076
11114
|
}
|
|
11077
11115
|
return s;
|
|
11078
11116
|
}), []);
|
|
11079
|
-
const softRef = (0,
|
|
11080
|
-
const stateRef = (0,
|
|
11117
|
+
const softRef = (0, import_react11.useRef)(null);
|
|
11118
|
+
const stateRef = (0, import_react11.useRef)(state);
|
|
11081
11119
|
stateRef.current = state;
|
|
11082
|
-
const holdIdRef = (0,
|
|
11083
|
-
const stopSoft = (0,
|
|
11120
|
+
const holdIdRef = (0, import_react11.useRef)(null);
|
|
11121
|
+
const stopSoft = (0, import_react11.useCallback)(() => {
|
|
11084
11122
|
if (softRef.current) {
|
|
11085
11123
|
clearInterval(softRef.current);
|
|
11086
11124
|
softRef.current = null;
|
|
11087
11125
|
}
|
|
11088
11126
|
}, []);
|
|
11089
|
-
(0,
|
|
11127
|
+
(0, import_react11.useEffect)(() => {
|
|
11090
11128
|
if (state.over || manualPause || props.paused) stopSoft();
|
|
11091
11129
|
return stopSoft;
|
|
11092
11130
|
}, [state.over, manualPause, props.paused, stopSoft]);
|
|
11093
|
-
const onKeyDown = (0,
|
|
11131
|
+
const onKeyDown = (0, import_react11.useCallback)((event) => {
|
|
11094
11132
|
const action = KEY_ACTIONS[event.key];
|
|
11095
11133
|
if (action) {
|
|
11096
11134
|
event.preventDefault();
|
|
@@ -11122,13 +11160,13 @@ function TetrisGame(props) {
|
|
|
11122
11160
|
setManualPause(false);
|
|
11123
11161
|
}
|
|
11124
11162
|
}, [act, stopSoft]);
|
|
11125
|
-
const onKeyUp = (0,
|
|
11163
|
+
const onKeyUp = (0, import_react11.useCallback)((event) => {
|
|
11126
11164
|
if (KEY_ACTIONS[event.key] === "down") stopSoft();
|
|
11127
11165
|
}, [stopSoft]);
|
|
11128
|
-
(0,
|
|
11166
|
+
(0, import_react11.useEffect)(() => {
|
|
11129
11167
|
if (state.over) playSfx("over");
|
|
11130
11168
|
}, [state.over]);
|
|
11131
|
-
(0,
|
|
11169
|
+
(0, import_react11.useEffect)(() => {
|
|
11132
11170
|
if (pausedRef.current || state.over) return;
|
|
11133
11171
|
const speed = Math.max(80, 720 - (state.level - 1) * 70);
|
|
11134
11172
|
const timer = setInterval(() => act("down"), speed);
|
|
@@ -11234,7 +11272,7 @@ var tetrisGame = { Game: TetrisGame, Preview: TetrisPreview, css: `
|
|
|
11234
11272
|
` };
|
|
11235
11273
|
|
|
11236
11274
|
// features/games/games/sokoban.jsx
|
|
11237
|
-
var
|
|
11275
|
+
var import_react12 = require("react");
|
|
11238
11276
|
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
11239
11277
|
var LEVELS = [
|
|
11240
11278
|
["######", "# #", "#@$ .#", "# #", "######"],
|
|
@@ -11329,28 +11367,28 @@ function undo(state) {
|
|
|
11329
11367
|
}
|
|
11330
11368
|
var DIRS = { ArrowUp: [-1, 0], ArrowDown: [1, 0], ArrowLeft: [0, -1], ArrowRight: [0, 1], w: [-1, 0], s: [1, 0], a: [0, -1], d: [0, 1], W: [-1, 0], S: [1, 0], A: [0, -1], D: [0, 1] };
|
|
11331
11369
|
function SokobanGame(props) {
|
|
11332
|
-
const [level, setLevel] = (0,
|
|
11333
|
-
const [state, setState] = (0,
|
|
11334
|
-
const stageRef = (0,
|
|
11335
|
-
const levelRef = (0,
|
|
11370
|
+
const [level, setLevel] = (0, import_react12.useState)(0);
|
|
11371
|
+
const [state, setState] = (0, import_react12.useState)(() => makeInitial(0));
|
|
11372
|
+
const stageRef = (0, import_react12.useRef)(null);
|
|
11373
|
+
const levelRef = (0, import_react12.useRef)(level);
|
|
11336
11374
|
levelRef.current = level;
|
|
11337
|
-
const move = (0,
|
|
11338
|
-
const prevWon = (0,
|
|
11339
|
-
(0,
|
|
11375
|
+
const move = (0, import_react12.useCallback)((dr, dc) => setState((s) => step(s, dr, dc)), []);
|
|
11376
|
+
const prevWon = (0, import_react12.useRef)(false);
|
|
11377
|
+
(0, import_react12.useEffect)(() => {
|
|
11340
11378
|
if (state.wonNew && !prevWon.current) playSfx("win");
|
|
11341
11379
|
prevWon.current = state.wonNew;
|
|
11342
11380
|
}, [state.wonNew]);
|
|
11343
|
-
const nextLevel = (0,
|
|
11381
|
+
const nextLevel = (0, import_react12.useCallback)(() => {
|
|
11344
11382
|
const n = (levelRef.current + 1) % LEVELS.length;
|
|
11345
11383
|
setLevel(n);
|
|
11346
11384
|
setState(makeInitial(n));
|
|
11347
11385
|
}, []);
|
|
11348
|
-
const pickLevel = (0,
|
|
11386
|
+
const pickLevel = (0, import_react12.useCallback)((i) => {
|
|
11349
11387
|
setLevel(i);
|
|
11350
11388
|
setState(makeInitial(i));
|
|
11351
11389
|
}, []);
|
|
11352
|
-
const reset = (0,
|
|
11353
|
-
const onKeyDown = (0,
|
|
11390
|
+
const reset = (0, import_react12.useCallback)(() => setState(makeInitial(levelRef.current)), []);
|
|
11391
|
+
const onKeyDown = (0, import_react12.useCallback)((event) => {
|
|
11354
11392
|
const d = DIRS[event.key];
|
|
11355
11393
|
if (d) {
|
|
11356
11394
|
event.preventDefault();
|
|
@@ -11435,7 +11473,7 @@ var sokobanGame = { Game: SokobanGame, Preview: SokobanPreview, css: `
|
|
|
11435
11473
|
` };
|
|
11436
11474
|
|
|
11437
11475
|
// features/games/games/gomoku.jsx
|
|
11438
|
-
var
|
|
11476
|
+
var import_react13 = require("react");
|
|
11439
11477
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
11440
11478
|
var GOMOKU_LINES = (() => {
|
|
11441
11479
|
const P = (n) => n * 100 + 50;
|
|
@@ -11552,22 +11590,22 @@ function aiMove(board) {
|
|
|
11552
11590
|
return best || [7, 7];
|
|
11553
11591
|
}
|
|
11554
11592
|
function GomokuGame(props) {
|
|
11555
|
-
const [board, setBoard] = (0,
|
|
11556
|
-
const [turn, setTurn] = (0,
|
|
11557
|
-
const [winner, setWinner] = (0,
|
|
11558
|
-
const [winCells, setWinCells] = (0,
|
|
11559
|
-
const [showResult, setShowResult] = (0,
|
|
11560
|
-
const [last, setLast] = (0,
|
|
11561
|
-
const [history, setHistory] = (0,
|
|
11562
|
-
const [thinking, setThinking] = (0,
|
|
11563
|
-
const boardRef = (0,
|
|
11564
|
-
const stageRef = (0,
|
|
11593
|
+
const [board, setBoard] = (0, import_react13.useState)(emptyBoard2);
|
|
11594
|
+
const [turn, setTurn] = (0, import_react13.useState)("b");
|
|
11595
|
+
const [winner, setWinner] = (0, import_react13.useState)(null);
|
|
11596
|
+
const [winCells, setWinCells] = (0, import_react13.useState)(null);
|
|
11597
|
+
const [showResult, setShowResult] = (0, import_react13.useState)(false);
|
|
11598
|
+
const [last, setLast] = (0, import_react13.useState)(null);
|
|
11599
|
+
const [history, setHistory] = (0, import_react13.useState)([]);
|
|
11600
|
+
const [thinking, setThinking] = (0, import_react13.useState)(false);
|
|
11601
|
+
const boardRef = (0, import_react13.useRef)(board);
|
|
11602
|
+
const stageRef = (0, import_react13.useRef)(null);
|
|
11565
11603
|
boardRef.current = board;
|
|
11566
|
-
const turnRef = (0,
|
|
11604
|
+
const turnRef = (0, import_react13.useRef)(turn);
|
|
11567
11605
|
turnRef.current = turn;
|
|
11568
|
-
const winRef = (0,
|
|
11606
|
+
const winRef = (0, import_react13.useRef)(winner);
|
|
11569
11607
|
winRef.current = winner;
|
|
11570
|
-
const finish = (0,
|
|
11608
|
+
const finish = (0, import_react13.useCallback)((b, r, c, color) => {
|
|
11571
11609
|
const line = winLine(b, r, c, color);
|
|
11572
11610
|
if (line) {
|
|
11573
11611
|
setWinner(color);
|
|
@@ -11581,7 +11619,7 @@ function GomokuGame(props) {
|
|
|
11581
11619
|
playSfx("clear");
|
|
11582
11620
|
} else playSfx("stone");
|
|
11583
11621
|
}, []);
|
|
11584
|
-
const place = (0,
|
|
11622
|
+
const place = (0, import_react13.useCallback)((r, c, color) => {
|
|
11585
11623
|
if (boardRef.current[r][c]) return false;
|
|
11586
11624
|
const next = boardRef.current.map((row) => row.slice());
|
|
11587
11625
|
next[r][c] = color;
|
|
@@ -11592,7 +11630,7 @@ function GomokuGame(props) {
|
|
|
11592
11630
|
finish(next, r, c, color);
|
|
11593
11631
|
return true;
|
|
11594
11632
|
}, [finish]);
|
|
11595
|
-
(0,
|
|
11633
|
+
(0, import_react13.useEffect)(() => {
|
|
11596
11634
|
if (turn !== "w" || winner || props.paused) return;
|
|
11597
11635
|
setThinking(true);
|
|
11598
11636
|
const t = setTimeout(() => {
|
|
@@ -11603,12 +11641,12 @@ function GomokuGame(props) {
|
|
|
11603
11641
|
}, 260);
|
|
11604
11642
|
return () => clearTimeout(t);
|
|
11605
11643
|
}, [turn, winner, props.paused, place]);
|
|
11606
|
-
const onCell = (0,
|
|
11644
|
+
const onCell = (0, import_react13.useCallback)((r, c) => {
|
|
11607
11645
|
if (winRef.current || turnRef.current !== "b" || thinking || boardRef.current[r][c]) return;
|
|
11608
11646
|
place(r, c, "b");
|
|
11609
11647
|
setTurn("w");
|
|
11610
11648
|
}, [thinking, place]);
|
|
11611
|
-
const reset = (0,
|
|
11649
|
+
const reset = (0, import_react13.useCallback)(() => {
|
|
11612
11650
|
setBoard(emptyBoard2());
|
|
11613
11651
|
setTurn("b");
|
|
11614
11652
|
setWinner(null);
|
|
@@ -11618,7 +11656,7 @@ function GomokuGame(props) {
|
|
|
11618
11656
|
setHistory([]);
|
|
11619
11657
|
setThinking(false);
|
|
11620
11658
|
}, []);
|
|
11621
|
-
const undo2 = (0,
|
|
11659
|
+
const undo2 = (0, import_react13.useCallback)(() => {
|
|
11622
11660
|
if (thinking || history.length < 2) return;
|
|
11623
11661
|
const h = history.slice(0, -2);
|
|
11624
11662
|
const next = emptyBoard2();
|
|
@@ -11632,7 +11670,7 @@ function GomokuGame(props) {
|
|
|
11632
11670
|
setShowResult(false);
|
|
11633
11671
|
setLast(h.length ? h[h.length - 1] : null);
|
|
11634
11672
|
}, [history, thinking]);
|
|
11635
|
-
const onKeyDown = (0,
|
|
11673
|
+
const onKeyDown = (0, import_react13.useCallback)((event) => {
|
|
11636
11674
|
if (event.key.toLowerCase() === "r") {
|
|
11637
11675
|
event.preventDefault();
|
|
11638
11676
|
reset();
|
|
@@ -11731,7 +11769,7 @@ var gomokuGame = { Game: GomokuGame, Preview: GomokuPreview, css: `
|
|
|
11731
11769
|
` };
|
|
11732
11770
|
|
|
11733
11771
|
// features/games/games/xiangqi.jsx
|
|
11734
|
-
var
|
|
11772
|
+
var import_react14 = require("react");
|
|
11735
11773
|
|
|
11736
11774
|
// features/games/xiangqi-core.js
|
|
11737
11775
|
var ROWS2 = 10;
|
|
@@ -12096,35 +12134,35 @@ function moveNotation(board, fr, fc, tr, tc) {
|
|
|
12096
12134
|
return pieceChar(p) + num(file(fc)) + verb + num(to);
|
|
12097
12135
|
}
|
|
12098
12136
|
function XiangqiGame(props) {
|
|
12099
|
-
const [board, setBoard] = (0,
|
|
12100
|
-
const [turn, setTurn] = (0,
|
|
12101
|
-
const [sel, setSel] = (0,
|
|
12102
|
-
const [targets, setTargets] = (0,
|
|
12103
|
-
const [over, setOver] = (0,
|
|
12104
|
-
const [check, setCheck] = (0,
|
|
12105
|
-
const [last, setLast] = (0,
|
|
12106
|
-
const [lastMove, setLastMove] = (0,
|
|
12107
|
-
const [moveLog, setMoveLog] = (0,
|
|
12108
|
-
const [moving, setMoving] = (0,
|
|
12109
|
-
const [thinking, setThinking] = (0,
|
|
12110
|
-
const [history, setHistory] = (0,
|
|
12111
|
-
const [repKeys, setRepKeys] = (0,
|
|
12112
|
-
const pushKey = (0,
|
|
12113
|
-
const stageRef = (0,
|
|
12114
|
-
const boardRef = (0,
|
|
12137
|
+
const [board, setBoard] = (0, import_react14.useState)(initialBoard);
|
|
12138
|
+
const [turn, setTurn] = (0, import_react14.useState)("r");
|
|
12139
|
+
const [sel, setSel] = (0, import_react14.useState)(null);
|
|
12140
|
+
const [targets, setTargets] = (0, import_react14.useState)([]);
|
|
12141
|
+
const [over, setOver] = (0, import_react14.useState)(null);
|
|
12142
|
+
const [check, setCheck] = (0, import_react14.useState)(false);
|
|
12143
|
+
const [last, setLast] = (0, import_react14.useState)(null);
|
|
12144
|
+
const [lastMove, setLastMove] = (0, import_react14.useState)(null);
|
|
12145
|
+
const [moveLog, setMoveLog] = (0, import_react14.useState)([]);
|
|
12146
|
+
const [moving, setMoving] = (0, import_react14.useState)(null);
|
|
12147
|
+
const [thinking, setThinking] = (0, import_react14.useState)(false);
|
|
12148
|
+
const [history, setHistory] = (0, import_react14.useState)([]);
|
|
12149
|
+
const [repKeys, setRepKeys] = (0, import_react14.useState)(() => [posKey(initialBoard())]);
|
|
12150
|
+
const pushKey = (0, import_react14.useCallback)((b) => setRepKeys((ks) => ks[ks.length - 1] === posKey(b) ? ks : ks.concat(posKey(b))), []);
|
|
12151
|
+
const stageRef = (0, import_react14.useRef)(null);
|
|
12152
|
+
const boardRef = (0, import_react14.useRef)(board);
|
|
12115
12153
|
boardRef.current = board;
|
|
12116
|
-
const turnRef = (0,
|
|
12154
|
+
const turnRef = (0, import_react14.useRef)(turn);
|
|
12117
12155
|
turnRef.current = turn;
|
|
12118
|
-
const overRef = (0,
|
|
12156
|
+
const overRef = (0, import_react14.useRef)(over);
|
|
12119
12157
|
overRef.current = over;
|
|
12120
|
-
const thinkingRef = (0,
|
|
12158
|
+
const thinkingRef = (0, import_react14.useRef)(thinking);
|
|
12121
12159
|
thinkingRef.current = thinking;
|
|
12122
|
-
const historyRef = (0,
|
|
12160
|
+
const historyRef = (0, import_react14.useRef)(history);
|
|
12123
12161
|
historyRef.current = history;
|
|
12124
|
-
const movingRef = (0,
|
|
12125
|
-
const pendingRef = (0,
|
|
12126
|
-
const animTimerRef = (0,
|
|
12127
|
-
const animateMove = (0,
|
|
12162
|
+
const movingRef = (0, import_react14.useRef)(false);
|
|
12163
|
+
const pendingRef = (0, import_react14.useRef)(null);
|
|
12164
|
+
const animTimerRef = (0, import_react14.useRef)(null);
|
|
12165
|
+
const animateMove = (0, import_react14.useCallback)((b, fr, fc, tr, tc, after) => {
|
|
12128
12166
|
const piece = boardRef.current[fr][fc];
|
|
12129
12167
|
const capture = !!boardRef.current[tr][tc];
|
|
12130
12168
|
pendingRef.current = { board: b, after };
|
|
@@ -12151,7 +12189,7 @@ function XiangqiGame(props) {
|
|
|
12151
12189
|
}
|
|
12152
12190
|
}, 260);
|
|
12153
12191
|
}, []);
|
|
12154
|
-
const restart = (0,
|
|
12192
|
+
const restart = (0, import_react14.useCallback)(() => {
|
|
12155
12193
|
if (animTimerRef.current) {
|
|
12156
12194
|
clearTimeout(animTimerRef.current);
|
|
12157
12195
|
animTimerRef.current = null;
|
|
@@ -12174,7 +12212,7 @@ function XiangqiGame(props) {
|
|
|
12174
12212
|
setMoving(null);
|
|
12175
12213
|
setRepKeys([posKey(b)]);
|
|
12176
12214
|
}, []);
|
|
12177
|
-
const undo2 = (0,
|
|
12215
|
+
const undo2 = (0, import_react14.useCallback)(() => {
|
|
12178
12216
|
if (thinkingRef.current || overRef.current || turnRef.current !== "r" || movingRef.current) return;
|
|
12179
12217
|
const h = historyRef.current;
|
|
12180
12218
|
if (h.length < 2) return;
|
|
@@ -12192,7 +12230,7 @@ function XiangqiGame(props) {
|
|
|
12192
12230
|
setCheck(inCheck(b, "r"));
|
|
12193
12231
|
setRepKeys(hist.map(posKey).concat(posKey(b)));
|
|
12194
12232
|
}, []);
|
|
12195
|
-
const moveRed = (0,
|
|
12233
|
+
const moveRed = (0, import_react14.useCallback)((tr, tc) => {
|
|
12196
12234
|
if (turnRef.current !== "r" || overRef.current || !sel || movingRef.current) return;
|
|
12197
12235
|
const fr = sel[0], fc = sel[1];
|
|
12198
12236
|
const nb = applyMove(boardRef.current, fr, fc, tr, tc);
|
|
@@ -12206,7 +12244,7 @@ function XiangqiGame(props) {
|
|
|
12206
12244
|
} else setCheck(inCheck(nb, "b"));
|
|
12207
12245
|
});
|
|
12208
12246
|
}, [sel, pushKey, animateMove]);
|
|
12209
|
-
const select = (0,
|
|
12247
|
+
const select = (0, import_react14.useCallback)((r, c) => {
|
|
12210
12248
|
if (overRef.current || turnRef.current !== "r" || thinkingRef.current || movingRef.current) return;
|
|
12211
12249
|
const p = boardRef.current[r][c];
|
|
12212
12250
|
if (p && p.c === "r") {
|
|
@@ -12222,7 +12260,7 @@ function XiangqiGame(props) {
|
|
|
12222
12260
|
setSel(null);
|
|
12223
12261
|
setTargets([]);
|
|
12224
12262
|
}, [sel, targets, moveRed]);
|
|
12225
|
-
(0,
|
|
12263
|
+
(0, import_react14.useEffect)(() => {
|
|
12226
12264
|
if (turn !== "b" || over || props.paused || movingRef.current) return;
|
|
12227
12265
|
const t = setTimeout(() => {
|
|
12228
12266
|
const seenCounts = /* @__PURE__ */ new Map();
|
|
@@ -12246,7 +12284,7 @@ function XiangqiGame(props) {
|
|
|
12246
12284
|
setThinking(true);
|
|
12247
12285
|
return () => clearTimeout(t);
|
|
12248
12286
|
}, [turn, over, props.paused, repKeys, pushKey, animateMove]);
|
|
12249
|
-
const onKeyDown = (0,
|
|
12287
|
+
const onKeyDown = (0, import_react14.useCallback)((event) => {
|
|
12250
12288
|
if (event.key.toLowerCase() === "r") {
|
|
12251
12289
|
event.preventDefault();
|
|
12252
12290
|
restart();
|
|
@@ -12257,14 +12295,14 @@ function XiangqiGame(props) {
|
|
|
12257
12295
|
}, [restart, undo2]);
|
|
12258
12296
|
useGameControls(stageRef, props.paused, onKeyDown);
|
|
12259
12297
|
const status = over === "r" ? "\u7EA2\u65B9\u80DC \xB7 \u606D\u559C" : over === "b" ? "\u9ED1\u65B9\u80DC \xB7 AI \u8D62" : moving ? moving.piece.c === "r" ? "\u7EA2\u65B9\u8D70\u5B50\u2026" : "AI \u8D70\u5B50\u2026" : thinking ? "AI \u601D\u8003\u4E2D\u2026" : check ? "\u5C06\u519B\uFF01" : turn === "r" ? "\u8F6E\u5230\u4F60\uFF08\u7EA2\u65B9\uFF09" : "\u8F6E\u5230 AI\uFF08\u9ED1\u65B9\uFF09";
|
|
12260
|
-
const prevCheck = (0,
|
|
12261
|
-
(0,
|
|
12298
|
+
const prevCheck = (0, import_react14.useRef)(false);
|
|
12299
|
+
(0, import_react14.useEffect)(() => {
|
|
12262
12300
|
if (over === "r") playSfx("win");
|
|
12263
12301
|
else if (over === "b") playSfx("over");
|
|
12264
12302
|
else if (!thinking && check && !prevCheck.current) playSfx("check");
|
|
12265
12303
|
prevCheck.current = !thinking && check;
|
|
12266
12304
|
}, [check, thinking, over]);
|
|
12267
|
-
(0,
|
|
12305
|
+
(0, import_react14.useEffect)(() => () => {
|
|
12268
12306
|
if (animTimerRef.current) clearTimeout(animTimerRef.current);
|
|
12269
12307
|
}, []);
|
|
12270
12308
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("section", { className: "dgame-game", "aria-label": "\u8C61\u68CB", children: [
|
|
@@ -12369,7 +12407,7 @@ var xiangqiGame = { Game: XiangqiGame, Preview: XiangqiPreview, css: `
|
|
|
12369
12407
|
` };
|
|
12370
12408
|
|
|
12371
12409
|
// features/games/games/snake.jsx
|
|
12372
|
-
var
|
|
12410
|
+
var import_react15 = require("react");
|
|
12373
12411
|
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
12374
12412
|
var SIZE2 = 16;
|
|
12375
12413
|
var DIRS3 = { ArrowUp: [-1, 0], ArrowDown: [1, 0], ArrowLeft: [0, -1], ArrowRight: [0, 1], w: [-1, 0], s: [1, 0], a: [0, -1], d: [0, 1], W: [-1, 0], S: [1, 0], A: [0, -1], D: [0, 1] };
|
|
@@ -12414,26 +12452,26 @@ function step2(state, dir) {
|
|
|
12414
12452
|
return Object.assign({}, state, { snake });
|
|
12415
12453
|
}
|
|
12416
12454
|
function SnakeGame(props) {
|
|
12417
|
-
const [state, setState] = (0,
|
|
12418
|
-
const [paused, setPaused] = (0,
|
|
12419
|
-
const [speedMode, setSpeedMode] = (0,
|
|
12420
|
-
const stageRef = (0,
|
|
12421
|
-
const dirRef = (0,
|
|
12422
|
-
const overRef = (0,
|
|
12455
|
+
const [state, setState] = (0, import_react15.useState)(initial2);
|
|
12456
|
+
const [paused, setPaused] = (0, import_react15.useState)(false);
|
|
12457
|
+
const [speedMode, setSpeedMode] = (0, import_react15.useState)(loadSpeedMode);
|
|
12458
|
+
const stageRef = (0, import_react15.useRef)(null);
|
|
12459
|
+
const dirRef = (0, import_react15.useRef)(state.dir);
|
|
12460
|
+
const overRef = (0, import_react15.useRef)(state.over);
|
|
12423
12461
|
overRef.current = state.over;
|
|
12424
|
-
const pausedRef = (0,
|
|
12462
|
+
const pausedRef = (0, import_react15.useRef)(!!(props && props.paused) || paused);
|
|
12425
12463
|
pausedRef.current = !!(props && props.paused) || paused;
|
|
12426
|
-
const start = (0,
|
|
12464
|
+
const start = (0, import_react15.useCallback)(() => {
|
|
12427
12465
|
const init = initial2();
|
|
12428
12466
|
init.started = true;
|
|
12429
12467
|
dirRef.current = init.dir;
|
|
12430
12468
|
setState(init);
|
|
12431
12469
|
setPaused(false);
|
|
12432
12470
|
}, []);
|
|
12433
|
-
const begin = (0,
|
|
12471
|
+
const begin = (0, import_react15.useCallback)(() => {
|
|
12434
12472
|
setState((s) => s.started || s.over ? s : Object.assign({}, s, { started: true }));
|
|
12435
12473
|
}, []);
|
|
12436
|
-
const changeDir = (0,
|
|
12474
|
+
const changeDir = (0, import_react15.useCallback)((nv) => {
|
|
12437
12475
|
if (overRef.current || pausedRef.current) return;
|
|
12438
12476
|
const cur = dirRef.current;
|
|
12439
12477
|
const opp = OPPOSITE[cur[0] + "," + cur[1]];
|
|
@@ -12441,24 +12479,24 @@ function SnakeGame(props) {
|
|
|
12441
12479
|
dirRef.current = nv;
|
|
12442
12480
|
begin();
|
|
12443
12481
|
}, [begin]);
|
|
12444
|
-
(0,
|
|
12482
|
+
(0, import_react15.useEffect)(() => {
|
|
12445
12483
|
if (state.over) playSfx("over");
|
|
12446
12484
|
}, [state.over]);
|
|
12447
|
-
(0,
|
|
12485
|
+
(0, import_react15.useEffect)(() => {
|
|
12448
12486
|
if (!state.started || state.over || pausedRef.current) return;
|
|
12449
12487
|
const mode = SPEED_MODES[speedMode] || SPEED_MODES.slow;
|
|
12450
12488
|
const speed = Math.max(mode.min, mode.base - state.score * mode.stepMs);
|
|
12451
12489
|
const timer = setInterval(() => setState((s) => s.over || !s.started || pausedRef.current ? s : step2(s, dirRef.current)), speed);
|
|
12452
12490
|
return () => clearInterval(timer);
|
|
12453
12491
|
}, [state.started, state.over, state.score, props.paused, paused, speedMode]);
|
|
12454
|
-
const pickSpeed = (0,
|
|
12492
|
+
const pickSpeed = (0, import_react15.useCallback)((m) => {
|
|
12455
12493
|
setSpeedMode(m);
|
|
12456
12494
|
try {
|
|
12457
12495
|
localStorage.setItem("dsh-dock.snake.speed", m);
|
|
12458
12496
|
} catch {
|
|
12459
12497
|
}
|
|
12460
12498
|
}, []);
|
|
12461
|
-
const onKeyDown = (0,
|
|
12499
|
+
const onKeyDown = (0, import_react15.useCallback)((event) => {
|
|
12462
12500
|
const d = DIRS3[event.key];
|
|
12463
12501
|
if (d) {
|
|
12464
12502
|
event.preventDefault();
|
|
@@ -12558,7 +12596,7 @@ var snakeGame = { Game: SnakeGame, Preview: SnakePreview, css: `
|
|
|
12558
12596
|
` };
|
|
12559
12597
|
|
|
12560
12598
|
// features/games/games/breakout.jsx
|
|
12561
|
-
var
|
|
12599
|
+
var import_react16 = require("react");
|
|
12562
12600
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
12563
12601
|
var W = 320;
|
|
12564
12602
|
var H = 360;
|
|
@@ -12638,22 +12676,22 @@ function collideRect(x, y, r, bx, by, bw, bh) {
|
|
|
12638
12676
|
return dx * dx + dy * dy < r * r;
|
|
12639
12677
|
}
|
|
12640
12678
|
function BreakoutGame(props) {
|
|
12641
|
-
const canvasRef = (0,
|
|
12642
|
-
const [score, setScore] = (0,
|
|
12643
|
-
const [lives, setLives] = (0,
|
|
12644
|
-
const [level, setLevel] = (0,
|
|
12645
|
-
const [status, setStatus] = (0,
|
|
12646
|
-
const keys = (0,
|
|
12647
|
-
const pausedRef = (0,
|
|
12679
|
+
const canvasRef = (0, import_react16.useRef)(null);
|
|
12680
|
+
const [score, setScore] = (0, import_react16.useState)(0);
|
|
12681
|
+
const [lives, setLives] = (0, import_react16.useState)(3);
|
|
12682
|
+
const [level, setLevel] = (0, import_react16.useState)(1);
|
|
12683
|
+
const [status, setStatus] = (0, import_react16.useState)("play");
|
|
12684
|
+
const keys = (0, import_react16.useRef)({});
|
|
12685
|
+
const pausedRef = (0, import_react16.useRef)(!!(props && props.paused));
|
|
12648
12686
|
pausedRef.current = !!(props && props.paused);
|
|
12649
|
-
const game = (0,
|
|
12650
|
-
const scoreRef = (0,
|
|
12687
|
+
const game = (0, import_react16.useRef)(null);
|
|
12688
|
+
const scoreRef = (0, import_react16.useRef)(0);
|
|
12651
12689
|
scoreRef.current = score;
|
|
12652
|
-
const statusRef = (0,
|
|
12690
|
+
const statusRef = (0, import_react16.useRef)("play");
|
|
12653
12691
|
statusRef.current = status;
|
|
12654
|
-
const livesRef = (0,
|
|
12692
|
+
const livesRef = (0, import_react16.useRef)(3);
|
|
12655
12693
|
livesRef.current = lives;
|
|
12656
|
-
const start = (0,
|
|
12694
|
+
const start = (0, import_react16.useCallback)((lvl) => {
|
|
12657
12695
|
const bricks = makeBricks(lvl);
|
|
12658
12696
|
game.current = {
|
|
12659
12697
|
stars: Array.from({ length: 46 }, () => ({ x: Math.random() * W, y: Math.random() * H, a: 0.25 + Math.random() * 0.5 })),
|
|
@@ -12663,20 +12701,20 @@ function BreakoutGame(props) {
|
|
|
12663
12701
|
speed: SPEED * (1 + (lvl - 1) * 0.09)
|
|
12664
12702
|
};
|
|
12665
12703
|
}, []);
|
|
12666
|
-
(0,
|
|
12704
|
+
(0, import_react16.useEffect)(() => {
|
|
12667
12705
|
start(1);
|
|
12668
12706
|
setScore(0);
|
|
12669
12707
|
setLives(3);
|
|
12670
12708
|
setStatus("play");
|
|
12671
12709
|
}, [start]);
|
|
12672
|
-
const launchBall = (0,
|
|
12710
|
+
const launchBall = (0, import_react16.useCallback)(() => {
|
|
12673
12711
|
const g = game.current;
|
|
12674
12712
|
if (!g) return;
|
|
12675
12713
|
g.ball.vx = (Math.random() > 0.5 ? 1 : -1) * SPEED;
|
|
12676
12714
|
g.ball.vy = -SPEED;
|
|
12677
12715
|
g.launched = true;
|
|
12678
12716
|
}, []);
|
|
12679
|
-
const resetBall = (0,
|
|
12717
|
+
const resetBall = (0, import_react16.useCallback)(() => {
|
|
12680
12718
|
const g = game.current;
|
|
12681
12719
|
if (g) {
|
|
12682
12720
|
g.ball.x = W / 2;
|
|
@@ -12686,7 +12724,7 @@ function BreakoutGame(props) {
|
|
|
12686
12724
|
g.launched = false;
|
|
12687
12725
|
}
|
|
12688
12726
|
}, []);
|
|
12689
|
-
(0,
|
|
12727
|
+
(0, import_react16.useEffect)(() => {
|
|
12690
12728
|
const frame = () => {
|
|
12691
12729
|
const g = game.current;
|
|
12692
12730
|
const ctx = canvasRef.current && canvasRef.current.getContext("2d");
|
|
@@ -12772,7 +12810,7 @@ function BreakoutGame(props) {
|
|
|
12772
12810
|
});
|
|
12773
12811
|
return () => cancelAnimationFrame(raf);
|
|
12774
12812
|
}, [resetBall]);
|
|
12775
|
-
const onKeyDown = (0,
|
|
12813
|
+
const onKeyDown = (0, import_react16.useCallback)((event) => {
|
|
12776
12814
|
if (pausedRef.current) return;
|
|
12777
12815
|
if (event.key === "ArrowLeft") {
|
|
12778
12816
|
event.preventDefault();
|
|
@@ -12793,11 +12831,11 @@ function BreakoutGame(props) {
|
|
|
12793
12831
|
livesRef.current = 3;
|
|
12794
12832
|
}
|
|
12795
12833
|
}, [launchBall, start]);
|
|
12796
|
-
const onKeyUp = (0,
|
|
12834
|
+
const onKeyUp = (0, import_react16.useCallback)((event) => {
|
|
12797
12835
|
if (event.key === "ArrowLeft") keys.current.left = false;
|
|
12798
12836
|
else if (event.key === "ArrowRight") keys.current.right = false;
|
|
12799
12837
|
}, []);
|
|
12800
|
-
const onPointerMove = (0,
|
|
12838
|
+
const onPointerMove = (0, import_react16.useCallback)((e) => {
|
|
12801
12839
|
const g = game.current, cv = canvasRef.current;
|
|
12802
12840
|
if (!g || !cv) return;
|
|
12803
12841
|
const rect2 = cv.getBoundingClientRect();
|
|
@@ -12889,7 +12927,7 @@ var breakoutGame = { Game: BreakoutGame, Preview: BreakoutPreview, css: `
|
|
|
12889
12927
|
` };
|
|
12890
12928
|
|
|
12891
12929
|
// features/games/games/racer.jsx
|
|
12892
|
-
var
|
|
12930
|
+
var import_react17 = require("react");
|
|
12893
12931
|
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
12894
12932
|
var W2 = 300;
|
|
12895
12933
|
var H2 = 420;
|
|
@@ -12916,15 +12954,15 @@ function rect(ctx, x, y, w, h, r, fill) {
|
|
|
12916
12954
|
ctx.fill();
|
|
12917
12955
|
}
|
|
12918
12956
|
function RacerGame(props) {
|
|
12919
|
-
const canvasRef = (0,
|
|
12920
|
-
const [status, setStatus] = (0,
|
|
12921
|
-
const game = (0,
|
|
12922
|
-
const keys = (0,
|
|
12923
|
-
const statusRef = (0,
|
|
12957
|
+
const canvasRef = (0, import_react17.useRef)(null);
|
|
12958
|
+
const [status, setStatus] = (0, import_react17.useState)("play");
|
|
12959
|
+
const game = (0, import_react17.useRef)(null);
|
|
12960
|
+
const keys = (0, import_react17.useRef)({});
|
|
12961
|
+
const statusRef = (0, import_react17.useRef)("play");
|
|
12924
12962
|
statusRef.current = status;
|
|
12925
|
-
const pausedRef = (0,
|
|
12963
|
+
const pausedRef = (0, import_react17.useRef)(!!(props && props.paused));
|
|
12926
12964
|
pausedRef.current = !!(props && props.paused);
|
|
12927
|
-
const reset = (0,
|
|
12965
|
+
const reset = (0, import_react17.useCallback)(() => {
|
|
12928
12966
|
game.current = {
|
|
12929
12967
|
stars: Array.from({ length: 50 }, () => ({ x: Math.random() * W2, y: Math.random() * H2, a: 0.2 + Math.random() * 0.5 })),
|
|
12930
12968
|
player: { x: laneX(1), y: H2 - CAR_H - 16, w: CAR_W, h: CAR_H },
|
|
@@ -12938,15 +12976,15 @@ function RacerGame(props) {
|
|
|
12938
12976
|
over: false
|
|
12939
12977
|
};
|
|
12940
12978
|
}, []);
|
|
12941
|
-
(0,
|
|
12979
|
+
(0, import_react17.useEffect)(() => {
|
|
12942
12980
|
reset();
|
|
12943
12981
|
setStatus("play");
|
|
12944
12982
|
}, [reset]);
|
|
12945
|
-
const launch = (0,
|
|
12983
|
+
const launch = (0, import_react17.useCallback)(() => {
|
|
12946
12984
|
reset();
|
|
12947
12985
|
setStatus("play");
|
|
12948
12986
|
}, [reset]);
|
|
12949
|
-
(0,
|
|
12987
|
+
(0, import_react17.useEffect)(() => {
|
|
12950
12988
|
const draw2 = () => {
|
|
12951
12989
|
const g = game.current, ctx = canvasRef.current && canvasRef.current.getContext("2d");
|
|
12952
12990
|
if (!g || !ctx) return;
|
|
@@ -13048,7 +13086,7 @@ function RacerGame(props) {
|
|
|
13048
13086
|
});
|
|
13049
13087
|
return () => cancelAnimationFrame(raf);
|
|
13050
13088
|
}, []);
|
|
13051
|
-
const onKeyDown = (0,
|
|
13089
|
+
const onKeyDown = (0, import_react17.useCallback)((event) => {
|
|
13052
13090
|
if (pausedRef.current) return;
|
|
13053
13091
|
if (event.key === "ArrowLeft") {
|
|
13054
13092
|
event.preventDefault();
|
|
@@ -13061,11 +13099,11 @@ function RacerGame(props) {
|
|
|
13061
13099
|
launch();
|
|
13062
13100
|
}
|
|
13063
13101
|
}, [launch]);
|
|
13064
|
-
const onKeyUp = (0,
|
|
13102
|
+
const onKeyUp = (0, import_react17.useCallback)((event) => {
|
|
13065
13103
|
if (event.key === "ArrowLeft") keys.current.left = false;
|
|
13066
13104
|
else if (event.key === "ArrowRight") keys.current.right = false;
|
|
13067
13105
|
}, []);
|
|
13068
|
-
const onPointerMove = (0,
|
|
13106
|
+
const onPointerMove = (0, import_react17.useCallback)((e) => {
|
|
13069
13107
|
const g = game.current, cv = canvasRef.current;
|
|
13070
13108
|
if (!g || !cv) return;
|
|
13071
13109
|
const rect0 = cv.getBoundingClientRect();
|
|
@@ -13126,7 +13164,7 @@ var racerGame = { Game: RacerGame, Preview: RacerPreview, css: `
|
|
|
13126
13164
|
` };
|
|
13127
13165
|
|
|
13128
13166
|
// features/games/games/tank.jsx
|
|
13129
|
-
var
|
|
13167
|
+
var import_react18 = require("react");
|
|
13130
13168
|
|
|
13131
13169
|
// features/games/tank-core.js
|
|
13132
13170
|
var GRID = 15;
|
|
@@ -13334,27 +13372,27 @@ var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
|
13334
13372
|
var DIR_ANGLE = { up: 0, right: 90, down: 180, left: 270 };
|
|
13335
13373
|
var ENEMY_COLORS = ["#f87171", "#fb923c", "#c084fc", "#4ade80", "#38bdf8"];
|
|
13336
13374
|
function TankGame(props) {
|
|
13337
|
-
const [snap, setSnap] = (0,
|
|
13338
|
-
const [status, setStatus] = (0,
|
|
13339
|
-
const snapRef = (0,
|
|
13375
|
+
const [snap, setSnap] = (0, import_react18.useState)(initialState);
|
|
13376
|
+
const [status, setStatus] = (0, import_react18.useState)("play");
|
|
13377
|
+
const snapRef = (0, import_react18.useRef)(snap);
|
|
13340
13378
|
snapRef.current = snap;
|
|
13341
|
-
const keys = (0,
|
|
13342
|
-
const pausedRef = (0,
|
|
13379
|
+
const keys = (0, import_react18.useRef)({ dir: null, shoot: false });
|
|
13380
|
+
const pausedRef = (0, import_react18.useRef)(!!(props && props.paused));
|
|
13343
13381
|
pausedRef.current = !!(props && props.paused);
|
|
13344
|
-
const statusRef = (0,
|
|
13382
|
+
const statusRef = (0, import_react18.useRef)("play");
|
|
13345
13383
|
statusRef.current = status;
|
|
13346
|
-
const boardRef = (0,
|
|
13347
|
-
const start = (0,
|
|
13384
|
+
const boardRef = (0, import_react18.useRef)(null);
|
|
13385
|
+
const start = (0, import_react18.useCallback)(() => {
|
|
13348
13386
|
setSnap(initialState());
|
|
13349
13387
|
setStatus("play");
|
|
13350
13388
|
statusRef.current = "play";
|
|
13351
13389
|
}, []);
|
|
13352
|
-
const nextLvl = (0,
|
|
13390
|
+
const nextLvl = (0, import_react18.useCallback)(() => {
|
|
13353
13391
|
setSnap((s) => nextWave(s));
|
|
13354
13392
|
setStatus("play");
|
|
13355
13393
|
statusRef.current = "play";
|
|
13356
13394
|
}, []);
|
|
13357
|
-
(0,
|
|
13395
|
+
(0, import_react18.useEffect)(() => {
|
|
13358
13396
|
const timer = setInterval(() => {
|
|
13359
13397
|
if (pausedRef.current) return;
|
|
13360
13398
|
setSnap((s) => {
|
|
@@ -13373,8 +13411,8 @@ function TankGame(props) {
|
|
|
13373
13411
|
}, 120);
|
|
13374
13412
|
return () => clearInterval(timer);
|
|
13375
13413
|
}, []);
|
|
13376
|
-
const stageRef = (0,
|
|
13377
|
-
const onKeyDown = (0,
|
|
13414
|
+
const stageRef = (0, import_react18.useRef)(null);
|
|
13415
|
+
const onKeyDown = (0, import_react18.useCallback)((event) => {
|
|
13378
13416
|
if (pausedRef.current) return;
|
|
13379
13417
|
const map = { ArrowUp: "up", ArrowDown: "down", ArrowLeft: "left", ArrowRight: "right", w: "up", s: "down", a: "left", d: "right", W: "up", S: "down", A: "left", D: "right" };
|
|
13380
13418
|
const dir = map[event.key];
|
|
@@ -13391,7 +13429,7 @@ function TankGame(props) {
|
|
|
13391
13429
|
start();
|
|
13392
13430
|
}
|
|
13393
13431
|
}, [start]);
|
|
13394
|
-
const onKeyUp = (0,
|
|
13432
|
+
const onKeyUp = (0, import_react18.useCallback)((event) => {
|
|
13395
13433
|
const map = { ArrowUp: "up", ArrowDown: "down", ArrowLeft: "left", ArrowRight: "right", w: "up", s: "down", a: "left", d: "right", W: "up", S: "down", A: "left", D: "right" };
|
|
13396
13434
|
const dir = map[event.key];
|
|
13397
13435
|
if (dir && keys.current.dir === dir) keys.current.dir = null;
|
|
@@ -13533,8 +13571,8 @@ function initialDash() {
|
|
|
13533
13571
|
return { lane: 1, rocks: [], score: 0, shield: 3, running: true, nextId: 1 };
|
|
13534
13572
|
}
|
|
13535
13573
|
function useTaskPulse() {
|
|
13536
|
-
const [status, setStatus] = (0,
|
|
13537
|
-
const refresh = (0,
|
|
13574
|
+
const [status, setStatus] = (0, import_react19.useState)({ loading: true, active: [], error: false });
|
|
13575
|
+
const refresh = (0, import_react19.useCallback)(() => fetch("dsh-dock/animation/status", {
|
|
13538
13576
|
method: "POST",
|
|
13539
13577
|
headers: { "content-type": "application/json" },
|
|
13540
13578
|
body: "{}"
|
|
@@ -13542,7 +13580,7 @@ function useTaskPulse() {
|
|
|
13542
13580
|
if (!payload || !payload.ok) throw new Error("status unavailable");
|
|
13543
13581
|
setStatus({ loading: false, active: Array.isArray(payload.data && payload.data.active) ? payload.data.active : [], error: false });
|
|
13544
13582
|
}).catch(() => setStatus((current) => ({ loading: false, active: current.active || [], error: true }))), []);
|
|
13545
|
-
(0,
|
|
13583
|
+
(0, import_react19.useEffect)(() => {
|
|
13546
13584
|
refresh();
|
|
13547
13585
|
const timer = setInterval(refresh, 2600);
|
|
13548
13586
|
return () => clearInterval(timer);
|
|
@@ -13550,14 +13588,14 @@ function useTaskPulse() {
|
|
|
13550
13588
|
return status;
|
|
13551
13589
|
}
|
|
13552
13590
|
function DashGame(props) {
|
|
13553
|
-
const [dash, setDash] = (0,
|
|
13554
|
-
const pausedRef = (0,
|
|
13591
|
+
const [dash, setDash] = (0, import_react19.useState)(initialDash);
|
|
13592
|
+
const pausedRef = (0, import_react19.useRef)(!!(props && props.paused));
|
|
13555
13593
|
pausedRef.current = !!(props && props.paused);
|
|
13556
|
-
const move = (0,
|
|
13594
|
+
const move = (0, import_react19.useCallback)((delta) => setDash((current) => Object.assign({}, current, {
|
|
13557
13595
|
lane: Math.max(0, Math.min(LANES - 1, current.lane + delta))
|
|
13558
13596
|
})), []);
|
|
13559
|
-
const stageRef = (0,
|
|
13560
|
-
const onKeyDown = (0,
|
|
13597
|
+
const stageRef = (0, import_react19.useRef)(null);
|
|
13598
|
+
const onKeyDown = (0, import_react19.useCallback)((event) => {
|
|
13561
13599
|
if (event.key === "ArrowLeft" || event.key.toLowerCase() === "a") {
|
|
13562
13600
|
event.preventDefault();
|
|
13563
13601
|
move(-1);
|
|
@@ -13570,7 +13608,7 @@ function DashGame(props) {
|
|
|
13570
13608
|
}
|
|
13571
13609
|
}, [move, dash.running]);
|
|
13572
13610
|
useGameControls(stageRef, props.paused, onKeyDown);
|
|
13573
|
-
(0,
|
|
13611
|
+
(0, import_react19.useEffect)(() => {
|
|
13574
13612
|
const timer = setInterval(() => {
|
|
13575
13613
|
if (pausedRef.current || typeof document !== "undefined" && document.hidden) return;
|
|
13576
13614
|
setDash((current) => {
|
|
@@ -13647,10 +13685,10 @@ function DashGame(props) {
|
|
|
13647
13685
|
] });
|
|
13648
13686
|
}
|
|
13649
13687
|
function ReactorGame(props) {
|
|
13650
|
-
const [cells, setCells] = (0,
|
|
13651
|
-
const [moves, setMoves] = (0,
|
|
13652
|
-
const [cursor, setCursor] = (0,
|
|
13653
|
-
const gridRef = (0,
|
|
13688
|
+
const [cells, setCells] = (0, import_react19.useState)(makeReactor);
|
|
13689
|
+
const [moves, setMoves] = (0, import_react19.useState)(0);
|
|
13690
|
+
const [cursor, setCursor] = (0, import_react19.useState)(4);
|
|
13691
|
+
const gridRef = (0, import_react19.useRef)(null);
|
|
13654
13692
|
const solved = cells.every(Boolean);
|
|
13655
13693
|
const toggle = (index) => {
|
|
13656
13694
|
if (solved) return;
|
|
@@ -13860,8 +13898,8 @@ var gamesBus = {
|
|
|
13860
13898
|
}
|
|
13861
13899
|
};
|
|
13862
13900
|
function useGameWin() {
|
|
13863
|
-
const [state, setState] = (0,
|
|
13864
|
-
(0,
|
|
13901
|
+
const [state, setState] = (0, import_react19.useState)(gamesBus.state);
|
|
13902
|
+
(0, import_react19.useEffect)(() => gamesBus.subscribe(() => setState(gamesBus.state)), []);
|
|
13865
13903
|
return state;
|
|
13866
13904
|
}
|
|
13867
13905
|
var CATS = [
|
|
@@ -13977,12 +14015,12 @@ function snapFabX(side) {
|
|
|
13977
14015
|
function GameWindow(props) {
|
|
13978
14016
|
const game = props.game;
|
|
13979
14017
|
const status = useTaskPulse();
|
|
13980
|
-
const [win, setWin] = (0,
|
|
13981
|
-
const winRef = (0,
|
|
14018
|
+
const [win, setWin] = (0, import_react19.useState)(() => typeof window === "undefined" ? { mode: "normal", x: 14, y: 14, w: 470, h: 600 } : restoreWinGeom());
|
|
14019
|
+
const winRef = (0, import_react19.useRef)(win);
|
|
13982
14020
|
winRef.current = win;
|
|
13983
|
-
const pickerRef = (0,
|
|
14021
|
+
const pickerRef = (0, import_react19.useRef)(props.picker);
|
|
13984
14022
|
pickerRef.current = props.picker;
|
|
13985
|
-
(0,
|
|
14023
|
+
(0, import_react19.useEffect)(() => {
|
|
13986
14024
|
const onKey = (e) => {
|
|
13987
14025
|
if (e.key !== "Escape") return;
|
|
13988
14026
|
if (pickerRef.current) gamesBus.closePicker();
|
|
@@ -14070,12 +14108,12 @@ function GameWindow(props) {
|
|
|
14070
14108
|
] });
|
|
14071
14109
|
}
|
|
14072
14110
|
function GameFab(props) {
|
|
14073
|
-
const [pos, setPos] = (0,
|
|
14074
|
-
const [dragging, setDragging] = (0,
|
|
14075
|
-
const dragRef = (0,
|
|
14076
|
-
const clickBlockRef = (0,
|
|
14077
|
-
const sideRef = (0,
|
|
14078
|
-
(0,
|
|
14111
|
+
const [pos, setPos] = (0, import_react19.useState)(null);
|
|
14112
|
+
const [dragging, setDragging] = (0, import_react19.useState)(false);
|
|
14113
|
+
const dragRef = (0, import_react19.useRef)(null);
|
|
14114
|
+
const clickBlockRef = (0, import_react19.useRef)(false);
|
|
14115
|
+
const sideRef = (0, import_react19.useRef)("left");
|
|
14116
|
+
(0, import_react19.useEffect)(() => {
|
|
14079
14117
|
if (typeof window === "undefined") return;
|
|
14080
14118
|
let next = { side: "left", y: Math.round(window.innerHeight * 0.34) };
|
|
14081
14119
|
try {
|
|
@@ -14090,7 +14128,7 @@ function GameFab(props) {
|
|
|
14090
14128
|
y: Math.min(Math.max(8, next.y), Math.max(8, window.innerHeight - FAB_H - 8))
|
|
14091
14129
|
});
|
|
14092
14130
|
}, []);
|
|
14093
|
-
(0,
|
|
14131
|
+
(0, import_react19.useEffect)(() => {
|
|
14094
14132
|
if (typeof window === "undefined") return;
|
|
14095
14133
|
const update = () => {
|
|
14096
14134
|
if (dragRef.current) return;
|
|
@@ -14185,8 +14223,8 @@ function GamepadIcon(props) {
|
|
|
14185
14223
|
}
|
|
14186
14224
|
function GamesOverlay() {
|
|
14187
14225
|
const winState = useGameWin();
|
|
14188
|
-
const [panelOpen, setPanelOpen2] = (0,
|
|
14189
|
-
(0,
|
|
14226
|
+
const [panelOpen, setPanelOpen2] = (0, import_react19.useState)(panelNav.open);
|
|
14227
|
+
(0, import_react19.useEffect)(() => {
|
|
14190
14228
|
setPanelOpen2(panelNav.open);
|
|
14191
14229
|
return subscribePanel(() => setPanelOpen2(panelNav.open));
|
|
14192
14230
|
}, []);
|
|
@@ -14289,7 +14327,7 @@ var dgcovGroupCss = `
|
|
|
14289
14327
|
|
|
14290
14328
|
`;
|
|
14291
14329
|
var css5 = [baseCss, tetrisGame.css, sokobanGame.css, gomokuGame.css, xiangqiGame.css, snakeGame.css, breakoutGame.css, racerGame.css, tankGame.css, dgcovGroupCss].filter(Boolean).join("\n");
|
|
14292
|
-
var
|
|
14330
|
+
var feature9 = {
|
|
14293
14331
|
id: "games",
|
|
14294
14332
|
name: "\u8DA3\u5473\u6E38\u620F",
|
|
14295
14333
|
order: 135,
|
|
@@ -14303,7 +14341,7 @@ var feature11 = {
|
|
|
14303
14341
|
};
|
|
14304
14342
|
|
|
14305
14343
|
// features/mobile-relay/view.jsx
|
|
14306
|
-
var
|
|
14344
|
+
var import_react20 = require("react");
|
|
14307
14345
|
var import_qrcode = __toESM(require_browser(), 1);
|
|
14308
14346
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
14309
14347
|
function rpc(method, payload) {
|
|
@@ -14340,8 +14378,8 @@ function RelayIcon({ name, size = 18 }) {
|
|
|
14340
14378
|
] });
|
|
14341
14379
|
}
|
|
14342
14380
|
function useCompact() {
|
|
14343
|
-
const [compact, setCompact] = (0,
|
|
14344
|
-
(0,
|
|
14381
|
+
const [compact, setCompact] = (0, import_react20.useState)(() => typeof window !== "undefined" && window.matchMedia("(max-width: 680px)").matches);
|
|
14382
|
+
(0, import_react20.useEffect)(() => {
|
|
14345
14383
|
const media = window.matchMedia("(max-width: 680px)");
|
|
14346
14384
|
const update = () => setCompact(media.matches);
|
|
14347
14385
|
update();
|
|
@@ -14352,23 +14390,23 @@ function useCompact() {
|
|
|
14352
14390
|
}
|
|
14353
14391
|
function RemoteCard() {
|
|
14354
14392
|
const compact = useCompact();
|
|
14355
|
-
const [lan, setLan] = (0,
|
|
14356
|
-
const [username, setUsername] = (0,
|
|
14357
|
-
const [password, setPassword] = (0,
|
|
14358
|
-
const [newPassword, setNewPassword] = (0,
|
|
14359
|
-
const [port, setPort] = (0,
|
|
14360
|
-
const [address, setAddress] = (0,
|
|
14361
|
-
const [qr, setQr] = (0,
|
|
14362
|
-
const [busy, setBusy] = (0,
|
|
14363
|
-
const [message, setMessage] = (0,
|
|
14364
|
-
const [messageKind, setMessageKind] = (0,
|
|
14365
|
-
const [changing, setChanging] = (0,
|
|
14366
|
-
const [remote, setRemote] = (0,
|
|
14367
|
-
const notify = (0,
|
|
14393
|
+
const [lan, setLan] = (0, import_react20.useState)(null);
|
|
14394
|
+
const [username, setUsername] = (0, import_react20.useState)("");
|
|
14395
|
+
const [password, setPassword] = (0, import_react20.useState)("");
|
|
14396
|
+
const [newPassword, setNewPassword] = (0, import_react20.useState)("");
|
|
14397
|
+
const [port, setPort] = (0, import_react20.useState)("");
|
|
14398
|
+
const [address, setAddress] = (0, import_react20.useState)("");
|
|
14399
|
+
const [qr, setQr] = (0, import_react20.useState)("");
|
|
14400
|
+
const [busy, setBusy] = (0, import_react20.useState)("");
|
|
14401
|
+
const [message, setMessage] = (0, import_react20.useState)("");
|
|
14402
|
+
const [messageKind, setMessageKind] = (0, import_react20.useState)("error");
|
|
14403
|
+
const [changing, setChanging] = (0, import_react20.useState)(false);
|
|
14404
|
+
const [remote, setRemote] = (0, import_react20.useState)(false);
|
|
14405
|
+
const notify = (0, import_react20.useCallback)((text, kind) => {
|
|
14368
14406
|
setMessage(text);
|
|
14369
14407
|
setMessageKind(kind || "error");
|
|
14370
14408
|
}, []);
|
|
14371
|
-
const refresh = (0,
|
|
14409
|
+
const refresh = (0, import_react20.useCallback)(async () => {
|
|
14372
14410
|
try {
|
|
14373
14411
|
const data = await rpc("lan");
|
|
14374
14412
|
setLan(data);
|
|
@@ -14378,19 +14416,19 @@ function RemoteCard() {
|
|
|
14378
14416
|
notify(e && e.message ? e.message : String(e));
|
|
14379
14417
|
}
|
|
14380
14418
|
}, [notify]);
|
|
14381
|
-
(0,
|
|
14419
|
+
(0, import_react20.useEffect)(() => {
|
|
14382
14420
|
refresh();
|
|
14383
14421
|
const timer = setInterval(refresh, 3e3);
|
|
14384
14422
|
return () => clearInterval(timer);
|
|
14385
14423
|
}, [refresh]);
|
|
14386
|
-
(0,
|
|
14424
|
+
(0, import_react20.useEffect)(() => {
|
|
14387
14425
|
fetch("/__dsh_auth/health", { method: "POST" }).then((r) => setRemote(Boolean(r.ok))).catch(() => setRemote(false));
|
|
14388
14426
|
}, []);
|
|
14389
14427
|
const active = Boolean(lan && lan.gatewayActive);
|
|
14390
14428
|
const gatewayPort = lan && lan.gatewayPort ? lan.gatewayPort : 3081;
|
|
14391
14429
|
const suggestedPort = lan && lan.mainPort ? lan.mainPort + 1 : gatewayPort;
|
|
14392
|
-
const lanLink = (0,
|
|
14393
|
-
(0,
|
|
14430
|
+
const lanLink = (0, import_react20.useMemo)(() => address && active ? "http://" + address + ":" + gatewayPort : "", [address, active, gatewayPort]);
|
|
14431
|
+
(0, import_react20.useEffect)(() => {
|
|
14394
14432
|
let live = true;
|
|
14395
14433
|
if (!lanLink) {
|
|
14396
14434
|
setQr("");
|
|
@@ -14607,8 +14645,8 @@ function MobileRelayView() {
|
|
|
14607
14645
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(RemoteCard, {});
|
|
14608
14646
|
}
|
|
14609
14647
|
function MobileRelayHomeStat() {
|
|
14610
|
-
const [summary, setSummary] = (0,
|
|
14611
|
-
(0,
|
|
14648
|
+
const [summary, setSummary] = (0, import_react20.useState)("\u672A\u5F00\u542F\uFF0C\u5F00\u542F\u540E\u53EF\u8FDC\u7A0B\u767B\u5F55");
|
|
14649
|
+
(0, import_react20.useEffect)(() => {
|
|
14612
14650
|
const refresh = () => {
|
|
14613
14651
|
rpc("lan").then((data) => {
|
|
14614
14652
|
const devices = typeof data.devices === "number" && data.devices > 0 ? " \xB7 " + data.devices + " \u53F0\u8BBE\u5907\u5728\u7EBF" : "";
|
|
@@ -14622,7 +14660,7 @@ function MobileRelayHomeStat() {
|
|
|
14622
14660
|
}, []);
|
|
14623
14661
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: summary });
|
|
14624
14662
|
}
|
|
14625
|
-
var
|
|
14663
|
+
var feature10 = {
|
|
14626
14664
|
id: "mobile-relay",
|
|
14627
14665
|
name: "\u8FDC\u7A0B\u8BBF\u95EE",
|
|
14628
14666
|
order: 80,
|
|
@@ -14636,9 +14674,726 @@ var feature12 = {
|
|
|
14636
14674
|
HomeStat: MobileRelayHomeStat
|
|
14637
14675
|
};
|
|
14638
14676
|
|
|
14677
|
+
// features/mcpconfig/view.js
|
|
14678
|
+
var import_react21 = __toESM(require("react"), 1);
|
|
14679
|
+
var ENDPOINT = "dsh-dock/mcpconfig";
|
|
14680
|
+
var SERVER_NAME_RE = /^[A-Za-z0-9_-]{1,32}$/;
|
|
14681
|
+
var ENV_KEY_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
14682
|
+
var DEFAULT_TOOL_TIMEOUT_MS = 6e4;
|
|
14683
|
+
var TRANSPORTS = [
|
|
14684
|
+
{ value: "stdio", label: "stdio\uFF08\u672C\u673A\u5B50\u8FDB\u7A0B\uFF09" },
|
|
14685
|
+
{ value: "streamable-http", label: "streamable-http\uFF08\u8FDC\u7AEF HTTP\uFF09" }
|
|
14686
|
+
];
|
|
14687
|
+
var STATE_TEXT = { active: "\u8FD0\u884C\u4E2D", inactive: "\u672A\u8FDE\u63A5", failed: "\u5931\u8D25", disabled: "\u5DF2\u505C\u7528", unknown: "\u672A\u77E5" };
|
|
14688
|
+
function timeoutSignal(ms) {
|
|
14689
|
+
try {
|
|
14690
|
+
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") return AbortSignal.timeout(ms);
|
|
14691
|
+
} catch (e) {
|
|
14692
|
+
}
|
|
14693
|
+
return void 0;
|
|
14694
|
+
}
|
|
14695
|
+
function errorText(body, fallback) {
|
|
14696
|
+
if (body && typeof body.error === "string" && body.error) return body.error;
|
|
14697
|
+
if (body && body.error && typeof body.error.message === "string" && body.error.message) return body.error.message;
|
|
14698
|
+
return fallback;
|
|
14699
|
+
}
|
|
14700
|
+
function messageOf(e) {
|
|
14701
|
+
return e && e.message || String(e);
|
|
14702
|
+
}
|
|
14703
|
+
function linesToEnv(text) {
|
|
14704
|
+
const out = {};
|
|
14705
|
+
for (const line of String(text || "").split(/\r?\n/)) {
|
|
14706
|
+
const raw = line.trim();
|
|
14707
|
+
if (!raw) continue;
|
|
14708
|
+
const at = raw.indexOf("=");
|
|
14709
|
+
if (at < 0) {
|
|
14710
|
+
out[raw] = "";
|
|
14711
|
+
continue;
|
|
14712
|
+
}
|
|
14713
|
+
const key = raw.slice(0, at).trim();
|
|
14714
|
+
if (key) out[key] = raw.slice(at + 1).trim();
|
|
14715
|
+
}
|
|
14716
|
+
return out;
|
|
14717
|
+
}
|
|
14718
|
+
function linesToHeaders(text) {
|
|
14719
|
+
const out = {};
|
|
14720
|
+
for (const line of String(text || "").split(/\r?\n/)) {
|
|
14721
|
+
const raw = line.trim();
|
|
14722
|
+
if (!raw) continue;
|
|
14723
|
+
const at = raw.indexOf(":");
|
|
14724
|
+
if (at < 0) {
|
|
14725
|
+
out[raw] = "";
|
|
14726
|
+
continue;
|
|
14727
|
+
}
|
|
14728
|
+
const key = raw.slice(0, at).trim();
|
|
14729
|
+
if (key) out[key] = raw.slice(at + 1).trim();
|
|
14730
|
+
}
|
|
14731
|
+
return out;
|
|
14732
|
+
}
|
|
14733
|
+
function mapToEnvText(map) {
|
|
14734
|
+
return Object.keys(map || {}).map((k) => {
|
|
14735
|
+
const v = map[k];
|
|
14736
|
+
return k + "=" + (typeof v === "string" ? v : v === void 0 || v === null ? "" : JSON.stringify(v));
|
|
14737
|
+
}).join("\n");
|
|
14738
|
+
}
|
|
14739
|
+
function mapToHeadersText(map) {
|
|
14740
|
+
return Object.keys(map || {}).map((k) => {
|
|
14741
|
+
const v = map[k];
|
|
14742
|
+
return k + ": " + (typeof v === "string" ? v : v === void 0 || v === null ? "" : JSON.stringify(v));
|
|
14743
|
+
}).join("\n");
|
|
14744
|
+
}
|
|
14745
|
+
function argsToText(args) {
|
|
14746
|
+
return (Array.isArray(args) ? args : []).map((x) => typeof x === "string" ? x : String(x)).join("\n");
|
|
14747
|
+
}
|
|
14748
|
+
function textToArgs(text) {
|
|
14749
|
+
return String(text || "").split(/\r?\n/).map((x) => x.trim()).filter(Boolean);
|
|
14750
|
+
}
|
|
14751
|
+
function toDraft(server) {
|
|
14752
|
+
const s = server && typeof server === "object" ? server : {};
|
|
14753
|
+
return {
|
|
14754
|
+
serverName: typeof s.serverName === "string" ? s.serverName : "",
|
|
14755
|
+
transport: s.transport === "streamable-http" ? "streamable-http" : "stdio",
|
|
14756
|
+
command: typeof s.command === "string" ? s.command : "",
|
|
14757
|
+
args: Array.isArray(s.args) ? s.args.filter((x) => typeof x === "string") : [],
|
|
14758
|
+
env: s.env && typeof s.env === "object" && !Array.isArray(s.env) ? s.env : {},
|
|
14759
|
+
cwd: typeof s.cwd === "string" ? s.cwd : "",
|
|
14760
|
+
url: typeof s.url === "string" ? s.url : "",
|
|
14761
|
+
headers: s.headers && typeof s.headers === "object" && !Array.isArray(s.headers) ? s.headers : {},
|
|
14762
|
+
enabled: s.enabled !== false,
|
|
14763
|
+
failOnStartupError: s.failOnStartupError === true,
|
|
14764
|
+
toolCallTimeoutMs: Number.isFinite(s.toolCallTimeoutMs) && s.toolCallTimeoutMs > 0 ? s.toolCallTimeoutMs : DEFAULT_TOOL_TIMEOUT_MS,
|
|
14765
|
+
// 只读展示字段(POST 不含这些)
|
|
14766
|
+
state: typeof s.state === "string" ? s.state : "unknown",
|
|
14767
|
+
error: typeof s.error === "string" && s.error ? s.error : null,
|
|
14768
|
+
tools: Array.isArray(s.tools) ? s.tools.filter((x) => typeof x === "string") : [],
|
|
14769
|
+
toolCount: Number.isFinite(s.toolCount) ? s.toolCount : Array.isArray(s.tools) ? s.tools.length : 0
|
|
14770
|
+
};
|
|
14771
|
+
}
|
|
14772
|
+
function toSaveShape(draft) {
|
|
14773
|
+
const base = {
|
|
14774
|
+
serverName: draft.serverName,
|
|
14775
|
+
transport: draft.transport === "streamable-http" ? "streamable-http" : "stdio",
|
|
14776
|
+
enabled: draft.enabled !== false,
|
|
14777
|
+
failOnStartupError: draft.failOnStartupError === true,
|
|
14778
|
+
toolCallTimeoutMs: draft.toolCallTimeoutMs || DEFAULT_TOOL_TIMEOUT_MS
|
|
14779
|
+
};
|
|
14780
|
+
if (base.transport === "streamable-http") {
|
|
14781
|
+
return Object.assign(base, { url: draft.url || "", headers: draft.headers || {} });
|
|
14782
|
+
}
|
|
14783
|
+
return Object.assign(base, {
|
|
14784
|
+
command: draft.command || "",
|
|
14785
|
+
args: Array.isArray(draft.args) ? draft.args : [],
|
|
14786
|
+
env: draft.env || {},
|
|
14787
|
+
cwd: draft.cwd || ""
|
|
14788
|
+
});
|
|
14789
|
+
}
|
|
14790
|
+
function emptyForm() {
|
|
14791
|
+
return {
|
|
14792
|
+
mode: "create",
|
|
14793
|
+
index: -1,
|
|
14794
|
+
serverName: "",
|
|
14795
|
+
transport: "stdio",
|
|
14796
|
+
command: "",
|
|
14797
|
+
argsText: "",
|
|
14798
|
+
envText: "",
|
|
14799
|
+
cwd: "",
|
|
14800
|
+
url: "",
|
|
14801
|
+
headersText: "",
|
|
14802
|
+
toolCallTimeoutMs: String(DEFAULT_TOOL_TIMEOUT_MS),
|
|
14803
|
+
failOnStartupError: false,
|
|
14804
|
+
enabled: true
|
|
14805
|
+
};
|
|
14806
|
+
}
|
|
14807
|
+
function formFrom(draft, index) {
|
|
14808
|
+
return {
|
|
14809
|
+
mode: "edit",
|
|
14810
|
+
index,
|
|
14811
|
+
serverName: draft.serverName,
|
|
14812
|
+
transport: draft.transport,
|
|
14813
|
+
command: draft.command || "",
|
|
14814
|
+
argsText: argsToText(draft.args),
|
|
14815
|
+
envText: mapToEnvText(draft.env),
|
|
14816
|
+
cwd: draft.cwd || "",
|
|
14817
|
+
url: draft.url || "",
|
|
14818
|
+
headersText: mapToHeadersText(draft.headers),
|
|
14819
|
+
toolCallTimeoutMs: String(draft.toolCallTimeoutMs || DEFAULT_TOOL_TIMEOUT_MS),
|
|
14820
|
+
failOnStartupError: !!draft.failOnStartupError,
|
|
14821
|
+
enabled: draft.enabled !== false
|
|
14822
|
+
};
|
|
14823
|
+
}
|
|
14824
|
+
function formToDraft(form, drafts) {
|
|
14825
|
+
const serverName = String(form.serverName || "").trim();
|
|
14826
|
+
if (!SERVER_NAME_RE.test(serverName)) {
|
|
14827
|
+
return { error: "serverName \u975E\u6CD5\uFF1A\u987B\u5339\u914D " + SERVER_NAME_RE + "\uFF081~32 \u4F4D\u5B57\u6BCD\u3001\u6570\u5B57\u3001_ \u6216 -\uFF09" };
|
|
14828
|
+
}
|
|
14829
|
+
const duplicate = drafts.some((d, i) => i !== form.index && d.serverName === serverName);
|
|
14830
|
+
if (duplicate) return { error: "serverName\u300C" + serverName + "\u300D\u5DF2\u5B58\u5728\uFF0C\u8BF7\u6362\u4E00\u4E2A\u540D\u5B57" };
|
|
14831
|
+
const transport = form.transport === "streamable-http" ? "streamable-http" : "stdio";
|
|
14832
|
+
const timeoutRaw = String(form.toolCallTimeoutMs === void 0 ? "" : form.toolCallTimeoutMs).trim();
|
|
14833
|
+
const timeout = timeoutRaw === "" ? DEFAULT_TOOL_TIMEOUT_MS : Number(timeoutRaw);
|
|
14834
|
+
if (!Number.isFinite(timeout) || timeout <= 0) return { error: "toolCallTimeoutMs \u987B\u4E3A\u6B63\u6574\u6570\uFF08\u6BEB\u79D2\uFF09\uFF0C\u9ED8\u8BA4 " + DEFAULT_TOOL_TIMEOUT_MS };
|
|
14835
|
+
const base = {
|
|
14836
|
+
serverName,
|
|
14837
|
+
transport,
|
|
14838
|
+
enabled: form.mode === "create" ? form.enabled !== false : drafts[form.index] ? drafts[form.index].enabled !== false : true,
|
|
14839
|
+
failOnStartupError: !!form.failOnStartupError,
|
|
14840
|
+
toolCallTimeoutMs: Math.floor(timeout)
|
|
14841
|
+
};
|
|
14842
|
+
if (transport === "streamable-http") {
|
|
14843
|
+
const url = String(form.url || "").trim();
|
|
14844
|
+
if (!/^https?:\/\//i.test(url)) return { error: "url \u975E\u6CD5\uFF1A\u987B\u4EE5 http:// \u6216 https:// \u5F00\u5934" };
|
|
14845
|
+
const headers = linesToHeaders(form.headersText);
|
|
14846
|
+
for (const key of Object.keys(headers)) {
|
|
14847
|
+
if (!/^[A-Za-z0-9-]+$/.test(key)) return { error: "header \u540D\u975E\u6CD5\uFF1A" + key };
|
|
14848
|
+
}
|
|
14849
|
+
return { draft: Object.assign(base, { url, headers, command: "", args: [], env: {}, cwd: "" }) };
|
|
14850
|
+
}
|
|
14851
|
+
const command = String(form.command || "").trim();
|
|
14852
|
+
if (!command) return { error: "stdio \u4F20\u8F93\u5FC5\u987B\u586B\u5199 command\uFF08\u53EF\u6267\u884C\u6587\u4EF6\u8DEF\u5F84\uFF09" };
|
|
14853
|
+
const env = linesToEnv(form.envText);
|
|
14854
|
+
for (const key of Object.keys(env)) {
|
|
14855
|
+
if (!ENV_KEY_RE.test(key)) return { error: "\u73AF\u5883\u53D8\u91CF\u540D\u975E\u6CD5\uFF1A" + key + "\uFF08\u987B\u5339\u914D " + ENV_KEY_RE + "\uFF09" };
|
|
14856
|
+
}
|
|
14857
|
+
return { draft: Object.assign(base, { command, args: textToArgs(form.argsText), env, cwd: String(form.cwd || "").trim(), url: "", headers: {} }) };
|
|
14858
|
+
}
|
|
14859
|
+
function stateDotClass(state) {
|
|
14860
|
+
if (state === "active") return "dkmc-dot ok";
|
|
14861
|
+
if (state === "failed") return "dkmc-dot err";
|
|
14862
|
+
if (state === "inactive") return "dkmc-dot idle";
|
|
14863
|
+
return "dkmc-dot off";
|
|
14864
|
+
}
|
|
14865
|
+
function stateClass(state) {
|
|
14866
|
+
if (state === "active") return "dkmc-state ok";
|
|
14867
|
+
if (state === "failed") return "dkmc-state err";
|
|
14868
|
+
return "dkmc-state";
|
|
14869
|
+
}
|
|
14870
|
+
function Field(props) {
|
|
14871
|
+
return import_react21.default.createElement(
|
|
14872
|
+
"div",
|
|
14873
|
+
{ className: "dkmc-field" },
|
|
14874
|
+
import_react21.default.createElement("label", { className: "dkmc-flabel" }, props.label),
|
|
14875
|
+
props.children,
|
|
14876
|
+
props.hint ? import_react21.default.createElement("p", { className: "dkmc-hint" }, props.hint) : null
|
|
14877
|
+
);
|
|
14878
|
+
}
|
|
14879
|
+
function ServerForm(props) {
|
|
14880
|
+
const form = props.form;
|
|
14881
|
+
const patch = props.patch;
|
|
14882
|
+
const onSave = props.onSave;
|
|
14883
|
+
const onCancel = props.onCancel;
|
|
14884
|
+
const saving = props.saving;
|
|
14885
|
+
const onExample = props.onExample;
|
|
14886
|
+
const input = (p) => import_react21.default.createElement("input", Object.assign({ className: "dkmc-input" }, p));
|
|
14887
|
+
const isEdit = form.mode === "edit";
|
|
14888
|
+
return import_react21.default.createElement(
|
|
14889
|
+
"div",
|
|
14890
|
+
{ className: "dkmc-editor" },
|
|
14891
|
+
import_react21.default.createElement(
|
|
14892
|
+
"div",
|
|
14893
|
+
{ className: "dkmc-editor-head" },
|
|
14894
|
+
import_react21.default.createElement("span", { className: "dkmc-editor-title" }, isEdit ? "\u7F16\u8F91 MCP \u670D\u52A1\u5668" : "\u65B0\u589E MCP \u670D\u52A1\u5668"),
|
|
14895
|
+
import_react21.default.createElement("span", { className: "dkmc-editor-sub" }, isEdit ? form.serverName : "\u5199\u56DE cordis.patch.yml \u7684\u6258\u7BA1\u5757\u5E76\u70ED\u5E94\u7528"),
|
|
14896
|
+
!isEdit && typeof onExample === "function" ? import_react21.default.createElement("button", {
|
|
14897
|
+
type: "button",
|
|
14898
|
+
className: "dkmc-btn ghost sm dkmc-example",
|
|
14899
|
+
title: "\u4E00\u952E\u586B\u5165\u672C\u673A Xiaomi-OCR MCP \u670D\u52A1\u5668\u914D\u7F6E",
|
|
14900
|
+
disabled: saving,
|
|
14901
|
+
onClick: onExample
|
|
14902
|
+
}, "\u586B\u5165\u672C\u673A Xiaomi-OCR \u793A\u4F8B") : null
|
|
14903
|
+
),
|
|
14904
|
+
props.error ? import_react21.default.createElement("p", { className: "dkmc-error" }, props.error) : null,
|
|
14905
|
+
Field({
|
|
14906
|
+
label: "serverName",
|
|
14907
|
+
hint: "\u5DE5\u5177\u540D\u524D\u7F00\uFF1A\u6A21\u578B\u770B\u5230\u7684\u662F mcp__<serverName>__<tool>\uFF1B\u987B\u5339\u914D " + SERVER_NAME_RE
|
|
14908
|
+
}, input({
|
|
14909
|
+
value: form.serverName,
|
|
14910
|
+
placeholder: "xiaomi_ocr",
|
|
14911
|
+
disabled: isEdit,
|
|
14912
|
+
onChange: (e) => patch({ serverName: e.target.value })
|
|
14913
|
+
})),
|
|
14914
|
+
Field({ label: "\u4F20\u8F93\u65B9\u5F0F" }, import_react21.default.createElement(
|
|
14915
|
+
"select",
|
|
14916
|
+
{
|
|
14917
|
+
className: "dkmc-input dkmc-select",
|
|
14918
|
+
value: form.transport,
|
|
14919
|
+
onChange: (e) => patch({ transport: e.target.value })
|
|
14920
|
+
},
|
|
14921
|
+
TRANSPORTS.map((t) => import_react21.default.createElement("option", { key: t.value, value: t.value }, t.label))
|
|
14922
|
+
)),
|
|
14923
|
+
form.transport === "streamable-http" ? Field(
|
|
14924
|
+
{ label: "url", hint: "MCP \u7AEF\u70B9\uFF08Streamable HTTP\uFF09\uFF0C\u987B\u4EE5 http:// \u6216 https:// \u5F00\u5934" },
|
|
14925
|
+
input({ value: form.url, placeholder: "http://127.0.0.1:3000/mcp", onChange: (e) => patch({ url: e.target.value }) })
|
|
14926
|
+
) : Field(
|
|
14927
|
+
{ label: "command", hint: "\u53EF\u6267\u884C\u6587\u4EF6\u7EDD\u5BF9\u8DEF\u5F84\u6216 PATH \u4E2D\u7684\u547D\u4EE4" },
|
|
14928
|
+
input({ value: form.command, placeholder: "/usr/bin/python3", onChange: (e) => patch({ command: e.target.value }) })
|
|
14929
|
+
),
|
|
14930
|
+
form.transport === "streamable-http" ? Field(
|
|
14931
|
+
{ label: "headers\uFF08\u6BCF\u884C\u4E00\u4E2A KEY: VALUE\uFF09", hint: "\u5982 Authorization: Bearer xxx\uFF1B\u503C\u4E3A\u7A7A\u7684\u884C\u5FFD\u7565" },
|
|
14932
|
+
import_react21.default.createElement("textarea", {
|
|
14933
|
+
className: "dkmc-input dkmc-textarea",
|
|
14934
|
+
rows: 4,
|
|
14935
|
+
spellCheck: false,
|
|
14936
|
+
value: form.headersText,
|
|
14937
|
+
placeholder: "Authorization: Bearer xxxxx",
|
|
14938
|
+
onChange: (e) => patch({ headersText: e.target.value })
|
|
14939
|
+
})
|
|
14940
|
+
) : import_react21.default.createElement(
|
|
14941
|
+
import_react21.default.Fragment,
|
|
14942
|
+
null,
|
|
14943
|
+
Field(
|
|
14944
|
+
{ label: "args\uFF08\u6BCF\u884C\u4E00\u4E2A\u53C2\u6570\uFF09" },
|
|
14945
|
+
import_react21.default.createElement("textarea", {
|
|
14946
|
+
className: "dkmc-input dkmc-textarea",
|
|
14947
|
+
rows: 4,
|
|
14948
|
+
spellCheck: false,
|
|
14949
|
+
value: form.argsText,
|
|
14950
|
+
placeholder: "/www/wwwroot/xiaomi-ocr/mcp_ocr.py",
|
|
14951
|
+
onChange: (e) => patch({ argsText: e.target.value })
|
|
14952
|
+
})
|
|
14953
|
+
),
|
|
14954
|
+
Field(
|
|
14955
|
+
{ label: "env\uFF08\u6BCF\u884C\u4E00\u4E2A KEY=VALUE\uFF09", hint: "\u73AF\u5883\u53D8\u91CF\u4F1A\u660E\u6587\u5199\u8FDB profile \u8865\u4E01\u5C42\uFF08\u6587\u4EF6 0600\uFF0C\u4EC5\u672C\u673A\u53EF\u8BFB\uFF09\uFF1B\u6CA1\u6709\u53EF\u7559\u7A7A" },
|
|
14956
|
+
import_react21.default.createElement("textarea", {
|
|
14957
|
+
className: "dkmc-input dkmc-textarea",
|
|
14958
|
+
rows: 3,
|
|
14959
|
+
spellCheck: false,
|
|
14960
|
+
value: form.envText,
|
|
14961
|
+
placeholder: "PYTHONUNBUFFERED=1",
|
|
14962
|
+
onChange: (e) => patch({ envText: e.target.value })
|
|
14963
|
+
})
|
|
14964
|
+
),
|
|
14965
|
+
Field(
|
|
14966
|
+
{ label: "cwd\uFF08\u53EF\u9009\uFF09" },
|
|
14967
|
+
input({ value: form.cwd, placeholder: "/www/wwwroot/xiaomi-ocr", onChange: (e) => patch({ cwd: e.target.value }) })
|
|
14968
|
+
)
|
|
14969
|
+
),
|
|
14970
|
+
import_react21.default.createElement(
|
|
14971
|
+
"details",
|
|
14972
|
+
{ className: "dkmc-advanced" },
|
|
14973
|
+
import_react21.default.createElement("summary", { className: "dkmc-summary" }, "\u9AD8\u7EA7"),
|
|
14974
|
+
import_react21.default.createElement(
|
|
14975
|
+
"div",
|
|
14976
|
+
{ className: "dkmc-advanced-body" },
|
|
14977
|
+
Field(
|
|
14978
|
+
{ label: "toolCallTimeoutMs", hint: "\u5355\u6B21 MCP \u5DE5\u5177\u8C03\u7528\u8D85\u65F6\uFF08\u6BEB\u79D2\uFF09\uFF0C\u9ED8\u8BA4 " + DEFAULT_TOOL_TIMEOUT_MS },
|
|
14979
|
+
input({ value: form.toolCallTimeoutMs, inputMode: "numeric", placeholder: String(DEFAULT_TOOL_TIMEOUT_MS), onChange: (e) => patch({ toolCallTimeoutMs: e.target.value }) })
|
|
14980
|
+
),
|
|
14981
|
+
import_react21.default.createElement(
|
|
14982
|
+
"label",
|
|
14983
|
+
{ className: "dkmc-check" },
|
|
14984
|
+
import_react21.default.createElement("input", {
|
|
14985
|
+
type: "checkbox",
|
|
14986
|
+
checked: !!form.failOnStartupError,
|
|
14987
|
+
onChange: () => patch({ failOnStartupError: !form.failOnStartupError })
|
|
14988
|
+
}),
|
|
14989
|
+
"\u9996\u6B21\u8FDE\u63A5\u5931\u8D25\u65F6\u62D2\u7EDD\u542F\u7528\u8BE5\u884C\uFF08failOnStartupError\uFF09"
|
|
14990
|
+
)
|
|
14991
|
+
)
|
|
14992
|
+
),
|
|
14993
|
+
import_react21.default.createElement(
|
|
14994
|
+
"div",
|
|
14995
|
+
{ className: "dkmc-editor-actions" },
|
|
14996
|
+
import_react21.default.createElement("button", { type: "button", className: "dkmc-btn ghost", disabled: saving, onClick: onCancel }, "\u53D6\u6D88"),
|
|
14997
|
+
import_react21.default.createElement(
|
|
14998
|
+
"button",
|
|
14999
|
+
{ type: "button", className: "dkmc-btn primary", disabled: saving, onClick: onSave },
|
|
15000
|
+
saving ? "\u4FDD\u5B58\u4E2D\u2026" : isEdit ? "\u4FDD\u5B58\u4FEE\u6539" : "\u65B0\u589E\u5E76\u4FDD\u5B58"
|
|
15001
|
+
)
|
|
15002
|
+
)
|
|
15003
|
+
);
|
|
15004
|
+
}
|
|
15005
|
+
function McpConfigView() {
|
|
15006
|
+
const [snap, setSnap] = import_react21.default.useState({ loading: true, error: null, data: null });
|
|
15007
|
+
const [drafts, setDrafts] = import_react21.default.useState([]);
|
|
15008
|
+
const [form, setForm] = import_react21.default.useState(null);
|
|
15009
|
+
const [formError, setFormError] = import_react21.default.useState(null);
|
|
15010
|
+
const [saving, setSaving] = import_react21.default.useState(false);
|
|
15011
|
+
const [msg, setMsg] = import_react21.default.useState(null);
|
|
15012
|
+
const [delArm, setDelArm] = import_react21.default.useState(null);
|
|
15013
|
+
const refresh = async () => {
|
|
15014
|
+
setSnap((s) => Object.assign({}, s, { loading: true, error: null }));
|
|
15015
|
+
try {
|
|
15016
|
+
if (typeof fetch !== "function") throw new Error("\u5F53\u524D\u73AF\u5883\u6CA1\u6709 fetch\uFF0C\u65E0\u6CD5\u8BFB\u53D6 MCP \u914D\u7F6E");
|
|
15017
|
+
const res = await fetch(ENDPOINT, { cache: "no-store", signal: timeoutSignal(6e4) });
|
|
15018
|
+
const body2 = await res.json().catch(() => null);
|
|
15019
|
+
if (!res.ok) throw new Error(errorText(body2, "MCP \u914D\u7F6E\u63A5\u53E3 HTTP " + res.status));
|
|
15020
|
+
if (!body2 || body2.ok === false) throw new Error(errorText(body2, "MCP \u914D\u7F6E\u63A5\u53E3\u8FD4\u56DE\u5F02\u5E38"));
|
|
15021
|
+
const list = Array.isArray(body2.servers) ? body2.servers : body2.data && Array.isArray(body2.data.servers) ? body2.data.servers : [];
|
|
15022
|
+
setSnap({ loading: false, error: null, data: body2 });
|
|
15023
|
+
setDrafts(list.map(toDraft));
|
|
15024
|
+
} catch (e) {
|
|
15025
|
+
setSnap({ loading: false, error: messageOf(e), data: null });
|
|
15026
|
+
}
|
|
15027
|
+
};
|
|
15028
|
+
import_react21.default.useEffect(() => {
|
|
15029
|
+
refresh();
|
|
15030
|
+
}, []);
|
|
15031
|
+
const commit = async (nextDrafts, successText) => {
|
|
15032
|
+
if (saving) return false;
|
|
15033
|
+
const previous = drafts;
|
|
15034
|
+
setSaving(true);
|
|
15035
|
+
setFormError(null);
|
|
15036
|
+
setMsg(null);
|
|
15037
|
+
setDrafts(nextDrafts);
|
|
15038
|
+
try {
|
|
15039
|
+
if (typeof fetch !== "function") throw new Error("\u5F53\u524D\u73AF\u5883\u6CA1\u6709 fetch\uFF0C\u65E0\u6CD5\u4FDD\u5B58 MCP \u914D\u7F6E");
|
|
15040
|
+
const res = await fetch(ENDPOINT, {
|
|
15041
|
+
method: "POST",
|
|
15042
|
+
headers: { "content-type": "application/json" },
|
|
15043
|
+
body: JSON.stringify({ action: "save", servers: nextDrafts.map(toSaveShape) }),
|
|
15044
|
+
cache: "no-store",
|
|
15045
|
+
signal: timeoutSignal(6e4)
|
|
15046
|
+
});
|
|
15047
|
+
const body2 = await res.json().catch(() => null);
|
|
15048
|
+
if (!res.ok || !body2 || body2.ok === false) {
|
|
15049
|
+
const extra = body2 && body2.rolledBack ? "\uFF08\u5DF2\u56DE\u6EDA\u5230\u4FDD\u5B58\u524D\u7684\u914D\u7F6E\uFF09" : body2 && body2.needsRestart ? "\uFF08\u914D\u7F6E\u53EF\u80FD\u5DF2\u5199\u5165\uFF0C\u9700\u91CD\u542F DSH \u68C0\u67E5\uFF09" : "";
|
|
15050
|
+
throw new Error(errorText(body2, "\u4FDD\u5B58\u5931\u8D25\uFF1AHTTP " + res.status) + extra);
|
|
15051
|
+
}
|
|
15052
|
+
const notes = [];
|
|
15053
|
+
if (body2.restartRequired) notes.push("\u5DF2\u4FDD\u5B58\uFF0C\u91CD\u542F DSH \u540E\u751F\u6548");
|
|
15054
|
+
else if (body2.applied === false) notes.push("\u5DF2\u4FDD\u5B58\uFF0C\u7B49\u5F85 DSH \u5E94\u7528");
|
|
15055
|
+
else notes.push(body2.changed === false ? "\u914D\u7F6E\u6CA1\u6709\u53D8\u5316" : "\u5DF2\u5E94\u7528");
|
|
15056
|
+
for (const w of Array.isArray(body2.warnings) ? body2.warnings : []) notes.push(String(w));
|
|
15057
|
+
setMsg({ tone: "ok", text: successText + "\uFF1B" + notes.join("\uFF1B") });
|
|
15058
|
+
setForm(null);
|
|
15059
|
+
setFormError(null);
|
|
15060
|
+
setDelArm(null);
|
|
15061
|
+
await refresh();
|
|
15062
|
+
return true;
|
|
15063
|
+
} catch (e) {
|
|
15064
|
+
setDrafts(previous);
|
|
15065
|
+
setFormError(messageOf(e));
|
|
15066
|
+
return false;
|
|
15067
|
+
} finally {
|
|
15068
|
+
setSaving(false);
|
|
15069
|
+
}
|
|
15070
|
+
};
|
|
15071
|
+
const openCreate = () => {
|
|
15072
|
+
setForm(emptyForm());
|
|
15073
|
+
setFormError(null);
|
|
15074
|
+
setMsg(null);
|
|
15075
|
+
setDelArm(null);
|
|
15076
|
+
};
|
|
15077
|
+
const openEdit = (draft, index) => {
|
|
15078
|
+
setForm(formFrom(draft, index));
|
|
15079
|
+
setFormError(null);
|
|
15080
|
+
setMsg(null);
|
|
15081
|
+
setDelArm(null);
|
|
15082
|
+
};
|
|
15083
|
+
const closeForm = () => {
|
|
15084
|
+
setForm(null);
|
|
15085
|
+
setFormError(null);
|
|
15086
|
+
};
|
|
15087
|
+
const patchForm = (patch) => {
|
|
15088
|
+
setForm((f) => Object.assign({}, f, patch));
|
|
15089
|
+
setFormError(null);
|
|
15090
|
+
};
|
|
15091
|
+
const saveForm = () => {
|
|
15092
|
+
if (!form || saving) return;
|
|
15093
|
+
const result = formToDraft(form, drafts);
|
|
15094
|
+
if (result.error) {
|
|
15095
|
+
setFormError(result.error);
|
|
15096
|
+
return;
|
|
15097
|
+
}
|
|
15098
|
+
const draft = result.draft;
|
|
15099
|
+
const next = form.mode === "edit" ? drafts.map((d, i) => i === form.index ? Object.assign({}, d, draft) : d) : drafts.concat([draft]);
|
|
15100
|
+
const text = (form.mode === "edit" ? "\u5DF2\u66F4\u65B0\u300C" : "\u5DF2\u65B0\u589E\u300C") + draft.serverName + "\u300D";
|
|
15101
|
+
commit(next, text);
|
|
15102
|
+
};
|
|
15103
|
+
const toggle = (draft) => {
|
|
15104
|
+
const next = drafts.map((d) => d.serverName === draft.serverName ? Object.assign({}, d, { enabled: !d.enabled }) : d);
|
|
15105
|
+
commit(next, "\u5DF2" + (draft.enabled ? "\u505C\u7528\u300C" : "\u542F\u7528\u300C") + draft.serverName + "\u300D");
|
|
15106
|
+
};
|
|
15107
|
+
const remove = (draft) => {
|
|
15108
|
+
if (delArm !== draft.serverName) {
|
|
15109
|
+
setDelArm(draft.serverName);
|
|
15110
|
+
setMsg(null);
|
|
15111
|
+
setFormError(null);
|
|
15112
|
+
return;
|
|
15113
|
+
}
|
|
15114
|
+
setDelArm(null);
|
|
15115
|
+
const next = drafts.filter((d) => d.serverName !== draft.serverName);
|
|
15116
|
+
if (form && form.mode === "edit" && form.serverName === draft.serverName) closeForm();
|
|
15117
|
+
commit(next, "\u5DF2\u5220\u9664\u300C" + draft.serverName + "\u300D");
|
|
15118
|
+
};
|
|
15119
|
+
const fillXiaomiExample = () => {
|
|
15120
|
+
if (drafts.some((d) => d.serverName === "xiaomi_ocr")) {
|
|
15121
|
+
setMsg({ tone: "warn", text: "\u5217\u8868\u91CC\u5DF2\u7ECF\u6709 xiaomi_ocr\uFF08\u53EF\u76F4\u63A5\u70B9\u8BE5\u5361\u7247\u7684\u300C\u7F16\u8F91\u300D\u67E5\u770B/\u4FEE\u6539\uFF09" });
|
|
15122
|
+
return;
|
|
15123
|
+
}
|
|
15124
|
+
setForm(Object.assign(emptyForm(), {
|
|
15125
|
+
serverName: "xiaomi_ocr",
|
|
15126
|
+
transport: "stdio",
|
|
15127
|
+
command: "/usr/bin/python3",
|
|
15128
|
+
argsText: "/www/wwwroot/xiaomi-ocr/mcp_ocr.py",
|
|
15129
|
+
cwd: "/www/wwwroot/xiaomi-ocr",
|
|
15130
|
+
envText: "",
|
|
15131
|
+
toolCallTimeoutMs: "300000",
|
|
15132
|
+
failOnStartupError: false
|
|
15133
|
+
}));
|
|
15134
|
+
setFormError(null);
|
|
15135
|
+
setMsg(null);
|
|
15136
|
+
};
|
|
15137
|
+
const data = snap.data;
|
|
15138
|
+
const patchPath = data && typeof data.patchPath === "string" ? data.patchPath : "";
|
|
15139
|
+
const hmrAvailable = !!(data && data.hmrAvailable);
|
|
15140
|
+
const warnings = data ? Array.isArray(data.warnings) ? data.warnings.filter((w) => typeof w === "string" && w) : typeof data.warning === "string" && data.warning ? [data.warning] : [] : [];
|
|
15141
|
+
const serverCount = drafts.length;
|
|
15142
|
+
const enabledCount = drafts.filter((d) => d.enabled).length;
|
|
15143
|
+
const toolsTotal = drafts.reduce((n, d) => n + (Number.isFinite(d.toolCount) ? d.toolCount : 0), 0);
|
|
15144
|
+
const body = [
|
|
15145
|
+
import_react21.default.createElement(
|
|
15146
|
+
"div",
|
|
15147
|
+
{ key: "head", className: "dkmc-head" },
|
|
15148
|
+
import_react21.default.createElement(
|
|
15149
|
+
"div",
|
|
15150
|
+
{ className: "dkmc-head-title" },
|
|
15151
|
+
import_react21.default.createElement("h2", { className: "dkmc-title" }, "MCP\u7BA1\u7406"),
|
|
15152
|
+
import_react21.default.createElement(
|
|
15153
|
+
"span",
|
|
15154
|
+
{ className: "dkmc-badge " + (hmrAvailable ? "ok" : "warn"), title: hmrAvailable ? "\u4FDD\u5B58\u540E\u7531 dsh-hmr \u539F\u5730\u91CD\u8F7D\uFF0C\u65E0\u9700\u91CD\u542F" : "\u5F53\u524D profile \u672A\u542F\u7528 HMR\uFF1A\u4FDD\u5B58\u540E\u9700\u91CD\u542F DSH \u751F\u6548" },
|
|
15155
|
+
hmrAvailable ? "\u5373\u65F6\u751F\u6548" : "\u9700\u91CD\u542F DSH \u751F\u6548"
|
|
15156
|
+
)
|
|
15157
|
+
),
|
|
15158
|
+
import_react21.default.createElement(
|
|
15159
|
+
"p",
|
|
15160
|
+
{ className: "dkmc-intro" },
|
|
15161
|
+
"\u7BA1\u7406 DSH \u4F7F\u7528\u7684 MCP \u670D\u52A1\u5668\uFF08\u65B0\u589E / \u7F16\u8F91 / \u5220\u9664 / \u542F\u505C\uFF09\uFF0C\u4FDD\u5B58\u540E\u5199\u56DE\u5F53\u524D profile \u7684 cordis \u8865\u4E01\u5C42\u6258\u7BA1\u5757\uFF1B\u8FDE\u63A5\u6210\u529F\u540E\u6A21\u578B\u5DE5\u5177\u5217\u8868\u51FA\u73B0 mcp__<serverName>__<tool>\u3002"
|
|
15162
|
+
)
|
|
15163
|
+
),
|
|
15164
|
+
import_react21.default.createElement(
|
|
15165
|
+
"div",
|
|
15166
|
+
{ key: "meta", className: "dkmc-meta" },
|
|
15167
|
+
import_react21.default.createElement("span", { className: "dkmc-meta-label" }, "\u8865\u4E01\u6587\u4EF6"),
|
|
15168
|
+
import_react21.default.createElement("code", { className: "dkmc-path", title: patchPath || void 0 }, patchPath || "\uFF08\u5C1A\u672A\u8BFB\u53D6\uFF09"),
|
|
15169
|
+
import_react21.default.createElement(
|
|
15170
|
+
"button",
|
|
15171
|
+
{ type: "button", className: "dkmc-btn ghost sm", disabled: snap.loading || saving, onClick: () => {
|
|
15172
|
+
setMsg(null);
|
|
15173
|
+
refresh();
|
|
15174
|
+
} },
|
|
15175
|
+
snap.loading ? "\u5237\u65B0\u4E2D\u2026" : "\u5237\u65B0"
|
|
15176
|
+
)
|
|
15177
|
+
)
|
|
15178
|
+
];
|
|
15179
|
+
if (warnings.length > 0) {
|
|
15180
|
+
body.push(import_react21.default.createElement(
|
|
15181
|
+
"ul",
|
|
15182
|
+
{ key: "warnings", className: "dkmc-warnings" },
|
|
15183
|
+
warnings.map((w, i) => import_react21.default.createElement("li", { key: i, className: "dkmc-warning" }, w))
|
|
15184
|
+
));
|
|
15185
|
+
}
|
|
15186
|
+
if (snap.error) {
|
|
15187
|
+
body.push(import_react21.default.createElement("p", { key: "loaderr", className: "dkmc-error" }, "MCP \u914D\u7F6E\u8BFB\u53D6\u5931\u8D25\uFF1A" + snap.error));
|
|
15188
|
+
}
|
|
15189
|
+
if (msg) {
|
|
15190
|
+
body.push(import_react21.default.createElement("p", {
|
|
15191
|
+
key: "msg",
|
|
15192
|
+
className: "dkmc-msg " + (msg.tone === "ok" ? "ok" : msg.tone === "warn" ? "warn" : "err"),
|
|
15193
|
+
role: "status"
|
|
15194
|
+
}, msg.text));
|
|
15195
|
+
}
|
|
15196
|
+
if (!data) {
|
|
15197
|
+
body.push(import_react21.default.createElement(
|
|
15198
|
+
"div",
|
|
15199
|
+
{ key: "empty-loading", className: "dkmc-empty" },
|
|
15200
|
+
snap.loading ? "\u6B63\u5728\u8BFB\u53D6 MCP \u670D\u52A1\u5668\u2026" : "\u6682\u65F6\u8BFB\u4E0D\u5230 MCP \u914D\u7F6E\uFF0C\u70B9\u4E0A\u65B9\u300C\u5237\u65B0\u300D\u91CD\u8BD5"
|
|
15201
|
+
));
|
|
15202
|
+
} else {
|
|
15203
|
+
body.push(import_react21.default.createElement(
|
|
15204
|
+
"div",
|
|
15205
|
+
{ key: "summary", className: "dkmc-summary-line" },
|
|
15206
|
+
"\u5171 " + serverCount + " \u53F0\u670D\u52A1\u5668 \xB7 " + enabledCount + " \u53F0\u542F\u7528 \xB7 \u5DF2\u6CE8\u518C\u5DE5\u5177 " + toolsTotal + " \u4E2A"
|
|
15207
|
+
));
|
|
15208
|
+
if (drafts.length === 0) {
|
|
15209
|
+
body.push(import_react21.default.createElement("div", { key: "empty", className: "dkmc-empty" }, "\u8FD8\u6CA1\u6709 MCP \u670D\u52A1\u5668\u2014\u2014\u70B9\u4E0B\u65B9\u300C\u65B0\u589E MCP \u670D\u52A1\u5668\u300D\u6DFB\u52A0\uFF0C\u6216\u5148\u586B\u5165\u672C\u673A Xiaomi-OCR \u793A\u4F8B\u3002"));
|
|
15210
|
+
} else {
|
|
15211
|
+
body.push(import_react21.default.createElement(
|
|
15212
|
+
"ul",
|
|
15213
|
+
{ key: "cards", className: "dkmc-cards" },
|
|
15214
|
+
drafts.map((draft, index) => {
|
|
15215
|
+
const editing = !!form && form.mode === "edit" && form.index === index;
|
|
15216
|
+
const state = draft.state || "unknown";
|
|
15217
|
+
const stateText = STATE_TEXT[state] || STATE_TEXT.unknown;
|
|
15218
|
+
const toolTitle = draft.tools && draft.tools.length > 0 ? draft.tools.join("\n") : "\u5C1A\u672A\u6CE8\u518C\u5DE5\u5177";
|
|
15219
|
+
return import_react21.default.createElement(
|
|
15220
|
+
"li",
|
|
15221
|
+
{ key: draft.serverName + ":" + index, className: "dkmc-card" + (editing ? " editing" : "") },
|
|
15222
|
+
import_react21.default.createElement(
|
|
15223
|
+
"div",
|
|
15224
|
+
{ className: "dkmc-rowhead" },
|
|
15225
|
+
import_react21.default.createElement("span", { className: "dkmc-name" }, draft.serverName || "\uFF08\u672A\u547D\u540D\uFF09"),
|
|
15226
|
+
import_react21.default.createElement("span", { className: "dkmc-tag" }, draft.transport === "streamable-http" ? "HTTP" : "stdio"),
|
|
15227
|
+
import_react21.default.createElement(
|
|
15228
|
+
"span",
|
|
15229
|
+
{ className: stateClass(state), title: stateText },
|
|
15230
|
+
import_react21.default.createElement("span", { className: stateDotClass(state), "aria-hidden": true }),
|
|
15231
|
+
stateText
|
|
15232
|
+
),
|
|
15233
|
+
import_react21.default.createElement("span", { className: "dkmc-tools", title: toolTitle }, (Number.isFinite(draft.toolCount) ? draft.toolCount : 0) + " \u4E2A\u5DE5\u5177"),
|
|
15234
|
+
import_react21.default.createElement(
|
|
15235
|
+
"span",
|
|
15236
|
+
{ className: "dkmc-actions" },
|
|
15237
|
+
import_react21.default.createElement("button", {
|
|
15238
|
+
type: "button",
|
|
15239
|
+
className: "dkmc-switch" + (draft.enabled ? " on" : ""),
|
|
15240
|
+
role: "switch",
|
|
15241
|
+
"aria-checked": draft.enabled,
|
|
15242
|
+
"aria-label": (draft.enabled ? "\u505C\u7528" : "\u542F\u7528") + draft.serverName,
|
|
15243
|
+
title: draft.enabled ? "\u505C\u7528\uFF08\u4FDD\u5B58\u540E\u7ACB\u5373\u751F\u6548\uFF09" : "\u542F\u7528\uFF08\u4FDD\u5B58\u540E\u7ACB\u5373\u751F\u6548\uFF09",
|
|
15244
|
+
disabled: saving,
|
|
15245
|
+
onClick: () => toggle(draft)
|
|
15246
|
+
}, draft.enabled ? "\u5DF2\u542F\u7528" : "\u5DF2\u505C\u7528"),
|
|
15247
|
+
import_react21.default.createElement("button", {
|
|
15248
|
+
type: "button",
|
|
15249
|
+
className: "dkmc-btn ghost sm",
|
|
15250
|
+
"aria-expanded": editing,
|
|
15251
|
+
disabled: saving,
|
|
15252
|
+
onClick: () => editing ? closeForm() : openEdit(draft, index)
|
|
15253
|
+
}, editing ? "\u6536\u8D77" : "\u7F16\u8F91"),
|
|
15254
|
+
import_react21.default.createElement("button", {
|
|
15255
|
+
type: "button",
|
|
15256
|
+
className: "dkmc-btn danger sm" + (delArm === draft.serverName ? " arm" : ""),
|
|
15257
|
+
title: delArm === draft.serverName ? "\u518D\u70B9\u4E00\u6B21\u786E\u8BA4\u5220\u9664" : "\u5220\u9664\u8BE5 MCP \u670D\u52A1\u5668",
|
|
15258
|
+
disabled: saving,
|
|
15259
|
+
onClick: () => remove(draft)
|
|
15260
|
+
}, delArm === draft.serverName ? "\u786E\u8BA4\u5220\u9664\uFF1F" : "\u5220\u9664")
|
|
15261
|
+
)
|
|
15262
|
+
),
|
|
15263
|
+
draft.error ? import_react21.default.createElement("p", { className: "dkmc-error dkmc-error-line", title: draft.error }, draft.error) : null,
|
|
15264
|
+
editing ? import_react21.default.createElement(ServerForm, {
|
|
15265
|
+
form,
|
|
15266
|
+
patch: patchForm,
|
|
15267
|
+
error: formError,
|
|
15268
|
+
saving,
|
|
15269
|
+
onSave: saveForm,
|
|
15270
|
+
onCancel: closeForm
|
|
15271
|
+
}) : null
|
|
15272
|
+
);
|
|
15273
|
+
})
|
|
15274
|
+
));
|
|
15275
|
+
}
|
|
15276
|
+
}
|
|
15277
|
+
body.push(import_react21.default.createElement(
|
|
15278
|
+
"div",
|
|
15279
|
+
{ key: "add", className: "dkmc-addblock" },
|
|
15280
|
+
form && form.mode === "create" ? import_react21.default.createElement(
|
|
15281
|
+
"div",
|
|
15282
|
+
{ className: "dkmc-card dkmc-addcard" },
|
|
15283
|
+
import_react21.default.createElement(ServerForm, {
|
|
15284
|
+
form,
|
|
15285
|
+
patch: patchForm,
|
|
15286
|
+
error: formError,
|
|
15287
|
+
saving,
|
|
15288
|
+
onExample: fillXiaomiExample,
|
|
15289
|
+
onSave: saveForm,
|
|
15290
|
+
onCancel: closeForm
|
|
15291
|
+
})
|
|
15292
|
+
) : import_react21.default.createElement(
|
|
15293
|
+
"div",
|
|
15294
|
+
{ className: "dkmc-addrow" },
|
|
15295
|
+
import_react21.default.createElement("button", { type: "button", className: "dkmc-addbtn", disabled: saving, onClick: openCreate }, "\uFF0B \u65B0\u589E MCP \u670D\u52A1\u5668"),
|
|
15296
|
+
import_react21.default.createElement("button", { type: "button", className: "dkmc-btn ghost", disabled: saving, onClick: fillXiaomiExample }, "\u586B\u5165\u672C\u673A Xiaomi-OCR \u793A\u4F8B")
|
|
15297
|
+
)
|
|
15298
|
+
));
|
|
15299
|
+
return import_react21.default.createElement("div", { className: "dkmc-page" }, body);
|
|
15300
|
+
}
|
|
15301
|
+
var feature11 = {
|
|
15302
|
+
id: "mcpconfig",
|
|
15303
|
+
name: "MCP\u7BA1\u7406",
|
|
15304
|
+
order: 101,
|
|
15305
|
+
accent: "#a855f7",
|
|
15306
|
+
description: "\u7BA1\u7406 DSH \u4F7F\u7528\u7684 MCP \u670D\u52A1\u5668\uFF08\u589E\u5220\u6539/\u542F\u505C/\u5DE5\u5177\u72B6\u6001\uFF09",
|
|
15307
|
+
defaultEnabled: false,
|
|
15308
|
+
View: McpConfigView,
|
|
15309
|
+
css: [
|
|
15310
|
+
// ---- MCP 管理页(dkmc- 前缀;排版/尺寸对齐 providerconfig 的 dkp- 页) ----
|
|
15311
|
+
".dkmc-page{width:100%;max-width:760px;display:flex;flex-direction:column;gap:12px;color:var(--dsw-alias-label-primary);font-size:13px;}",
|
|
15312
|
+
".dkmc-head{display:flex;flex-direction:column;gap:6px;}",
|
|
15313
|
+
".dkmc-head-title{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}",
|
|
15314
|
+
".dkmc-title{margin:0;font-size:16px;font-weight:500;line-height:24px;}",
|
|
15315
|
+
".dkmc-intro{margin:0;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:20px;}",
|
|
15316
|
+
".dkmc-badge{flex:none;border-radius:999px;padding:2px 9px;font-size:11px;line-height:16px;border:1px solid currentColor;}",
|
|
15317
|
+
".dkmc-badge.ok{color:var(--dsw-alias-state-success-primary);}",
|
|
15318
|
+
".dkmc-badge.warn{color:var(--dk-warn);}",
|
|
15319
|
+
".dkmc-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 10px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-lg,10px);background:var(--dsw-alias-bg-layer-1);}",
|
|
15320
|
+
".dkmc-meta-label{flex:none;color:var(--dsw-alias-label-tertiary);font-size:12px;}",
|
|
15321
|
+
".dkmc-path{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary);font-family:var(--ds-font-family-code,ui-monospace,monospace);font-size:12px;}",
|
|
15322
|
+
".dkmc-warnings{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px;}",
|
|
15323
|
+
".dkmc-warning{color:var(--dk-warn);font-size:12px;line-height:18px;}",
|
|
15324
|
+
".dkmc-error{margin:0;color:var(--dsw-alias-state-error-primary);font-size:12px;line-height:18px;word-break:break-word;}",
|
|
15325
|
+
".dkmc-error-line{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}",
|
|
15326
|
+
".dkmc-msg{margin:0;font-size:12px;line-height:18px;word-break:break-word;}",
|
|
15327
|
+
".dkmc-msg.ok{color:var(--dsw-alias-state-success-primary);}",
|
|
15328
|
+
".dkmc-msg.warn{color:var(--dk-warn);}",
|
|
15329
|
+
".dkmc-msg.err{color:var(--dsw-alias-state-error-primary);}",
|
|
15330
|
+
".dkmc-summary-line{color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;}",
|
|
15331
|
+
".dkmc-empty{border:1px dashed var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg,10px);padding:16px 12px;text-align:center;color:var(--dsw-alias-label-tertiary);font-size:12px;line-height:18px;}",
|
|
15332
|
+
".dkmc-cards{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:8px;}",
|
|
15333
|
+
".dkmc-card{box-sizing:border-box;margin:0;border:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-settings-card-fill,var(--dsw-alias-bg-layer-1));border-radius:var(--dsw-radius-lg,10px);padding:10px 12px;display:flex;flex-direction:column;gap:8px;}",
|
|
15334
|
+
".dkmc-card.editing{border-color:color-mix(in srgb,var(--dk-accent) 45%,var(--dsw-alias-border-l2));}",
|
|
15335
|
+
".dkmc-rowhead{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}",
|
|
15336
|
+
".dkmc-name{font-size:14px;font-weight:600;line-height:22px;overflow:hidden;text-overflow:ellipsis;max-width:100%;}",
|
|
15337
|
+
".dkmc-tag{flex:none;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-xs,4px);color:var(--dsw-alias-label-secondary);padding:1px 6px;font-size:11px;line-height:16px;}",
|
|
15338
|
+
".dkmc-state{flex:none;display:inline-flex;align-items:center;gap:5px;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px;white-space:nowrap;}",
|
|
15339
|
+
".dkmc-state.ok{color:var(--dsw-alias-state-success-primary);}",
|
|
15340
|
+
".dkmc-state.err{color:var(--dsw-alias-state-error-primary);}",
|
|
15341
|
+
".dkmc-dot{width:7px;height:7px;border-radius:50%;flex:none;background:var(--dsw-alias-label-tertiary);}",
|
|
15342
|
+
".dkmc-dot.ok{background:var(--dsw-alias-state-success-primary);box-shadow:0 0 4px color-mix(in srgb,var(--dsw-alias-state-success-primary) 55%,transparent);}",
|
|
15343
|
+
".dkmc-dot.err{background:var(--dsw-alias-state-error-primary);}",
|
|
15344
|
+
".dkmc-dot.idle{background:transparent;border:1.5px solid var(--dsw-alias-label-secondary);}",
|
|
15345
|
+
".dkmc-dot.off{background:transparent;border:1.5px solid var(--dsw-alias-label-tertiary);opacity:.75;}",
|
|
15346
|
+
".dkmc-tools{flex:none;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px;white-space:nowrap;cursor:default;}",
|
|
15347
|
+
".dkmc-actions{flex:none;margin-left:auto;display:inline-flex;align-items:center;gap:4px;flex-wrap:wrap;}",
|
|
15348
|
+
".dkmc-switch{cursor:pointer;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);border-radius:999px;padding:3px 10px;font-family:inherit;font-size:11px;line-height:16px;}",
|
|
15349
|
+
".dkmc-switch.on{color:var(--dsw-alias-state-success-primary);border-color:currentColor;}",
|
|
15350
|
+
".dkmc-switch[disabled]{opacity:.45;cursor:default;}",
|
|
15351
|
+
".dkmc-btn{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;gap:4px;height:32px;padding:0 12px;border:none;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;cursor:pointer;}",
|
|
15352
|
+
".dkmc-btn.ghost{border:.5px solid var(--dsw-alias-border-l3);}",
|
|
15353
|
+
".dkmc-btn.ghost:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
15354
|
+
".dkmc-btn.primary{background:var(--dsw-alias-button-primary-fill,var(--dk-accent));color:var(--dsw-alias-label-primary-foreground,#fff);}",
|
|
15355
|
+
".dkmc-btn.danger{color:var(--dsw-alias-state-error-primary);}",
|
|
15356
|
+
".dkmc-btn.danger:hover{background:var(--dsw-alias-interactive-bg-hover-danger,rgba(220,38,38,.1));}",
|
|
15357
|
+
".dkmc-btn.arm{color:var(--dsw-alias-state-error-primary);border:.5px solid currentColor;}",
|
|
15358
|
+
".dkmc-btn.sm{height:26px;padding:0 9px;border-radius:var(--dsw-radius-sm,6px);font-size:11px;line-height:16px;}",
|
|
15359
|
+
".dkmc-btn[disabled]{opacity:.4;cursor:default;}",
|
|
15360
|
+
".dkmc-editor{border-radius:var(--dsw-radius-lg,10px);background:var(--dsw-alias-bg-module-platform,var(--dsw-alias-bg-layer-1));padding:12px 14px;display:flex;flex-direction:column;gap:12px;}",
|
|
15361
|
+
".dkmc-editor-head{display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;}",
|
|
15362
|
+
".dkmc-editor-title{font-size:13px;font-weight:600;line-height:20px;}",
|
|
15363
|
+
".dkmc-editor-sub{color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px;}",
|
|
15364
|
+
".dkmc-example{margin-left:auto;flex:none;}",
|
|
15365
|
+
".dkmc-field{display:flex;flex-direction:column;gap:5px;min-width:0;}",
|
|
15366
|
+
".dkmc-flabel{display:inline-flex;align-items:center;gap:8px;color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:500;line-height:18px;}",
|
|
15367
|
+
".dkmc-hint{margin:0;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px;word-break:break-word;}",
|
|
15368
|
+
".dkmc-input{box-sizing:border-box;width:100%;height:32px;padding:0 10px;border:.5px solid var(--dsw-alias-border-l4,var(--dsw-alias-border-l2));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:20px;}",
|
|
15369
|
+
".dkmc-input:focus{border-color:var(--dsw-alias-state-business-primary,var(--dk-accent));outline:none;}",
|
|
15370
|
+
".dkmc-input::placeholder{color:var(--dsw-alias-label-dimmed,var(--dsw-alias-label-tertiary));}",
|
|
15371
|
+
".dkmc-input:disabled{opacity:.6;cursor:default;}",
|
|
15372
|
+
".dkmc-textarea{height:auto;min-height:64px;padding:8px 10px;resize:vertical;line-height:1.5;font-family:var(--ds-font-family-code,ui-monospace,monospace);font-size:12px;}",
|
|
15373
|
+
"select.dkmc-input{appearance:auto;cursor:pointer;max-width:280px;}",
|
|
15374
|
+
".dkmc-check{display:inline-flex;align-items:center;gap:6px;cursor:pointer;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;}",
|
|
15375
|
+
".dkmc-check input{accent-color:var(--dk-accent);margin:0;}",
|
|
15376
|
+
".dkmc-advanced{border-top:.5px solid var(--dsw-alias-border-l2);padding-top:10px;}",
|
|
15377
|
+
".dkmc-summary{display:flex;align-items:center;gap:6px;width:fit-content;margin-left:-4px;padding:2px 4px;border-radius:var(--dsw-radius-sm,6px);list-style:none;cursor:pointer;color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:500;line-height:18px;}",
|
|
15378
|
+
".dkmc-summary::-webkit-details-marker{display:none;}",
|
|
15379
|
+
'.dkmc-summary::before{content:"";width:5px;height:5px;border-right:1.5px solid;border-bottom:1.5px solid;transform:rotate(-45deg);transition:transform .12s;}',
|
|
15380
|
+
".dkmc-advanced[open]>.dkmc-summary::before{transform:rotate(45deg);}",
|
|
15381
|
+
".dkmc-advanced-body{display:flex;flex-direction:column;gap:12px;padding-top:12px;}",
|
|
15382
|
+
".dkmc-editor-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap;border-top:.5px solid var(--dsw-alias-border-l2);padding-top:10px;}",
|
|
15383
|
+
".dkmc-addblock{display:flex;align-items:stretch;}",
|
|
15384
|
+
".dkmc-addrow{display:flex;align-items:stretch;gap:8px;flex-wrap:wrap;}",
|
|
15385
|
+
".dkmc-addbtn{box-sizing:border-box;flex:1 1 220px;min-width:180px;height:44px;display:inline-flex;align-items:center;justify-content:center;gap:6px;border:1px dashed var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-lg,10px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:14px;line-height:22px;cursor:pointer;}",
|
|
15386
|
+
".dkmc-addbtn:hover{background:var(--dsw-alias-interactive-bg-hover);}",
|
|
15387
|
+
".dkmc-addbtn[disabled]{opacity:.4;cursor:default;}",
|
|
15388
|
+
".dkmc-addcard{flex:1 1 auto;padding:12px 14px;}",
|
|
15389
|
+
".dkmc-addcard .dkmc-editor{background:transparent;padding:0;}",
|
|
15390
|
+
"@media (max-width:680px){.dkmc-page{max-width:none;gap:14px}.dkmc-intro{font-size:13px;line-height:20px}.dkmc-editor{padding:12px}.dkmc-addcard{padding:12px 14px}.dkmc-btn{height:40px}.dkmc-btn.sm{height:34px}.dkmc-addbtn{height:48px;flex:1 1 100%}.dkmc-actions{width:100%;margin-left:0;justify-content:flex-end}.dkmc-name{font-size:15px}}"
|
|
15391
|
+
].join("\n")
|
|
15392
|
+
};
|
|
15393
|
+
|
|
14639
15394
|
// src/client.jsx
|
|
14640
|
-
var DOCK_VERSION = "0.
|
|
14641
|
-
var BUILTIN_FEATURES = [feature, feature2, feature3, feature4, feature5, feature6, feature7, feature8, feature9, feature10
|
|
15395
|
+
var DOCK_VERSION = "0.23.0";
|
|
15396
|
+
var BUILTIN_FEATURES = [feature, feature2, feature3, feature11, feature4, feature5, feature6, feature7, feature8, feature9, feature10];
|
|
14642
15397
|
var PLANNED_FEATURES = [];
|
|
14643
15398
|
var PLANNED_NOTES = {};
|
|
14644
15399
|
var externalDefs = [];
|
|
@@ -14758,8 +15513,10 @@ var SHELL_CSS = [
|
|
|
14758
15513
|
".dockm-page-wide-btn{flex:none;margin-left:auto;display:inline-flex;align-items:center;gap:4px;height:28px;padding:0 10px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-secondary);font-family:inherit;font-size:12px;cursor:pointer;}",
|
|
14759
15514
|
".dockm-page-wide-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);}",
|
|
14760
15515
|
/* 面板页的左侧菜单收窄:给右侧列表/表格让出宽度,别留大片空白 */
|
|
14761
|
-
|
|
14762
|
-
|
|
15516
|
+
// 左侧菜单列:内容只有 8px 圆点 + 4 字标签,140px 会留一大条空白(用户反馈「这个宽度可以缩小点」)。
|
|
15517
|
+
// 用 border-box 收到 110px(含内距):既够放最长标签「MCP管理 / 远程访问」,又把右侧死区收掉,正文区更宽。
|
|
15518
|
+
".dockm-page .dockm-nav{box-sizing:border-box;width:110px;padding:8px 7px;}",
|
|
15519
|
+
".dockm-page .dockm-nav-item{padding:7px 8px;font-size:12.5px;gap:6px;overflow:hidden;}",
|
|
14763
15520
|
".dockm-page-body>.dockm-body{flex:1;min-height:0;}",
|
|
14764
15521
|
".dockm-page-icon{flex:none;display:flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);}",
|
|
14765
15522
|
".dockm-page-titles{min-width:0;}",
|
|
@@ -14838,7 +15595,10 @@ var SHELL_CSS = [
|
|
|
14838
15595
|
/* 手机自适应:输入区工具行很窄——chip 字号/内距收紧、隐藏费用后缀与「余额」前缀,
|
|
14839
15596
|
数值完整显示且工具行保持单行不换行(完整信息仍在 title 悬浮提示里)。 */
|
|
14840
15597
|
".dockchip-pre-s{display:none;}",
|
|
14841
|
-
"
|
|
15598
|
+
".dockchip-svg{display:none;align-items:center;justify-content:center;}",
|
|
15599
|
+
/* 手机端:输入区工具行太窄,余额/用量只留两枚小图标(点进功能坞看具体数据),
|
|
15600
|
+
文本与圆点全部隐藏,图标做成 24×24 的稳定触控块 → 工具行必定单行。 */
|
|
15601
|
+
"@media (max-width:767px){.dockchip-row{max-width:min(92px,20cqw);gap:2px}.dockchip-svg{display:inline-flex}.dockchip-val,.dockchip-pre,.dockchip-pre-s,.dockchip-ic,.dockchip-x,.dockchip .dockchip-dot{display:none}.dockchip{width:24px;height:24px;box-sizing:border-box;justify-content:center;padding:0!important;gap:0!important;border-radius:6px}}",
|
|
14842
15602
|
/* 手机触控基础:去点按蓝块、消双击缩放判定延迟;原生侧栏开关热区扩到 44×44(视觉不变)。 */
|
|
14843
15603
|
`@media (max-width:767px){:is(button,[role="button"]){-webkit-tap-highlight-color:transparent;touch-action:manipulation}[data-sidebar-opener]{position:relative}[data-sidebar-opener]::after{content:'';position:absolute;left:50%;top:50%;width:44px;height:44px;transform:translate(-50%,-50%)}}`
|
|
14844
15604
|
].join("\n");
|
|
@@ -14876,8 +15636,8 @@ function ensureCss() {
|
|
|
14876
15636
|
}
|
|
14877
15637
|
}
|
|
14878
15638
|
function useExternalVersion() {
|
|
14879
|
-
const [, bump] =
|
|
14880
|
-
|
|
15639
|
+
const [, bump] = import_react22.default.useReducer((n) => n + 1, 0);
|
|
15640
|
+
import_react22.default.useEffect(() => {
|
|
14881
15641
|
externalListeners.add(bump);
|
|
14882
15642
|
return () => {
|
|
14883
15643
|
externalListeners.delete(bump);
|
|
@@ -14887,25 +15647,25 @@ function useExternalVersion() {
|
|
|
14887
15647
|
var lastGeom = { x: null, y: null, w: null, h: null };
|
|
14888
15648
|
function DockIcon(props) {
|
|
14889
15649
|
const size = props && props.size || 16;
|
|
14890
|
-
return
|
|
15650
|
+
return import_react22.default.createElement(
|
|
14891
15651
|
"svg",
|
|
14892
15652
|
{ width: size, height: size, viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: 1.3, "aria-hidden": true },
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
|
|
15653
|
+
import_react22.default.createElement("rect", { x: 2.5, y: 2.5, width: 4.4, height: 4.4, rx: 1.2 }),
|
|
15654
|
+
import_react22.default.createElement("rect", { x: 9, y: 2.5, width: 4.4, height: 4.4, rx: 1.2 }),
|
|
15655
|
+
import_react22.default.createElement("rect", { x: 2.5, y: 9, width: 4.4, height: 4.4, rx: 1.2 }),
|
|
15656
|
+
import_react22.default.createElement("rect", { x: 9, y: 9, width: 4.4, height: 4.4, rx: 1.2 })
|
|
14897
15657
|
);
|
|
14898
15658
|
}
|
|
14899
15659
|
function DockWorkspace() {
|
|
14900
|
-
const [nav, setNav] =
|
|
14901
|
-
|
|
15660
|
+
const [nav, setNav] = import_react22.default.useState({ open: panelNav.open, active: panelNav.active, params: panelNav.params });
|
|
15661
|
+
import_react22.default.useEffect(() => subscribePanel(() => setNav({ open: panelNav.open, active: panelNav.active, params: panelNav.params })), []);
|
|
14902
15662
|
const active = nav.active;
|
|
14903
15663
|
const navParams = nav.params;
|
|
14904
15664
|
const setActive = navigatePanel;
|
|
14905
|
-
const [, force] =
|
|
15665
|
+
const [, force] = import_react22.default.useReducer((n) => n + 1, 0);
|
|
14906
15666
|
useExternalVersion();
|
|
14907
|
-
const contentRef =
|
|
14908
|
-
|
|
15667
|
+
const contentRef = import_react22.default.useRef(null);
|
|
15668
|
+
import_react22.default.useEffect(() => {
|
|
14909
15669
|
if (contentRef.current) contentRef.current.scrollTop = 0;
|
|
14910
15670
|
}, [active]);
|
|
14911
15671
|
const MODULES = allModules();
|
|
@@ -14913,26 +15673,26 @@ function DockWorkspace() {
|
|
|
14913
15673
|
const mod = isHome ? null : MODULES.find((m) => m.id === active) || MODULES[0];
|
|
14914
15674
|
const st = mod ? stateOf(mod.id) : null;
|
|
14915
15675
|
const View = mod ? mod.View : null;
|
|
14916
|
-
const viewNode = mod && View ?
|
|
15676
|
+
const viewNode = mod && View ? import_react22.default.createElement(
|
|
14917
15677
|
"div",
|
|
14918
15678
|
{ className: "dockm-view" },
|
|
14919
|
-
|
|
15679
|
+
import_react22.default.createElement(
|
|
14920
15680
|
FeatureBoundary,
|
|
14921
15681
|
{ key: mod.id, label: mod.name },
|
|
14922
|
-
|
|
15682
|
+
import_react22.default.createElement(View, { ctx: ctxRef.current, feature: mod, params: navParams })
|
|
14923
15683
|
)
|
|
14924
15684
|
) : null;
|
|
14925
15685
|
const enabledCount = MODULES.filter((m) => {
|
|
14926
15686
|
const s = stateOf(m.id);
|
|
14927
15687
|
return !!(s && s.enabled);
|
|
14928
15688
|
}).length;
|
|
14929
|
-
return
|
|
15689
|
+
return import_react22.default.createElement(
|
|
14930
15690
|
"div",
|
|
14931
15691
|
{ className: "dockm-body" },
|
|
14932
|
-
|
|
15692
|
+
import_react22.default.createElement(
|
|
14933
15693
|
"nav",
|
|
14934
15694
|
{ className: "dockm-nav", "aria-label": "\u529F\u80FD\u6A21\u5757" },
|
|
14935
|
-
|
|
15695
|
+
import_react22.default.createElement(
|
|
14936
15696
|
"button",
|
|
14937
15697
|
{
|
|
14938
15698
|
type: "button",
|
|
@@ -14940,10 +15700,10 @@ function DockWorkspace() {
|
|
|
14940
15700
|
className: "dockm-nav-item" + (isHome ? " on" : ""),
|
|
14941
15701
|
onClick: () => setActive("home")
|
|
14942
15702
|
},
|
|
14943
|
-
|
|
14944
|
-
|
|
15703
|
+
import_react22.default.createElement("span", { className: "dockm-navhome" }, import_react22.default.createElement(DockIcon, null)),
|
|
15704
|
+
import_react22.default.createElement("span", null, "\u9996\u9875")
|
|
14945
15705
|
),
|
|
14946
|
-
MODULES.map((m) =>
|
|
15706
|
+
MODULES.map((m) => import_react22.default.createElement(
|
|
14947
15707
|
"button",
|
|
14948
15708
|
{
|
|
14949
15709
|
type: "button",
|
|
@@ -14951,42 +15711,42 @@ function DockWorkspace() {
|
|
|
14951
15711
|
className: "dockm-nav-item" + (m.id === active ? " on" : ""),
|
|
14952
15712
|
onClick: () => setActive(m.id)
|
|
14953
15713
|
},
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
m.planned ?
|
|
14957
|
-
m.external ?
|
|
15714
|
+
import_react22.default.createElement("span", { className: "dockm-dot", style: { background: m.accent } }),
|
|
15715
|
+
import_react22.default.createElement("span", null, m.name),
|
|
15716
|
+
m.planned ? import_react22.default.createElement("span", { className: "dockm-badge" }, "\u89C4\u5212\u4E2D") : null,
|
|
15717
|
+
m.external ? import_react22.default.createElement("span", { className: "dockm-badge" }, "\u5916\u90E8") : null
|
|
14958
15718
|
))
|
|
14959
15719
|
),
|
|
14960
|
-
|
|
15720
|
+
import_react22.default.createElement(
|
|
14961
15721
|
"div",
|
|
14962
15722
|
{ className: "dockm-content", ref: contentRef },
|
|
14963
|
-
|
|
15723
|
+
import_react22.default.createElement(
|
|
14964
15724
|
"div",
|
|
14965
15725
|
{ className: "dockm-content-head" },
|
|
14966
|
-
|
|
15726
|
+
import_react22.default.createElement(
|
|
14967
15727
|
"div",
|
|
14968
15728
|
{ className: "dockm-name" },
|
|
14969
|
-
isHome ?
|
|
15729
|
+
isHome ? import_react22.default.createElement("span", { className: "dockm-navhome" }, import_react22.default.createElement(DockIcon, null)) : import_react22.default.createElement("span", { className: "dockm-dot", style: { background: mod.accent } }),
|
|
14970
15730
|
isHome ? "\u9996\u9875" : mod.name,
|
|
14971
|
-
!isHome && mod.planned ?
|
|
14972
|
-
!isHome && mod.external ?
|
|
15731
|
+
!isHome && mod.planned ? import_react22.default.createElement("span", { className: "dockm-badge" }, "\u89C4\u5212\u4E2D") : null,
|
|
15732
|
+
!isHome && mod.external ? import_react22.default.createElement("span", { className: "dockm-badge" }, "\u5916\u90E8\u5305" + (mod.package ? " \xB7 " + mod.package : "")) : null
|
|
14973
15733
|
),
|
|
14974
|
-
|
|
15734
|
+
import_react22.default.createElement(
|
|
14975
15735
|
"div",
|
|
14976
15736
|
{ className: "dockm-desc" },
|
|
14977
15737
|
isHome ? "\u6240\u6709\u5B50\u529F\u80FD\u603B\u63FD\uFF1A\u8FD0\u884C\u72B6\u6001\u3001\u6982\u8981\u4E0E\u5FEB\u6377\u5F00\u5173\uFF0C\u70B9\u51FB\u5361\u7247\u8FDB\u5165\u5BF9\u5E94\u529F\u80FD\u9875\u3002" : mod.description
|
|
14978
15738
|
)
|
|
14979
15739
|
),
|
|
14980
|
-
isHome ?
|
|
14981
|
-
|
|
15740
|
+
isHome ? import_react22.default.createElement("div", { className: "dockm-view" }, import_react22.default.createElement(HomeView, { ctx: ctxRef.current, onOpen: setActive, onToggle: force })) : mod.planned ? import_react22.default.createElement("div", { className: "dockm-note" }, PLANNED_NOTES[mod.id] || "\u5F85\u63A5\u5165\uFF1A\u89C1 README \u8DEF\u7EBF\u56FE") : st && st.enabled && viewNode ? viewNode : st && st.error ? import_react22.default.createElement("div", { className: "dockm-note dockm-err" }, "\u529F\u80FD\u51FA\u9519\uFF1A" + st.error) : import_react22.default.createElement("div", { className: "dockm-note" }, "\u8BE5\u529F\u80FD\u5F53\u524D\u4E3A\u505C\u7528\u72B6\u6001\uFF08\u5F00\u5173\u5DF2\u6301\u4E45\u5316\uFF0C\u91CD\u542F\u540E\u4FDD\u6301\uFF09"),
|
|
15741
|
+
import_react22.default.createElement(
|
|
14982
15742
|
"div",
|
|
14983
15743
|
{ className: "dockm-foot" },
|
|
14984
|
-
|
|
14985
|
-
!isHome && mod && !mod.planned && st ?
|
|
15744
|
+
import_react22.default.createElement("span", null, isHome ? "\u529F\u80FD\u575E v" + DOCK_VERSION + " \xB7 \u5171 " + MODULES.length + " \u4E2A\u529F\u80FD\u6A21\u5757\uFF0C" + enabledCount + " \u4E2A\u5DF2\u542F\u7528" : "\u529F\u80FD\u575E v" + DOCK_VERSION + " \xB7 \u65B0\u529F\u80FD\u6309\u8DEF\u7EBF\u56FE\u8FFD\u52A0"),
|
|
15745
|
+
!isHome && mod && !mod.planned && st ? import_react22.default.createElement(
|
|
14986
15746
|
"span",
|
|
14987
15747
|
{ className: "dockm-foot-sw" },
|
|
14988
|
-
|
|
14989
|
-
|
|
15748
|
+
import_react22.default.createElement("span", { className: "dockm-foot-swlabel" + (st.enabled ? " on" : "") }, st.enabled ? "\u5DF2\u542F\u7528" : "\u5DF2\u505C\u7528"),
|
|
15749
|
+
import_react22.default.createElement("button", {
|
|
14990
15750
|
type: "button",
|
|
14991
15751
|
className: "dock-sw" + (st.enabled ? " on" : ""),
|
|
14992
15752
|
role: "switch",
|
|
@@ -14999,11 +15759,11 @@ function DockWorkspace() {
|
|
|
14999
15759
|
}
|
|
15000
15760
|
})
|
|
15001
15761
|
) : null,
|
|
15002
|
-
!isHome && mod && typeof mod.Chip === "function" ?
|
|
15762
|
+
!isHome && mod && typeof mod.Chip === "function" ? import_react22.default.createElement(
|
|
15003
15763
|
"span",
|
|
15004
15764
|
{ className: "dockm-foot-sw" },
|
|
15005
|
-
|
|
15006
|
-
|
|
15765
|
+
import_react22.default.createElement("span", { className: "dockm-foot-swlabel" + (chipShown(mod.id) ? " on" : "") }, "\u4F1A\u8BDD\u9875\u5C0F\u63A7\u4EF6"),
|
|
15766
|
+
import_react22.default.createElement("button", {
|
|
15007
15767
|
type: "button",
|
|
15008
15768
|
className: "dock-sw" + (chipShown(mod.id) ? " on" : ""),
|
|
15009
15769
|
role: "switch",
|
|
@@ -15021,12 +15781,12 @@ function DockWorkspace() {
|
|
|
15021
15781
|
);
|
|
15022
15782
|
}
|
|
15023
15783
|
function DockModal() {
|
|
15024
|
-
const [nav, setNav] =
|
|
15025
|
-
|
|
15784
|
+
const [nav, setNav] = import_react22.default.useState({ open: panelNav.open });
|
|
15785
|
+
import_react22.default.useEffect(() => subscribePanel(() => setNav({ open: panelNav.open })), []);
|
|
15026
15786
|
const open = nav.open || typeof document === "undefined";
|
|
15027
|
-
const [win, setWin] =
|
|
15028
|
-
const dlgRef =
|
|
15029
|
-
|
|
15787
|
+
const [win, setWin] = import_react22.default.useState(() => ({ mode: "normal", x: null, y: null, w: null, h: null }));
|
|
15788
|
+
const dlgRef = import_react22.default.useRef(null);
|
|
15789
|
+
import_react22.default.useEffect(() => {
|
|
15030
15790
|
if (lastGeom.w) setWin({ mode: "normal", x: lastGeom.x, y: lastGeom.y, w: lastGeom.w, h: lastGeom.h });
|
|
15031
15791
|
}, []);
|
|
15032
15792
|
function beginDrag(e, type) {
|
|
@@ -15066,10 +15826,10 @@ function DockModal() {
|
|
|
15066
15826
|
width: win.w != null ? win.w : void 0,
|
|
15067
15827
|
height: win.mode === "min" ? "auto" : win.h != null ? win.h : void 0
|
|
15068
15828
|
} : null;
|
|
15069
|
-
return
|
|
15829
|
+
return import_react22.default.createElement(
|
|
15070
15830
|
"div",
|
|
15071
15831
|
{ className: "dockm-backdrop", onClick: () => setPanelOpen(false) },
|
|
15072
|
-
|
|
15832
|
+
import_react22.default.createElement(
|
|
15073
15833
|
"div",
|
|
15074
15834
|
{
|
|
15075
15835
|
className: "dockm-dialog" + (win.mode === "max" ? " dockm-max" : "") + (win.mode === "min" ? " dockm-min" : ""),
|
|
@@ -15077,59 +15837,59 @@ function DockModal() {
|
|
|
15077
15837
|
ref: dlgRef,
|
|
15078
15838
|
onClick: (e) => e.stopPropagation()
|
|
15079
15839
|
},
|
|
15080
|
-
|
|
15840
|
+
import_react22.default.createElement(
|
|
15081
15841
|
"div",
|
|
15082
15842
|
{
|
|
15083
15843
|
className: "dockm-head",
|
|
15084
15844
|
onPointerDown: (e) => beginDrag(e, "move"),
|
|
15085
15845
|
onDoubleClick: () => setWin((s) => Object.assign({}, s, { mode: s.mode === "max" ? "normal" : "max" }))
|
|
15086
15846
|
},
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15847
|
+
import_react22.default.createElement(DockIcon, null),
|
|
15848
|
+
import_react22.default.createElement("span", { className: "dockm-title" }, "\u529F\u80FD\u575E"),
|
|
15849
|
+
import_react22.default.createElement("span", { className: "dockm-sub" }, "dsh-dock \xB7 \u4E5F\u53EF\u5728 \u8BBE\u7F6E \u2192 \u529F\u80FD\u575E \u6253\u5F00\u7BA1\u7406\u9875"),
|
|
15850
|
+
import_react22.default.createElement(
|
|
15091
15851
|
"span",
|
|
15092
15852
|
{ className: "dockm-ctrls" },
|
|
15093
|
-
|
|
15853
|
+
import_react22.default.createElement("button", {
|
|
15094
15854
|
type: "button",
|
|
15095
15855
|
className: "dockm-win",
|
|
15096
15856
|
title: win.mode === "min" ? "\u8FD8\u539F" : "\u6700\u5C0F\u5316",
|
|
15097
15857
|
onClick: () => setWin((s) => Object.assign({}, s, { mode: s.mode === "min" ? "normal" : "min" }))
|
|
15098
15858
|
}, "\u2581"),
|
|
15099
|
-
|
|
15859
|
+
import_react22.default.createElement("button", {
|
|
15100
15860
|
type: "button",
|
|
15101
15861
|
className: "dockm-win",
|
|
15102
15862
|
title: win.mode === "max" ? "\u8FD8\u539F" : "\u6700\u5927\u5316",
|
|
15103
15863
|
onClick: () => setWin((s) => Object.assign({}, s, { mode: s.mode === "max" ? "normal" : "max" }))
|
|
15104
15864
|
}, win.mode === "max" ? "\u2750" : "\u25A2"),
|
|
15105
|
-
|
|
15865
|
+
import_react22.default.createElement("button", { type: "button", className: "dockm-close", "aria-label": "\u5173\u95ED", title: "\u5173\u95ED", onClick: () => setPanelOpen(false) }, "\u2715")
|
|
15106
15866
|
)
|
|
15107
15867
|
),
|
|
15108
|
-
|
|
15109
|
-
win.mode === "normal" ?
|
|
15868
|
+
import_react22.default.createElement(DockWorkspace, null),
|
|
15869
|
+
win.mode === "normal" ? import_react22.default.createElement("div", { className: "dockm-resize", onPointerDown: (e) => beginDrag(e, "size") }) : null
|
|
15110
15870
|
)
|
|
15111
15871
|
);
|
|
15112
15872
|
}
|
|
15113
15873
|
function HomeView(props) {
|
|
15114
15874
|
const ctx = props && props.ctx;
|
|
15115
|
-
const [, force] =
|
|
15875
|
+
const [, force] = import_react22.default.useReducer((n) => n + 1, 0);
|
|
15116
15876
|
useExternalVersion();
|
|
15117
15877
|
const open = (id) => {
|
|
15118
15878
|
if (props && typeof props.onOpen === "function") props.onOpen(id);
|
|
15119
15879
|
};
|
|
15120
|
-
return
|
|
15880
|
+
return import_react22.default.createElement(
|
|
15121
15881
|
"div",
|
|
15122
15882
|
{ className: "dockh-grid" },
|
|
15123
15883
|
allModules().map((m) => {
|
|
15124
15884
|
const st = stateOf(m.id);
|
|
15125
15885
|
const enabled = !!(st && st.enabled);
|
|
15126
15886
|
const Stat = m.HomeStat;
|
|
15127
|
-
const statNode = m.planned ?
|
|
15887
|
+
const statNode = m.planned ? import_react22.default.createElement("span", null, PLANNED_NOTES[m.id] || "\u5F85\u63A5\u5165\uFF1A\u89C1 README \u8DEF\u7EBF\u56FE") : enabled && Stat ? import_react22.default.createElement(
|
|
15128
15888
|
FeatureBoundary,
|
|
15129
15889
|
{ key: m.id, label: m.name },
|
|
15130
|
-
|
|
15131
|
-
) :
|
|
15132
|
-
return
|
|
15890
|
+
import_react22.default.createElement(Stat, { ctx })
|
|
15891
|
+
) : import_react22.default.createElement("span", null, "\u5DF2\u505C\u7528\uFF0C\u542F\u7528\u540E\u5728\u6B64\u5C55\u793A\u8FD0\u884C\u6982\u8981");
|
|
15892
|
+
return import_react22.default.createElement(
|
|
15133
15893
|
"div",
|
|
15134
15894
|
{
|
|
15135
15895
|
key: m.id,
|
|
@@ -15144,21 +15904,21 @@ function HomeView(props) {
|
|
|
15144
15904
|
}
|
|
15145
15905
|
}
|
|
15146
15906
|
},
|
|
15147
|
-
|
|
15907
|
+
import_react22.default.createElement(
|
|
15148
15908
|
"div",
|
|
15149
15909
|
{ className: "dockh-head" },
|
|
15150
|
-
|
|
15151
|
-
|
|
15152
|
-
m.external ?
|
|
15910
|
+
import_react22.default.createElement("span", { className: "dockm-dot", style: { background: m.accent } }),
|
|
15911
|
+
import_react22.default.createElement("span", { className: "dockh-name" }, m.name),
|
|
15912
|
+
m.external ? import_react22.default.createElement("span", { className: "dockh-badge", title: m.package || void 0 }, "\u5916\u90E8") : null,
|
|
15153
15913
|
// 状态标识:圆点 + 文字(纯展示,与开关视觉区分)
|
|
15154
|
-
|
|
15914
|
+
import_react22.default.createElement(
|
|
15155
15915
|
"span",
|
|
15156
15916
|
{ className: "dockh-status" + (m.planned ? " plan" : enabled ? "" : " off") },
|
|
15157
|
-
|
|
15158
|
-
|
|
15917
|
+
import_react22.default.createElement("span", { className: "dockh-sdot" }),
|
|
15918
|
+
import_react22.default.createElement("span", null, m.planned ? "\u89C4\u5212\u4E2D" : enabled ? "\u8FD0\u884C\u4E2D" : "\u5DF2\u505C\u7528")
|
|
15159
15919
|
),
|
|
15160
15920
|
// 启停开关(规划中的功能不显示)
|
|
15161
|
-
m.planned ? null :
|
|
15921
|
+
m.planned ? null : import_react22.default.createElement("button", {
|
|
15162
15922
|
type: "button",
|
|
15163
15923
|
className: "dock-sw" + (enabled ? " on" : ""),
|
|
15164
15924
|
role: "switch",
|
|
@@ -15173,12 +15933,12 @@ function HomeView(props) {
|
|
|
15173
15933
|
}
|
|
15174
15934
|
})
|
|
15175
15935
|
),
|
|
15176
|
-
|
|
15177
|
-
|
|
15178
|
-
|
|
15936
|
+
import_react22.default.createElement("div", { className: "dockh-desc" }, m.description),
|
|
15937
|
+
import_react22.default.createElement("div", { className: "dockh-stat" }, statNode),
|
|
15938
|
+
import_react22.default.createElement(
|
|
15179
15939
|
"div",
|
|
15180
15940
|
{ className: "dockh-foot" },
|
|
15181
|
-
|
|
15941
|
+
import_react22.default.createElement("span", { className: "dockh-go" }, "\u67E5\u770B\u8BE6\u60C5 \u2192")
|
|
15182
15942
|
)
|
|
15183
15943
|
);
|
|
15184
15944
|
})
|
|
@@ -15186,16 +15946,16 @@ function HomeView(props) {
|
|
|
15186
15946
|
}
|
|
15187
15947
|
function DockPanel(props) {
|
|
15188
15948
|
const ctx = ctxRef.current;
|
|
15189
|
-
const [, force] =
|
|
15949
|
+
const [, force] = import_react22.default.useReducer((n) => n + 1, 0);
|
|
15190
15950
|
useExternalVersion();
|
|
15191
15951
|
const toggle = (id) => {
|
|
15192
15952
|
toggleFeature(id);
|
|
15193
15953
|
force();
|
|
15194
15954
|
};
|
|
15195
|
-
return
|
|
15955
|
+
return import_react22.default.createElement(
|
|
15196
15956
|
"div",
|
|
15197
15957
|
{ className: "dock-root" },
|
|
15198
|
-
|
|
15958
|
+
import_react22.default.createElement(
|
|
15199
15959
|
"div",
|
|
15200
15960
|
{ className: "dock-intro" },
|
|
15201
15961
|
"\u529F\u80FD\u575E\uFF08dsh-dock\uFF09\xB7 \u6240\u6709\u5C0F\u529F\u80FD\u96C6\u4E2D\u5728\u8FD9\u4E00\u4E2A\u9762\u677F\u91CC\u7BA1\u7406\u3002v0.4.0 \u8D77\u6BCF\u4E2A\u529F\u80FD\u662F\u72EC\u7ACB\u6A21\u5757\uFF08features/<id>/\uFF09\uFF0C",
|
|
@@ -15204,25 +15964,25 @@ function DockPanel(props) {
|
|
|
15204
15964
|
allModules().map((f) => {
|
|
15205
15965
|
const st = stateOf(f.id);
|
|
15206
15966
|
const View = f.View;
|
|
15207
|
-
const viewNode = !f.planned && st.enabled && View ?
|
|
15967
|
+
const viewNode = !f.planned && st.enabled && View ? import_react22.default.createElement(
|
|
15208
15968
|
"div",
|
|
15209
15969
|
{ className: "dock-body" },
|
|
15210
|
-
|
|
15970
|
+
import_react22.default.createElement(
|
|
15211
15971
|
FeatureBoundary,
|
|
15212
15972
|
{ key: f.id, label: f.name },
|
|
15213
|
-
|
|
15973
|
+
import_react22.default.createElement(View, { ctx, feature: f, params: props && props.params })
|
|
15214
15974
|
)
|
|
15215
15975
|
) : null;
|
|
15216
|
-
return
|
|
15976
|
+
return import_react22.default.createElement(
|
|
15217
15977
|
"div",
|
|
15218
15978
|
{ className: "dock-card", key: f.id },
|
|
15219
|
-
|
|
15979
|
+
import_react22.default.createElement(
|
|
15220
15980
|
"div",
|
|
15221
15981
|
{ className: "dock-card-head" },
|
|
15222
|
-
|
|
15223
|
-
|
|
15224
|
-
|
|
15225
|
-
f.planned ?
|
|
15982
|
+
import_react22.default.createElement("span", { className: "dock-dot" + (st.error ? " err" : st.enabled ? " on" : "") }),
|
|
15983
|
+
import_react22.default.createElement("span", { className: "dock-name" }, f.name),
|
|
15984
|
+
import_react22.default.createElement("span", { className: "dock-desc" }, f.description + (f.external ? "\uFF08\u6765\u81EA\u5916\u90E8\u5305" + (f.package ? " " + f.package : "") + "\uFF09" : "")),
|
|
15985
|
+
f.planned ? import_react22.default.createElement("span", { className: "dock-badge" }, "\u89C4\u5212\u4E2D") : import_react22.default.createElement("button", {
|
|
15226
15986
|
type: "button",
|
|
15227
15987
|
className: "dock-sw" + (st.enabled ? " on" : ""),
|
|
15228
15988
|
role: "switch",
|
|
@@ -15231,11 +15991,11 @@ function DockPanel(props) {
|
|
|
15231
15991
|
title: st.enabled ? "\u505C\u7528\u300C" + f.name + "\u300D" : "\u542F\u7528\u300C" + f.name + "\u300D",
|
|
15232
15992
|
onClick: () => toggle(f.id)
|
|
15233
15993
|
}),
|
|
15234
|
-
!f.planned && typeof f.Chip === "function" ?
|
|
15994
|
+
!f.planned && typeof f.Chip === "function" ? import_react22.default.createElement(
|
|
15235
15995
|
"span",
|
|
15236
15996
|
{ className: "dockm-foot-sw" },
|
|
15237
|
-
|
|
15238
|
-
|
|
15997
|
+
import_react22.default.createElement("span", { className: "dockm-foot-swlabel" + (chipShown(f.id) ? " on" : "") }, "\u4F1A\u8BDD\u9875\u5C0F\u63A7\u4EF6"),
|
|
15998
|
+
import_react22.default.createElement("button", {
|
|
15239
15999
|
type: "button",
|
|
15240
16000
|
className: "dock-sw" + (chipShown(f.id) ? " on" : ""),
|
|
15241
16001
|
role: "switch",
|
|
@@ -15249,7 +16009,7 @@ function DockPanel(props) {
|
|
|
15249
16009
|
})
|
|
15250
16010
|
) : null
|
|
15251
16011
|
),
|
|
15252
|
-
f.planned ?
|
|
16012
|
+
f.planned ? import_react22.default.createElement("div", { className: "dock-body" }, PLANNED_NOTES[f.id] || "\u5F85\u63A5\u5165\uFF1A\u89C1 README \u8DEF\u7EBF\u56FE") : st.error ? import_react22.default.createElement("div", { className: "dock-body dockm-err" }, "\u529F\u80FD\u51FA\u9519\uFF1A" + st.error) : null,
|
|
15253
16013
|
viewNode
|
|
15254
16014
|
);
|
|
15255
16015
|
})
|
|
@@ -15257,7 +16017,7 @@ function DockPanel(props) {
|
|
|
15257
16017
|
}
|
|
15258
16018
|
function DockPage() {
|
|
15259
16019
|
const ctx = ctxRef.current;
|
|
15260
|
-
const [wide, setWide] =
|
|
16020
|
+
const [wide, setWide] = import_react22.default.useState(false);
|
|
15261
16021
|
const toggleWide = () => {
|
|
15262
16022
|
try {
|
|
15263
16023
|
const layout = ctx && typeof ctx.get === "function" ? ctx.get("layout") : null;
|
|
@@ -15268,20 +16028,20 @@ function DockPage() {
|
|
|
15268
16028
|
} catch (e) {
|
|
15269
16029
|
}
|
|
15270
16030
|
};
|
|
15271
|
-
return
|
|
16031
|
+
return import_react22.default.createElement(
|
|
15272
16032
|
"div",
|
|
15273
16033
|
{ className: "dockm-page" + (wide ? " dockm-page-wide" : "") },
|
|
15274
|
-
|
|
16034
|
+
import_react22.default.createElement(
|
|
15275
16035
|
"div",
|
|
15276
16036
|
{ className: "dockm-page-head" },
|
|
15277
|
-
|
|
15278
|
-
|
|
16037
|
+
import_react22.default.createElement("span", { className: "dockm-page-icon" }, import_react22.default.createElement(DockIcon, { size: 20 })),
|
|
16038
|
+
import_react22.default.createElement(
|
|
15279
16039
|
"div",
|
|
15280
16040
|
{ className: "dockm-page-titles" },
|
|
15281
|
-
|
|
15282
|
-
|
|
16041
|
+
import_react22.default.createElement("div", { className: "dockm-page-title" }, "\u529F\u80FD\u575E"),
|
|
16042
|
+
import_react22.default.createElement("div", { className: "dockm-page-sub" }, "\u6240\u6709\u5C0F\u529F\u80FD\u96C6\u4E2D\u5728\u8FD9\u91CC\u7BA1\u7406\u3002\u4FA7\u680F\u56FE\u6807\u53EF\u5728\u300C\u66F4\u591A\u300D\u83DC\u5355\u91CC Pin \u5230\u9876\u90E8\uFF0C\u6216\u53D6\u6D88\u56FA\u5B9A\u6536\u8FDB\u66F4\u591A\u3002")
|
|
15283
16043
|
),
|
|
15284
|
-
|
|
16044
|
+
import_react22.default.createElement("button", {
|
|
15285
16045
|
type: "button",
|
|
15286
16046
|
className: "dockm-page-wide-btn",
|
|
15287
16047
|
title: wide ? "\u8FD8\u539F\u4FA7\u680F\u5BBD\u5EA6" : "\u6536\u8D77\u5DE6\u4FA7\u680F\uFF0C\u5168\u5C4F\u663E\u793A\u529F\u80FD\u575E",
|
|
@@ -15289,19 +16049,19 @@ function DockPage() {
|
|
|
15289
16049
|
onClick: toggleWide
|
|
15290
16050
|
}, wide ? "\u2750 \u8FD8\u539F" : "\u25A2 \u5168\u5C4F")
|
|
15291
16051
|
),
|
|
15292
|
-
|
|
16052
|
+
import_react22.default.createElement("div", { className: "dockm-page-body" }, import_react22.default.createElement(DockWorkspace, null))
|
|
15293
16053
|
);
|
|
15294
16054
|
}
|
|
15295
16055
|
function DockChips(props) {
|
|
15296
|
-
const [, force] =
|
|
15297
|
-
|
|
16056
|
+
const [, force] = import_react22.default.useReducer((n) => n + 1, 0);
|
|
16057
|
+
import_react22.default.useEffect(() => subscribeFeatureState(() => force()), []);
|
|
15298
16058
|
const items = [];
|
|
15299
16059
|
for (const f of allModules()) {
|
|
15300
16060
|
if (f.planned || !stateOf(f.id).enabled || !chipShown(f.id) || typeof f.Chip !== "function") continue;
|
|
15301
|
-
items.push(
|
|
16061
|
+
items.push(import_react22.default.createElement(
|
|
15302
16062
|
FeatureBoundary,
|
|
15303
16063
|
{ key: f.id, label: f.name },
|
|
15304
|
-
|
|
16064
|
+
import_react22.default.createElement(f.Chip, {
|
|
15305
16065
|
ctx: props.ctx,
|
|
15306
16066
|
feature: f,
|
|
15307
16067
|
session: props.session,
|
|
@@ -15311,38 +16071,38 @@ function DockChips(props) {
|
|
|
15311
16071
|
));
|
|
15312
16072
|
}
|
|
15313
16073
|
if (items.length === 0) return null;
|
|
15314
|
-
return
|
|
16074
|
+
return import_react22.default.createElement("div", { className: "dockchip-row" }, items);
|
|
15315
16075
|
}
|
|
15316
16076
|
function FeatureOverlays() {
|
|
15317
|
-
const [, force] =
|
|
16077
|
+
const [, force] = import_react22.default.useReducer((n) => n + 1, 0);
|
|
15318
16078
|
useExternalVersion();
|
|
15319
|
-
|
|
16079
|
+
import_react22.default.useEffect(() => subscribeFeatureState(() => force()), []);
|
|
15320
16080
|
const items = [];
|
|
15321
16081
|
for (const f of allModules()) {
|
|
15322
16082
|
if (f.planned || !stateOf(f.id).enabled || typeof f.Overlay !== "function") continue;
|
|
15323
|
-
items.push(
|
|
16083
|
+
items.push(import_react22.default.createElement(
|
|
15324
16084
|
FeatureBoundary,
|
|
15325
16085
|
{ key: f.id, label: f.name },
|
|
15326
|
-
|
|
16086
|
+
import_react22.default.createElement(f.Overlay, { ctx: ctxRef.current, feature: f })
|
|
15327
16087
|
));
|
|
15328
16088
|
}
|
|
15329
16089
|
if (items.length === 0) return null;
|
|
15330
|
-
return
|
|
16090
|
+
return import_react22.default.createElement(import_react22.default.Fragment, null, items);
|
|
15331
16091
|
}
|
|
15332
16092
|
function FeatureTurnTail(props) {
|
|
15333
|
-
const [, force] =
|
|
15334
|
-
|
|
16093
|
+
const [, force] = import_react22.default.useReducer((n) => n + 1, 0);
|
|
16094
|
+
import_react22.default.useEffect(() => subscribeFeatureState(() => force()), []);
|
|
15335
16095
|
const items = [];
|
|
15336
16096
|
for (const f of allModules()) {
|
|
15337
16097
|
if (f.planned || !stateOf(f.id).enabled || typeof f.TurnTail !== "function") continue;
|
|
15338
|
-
items.push(
|
|
16098
|
+
items.push(import_react22.default.createElement(
|
|
15339
16099
|
FeatureBoundary,
|
|
15340
16100
|
{ key: f.id, label: f.name },
|
|
15341
|
-
|
|
16101
|
+
import_react22.default.createElement(f.TurnTail, Object.assign({}, props, { ctx: ctxRef.current, feature: f }))
|
|
15342
16102
|
));
|
|
15343
16103
|
}
|
|
15344
16104
|
if (items.length === 0) return null;
|
|
15345
|
-
return
|
|
16105
|
+
return import_react22.default.createElement(import_react22.default.Fragment, null, items);
|
|
15346
16106
|
}
|
|
15347
16107
|
var ctxRef = { current: null };
|
|
15348
16108
|
function apply(ctx) {
|
|
@@ -15353,31 +16113,31 @@ function apply(ctx) {
|
|
|
15353
16113
|
if (slots === void 0) return;
|
|
15354
16114
|
slots.inject("sidebar.panellist", () => slots.register(
|
|
15355
16115
|
{ name: "sidebar.panellist", id: "dsh-dock", order: 30, label: "\u529F\u80FD\u575E" },
|
|
15356
|
-
(props) =>
|
|
16116
|
+
(props) => import_react22.default.createElement(DockIcon, { size: props && props.size || 18 })
|
|
15357
16117
|
));
|
|
15358
16118
|
slots.inject("main", () => slots.register(
|
|
15359
16119
|
{ name: "main", key: "dsh-dock", label: "\u529F\u80FD\u575E" },
|
|
15360
|
-
() =>
|
|
16120
|
+
() => import_react22.default.createElement(DockPage, null)
|
|
15361
16121
|
));
|
|
15362
16122
|
slots.inject("shell.overlay", () => slots.register(
|
|
15363
16123
|
{ name: "shell.overlay", id: "dsh-dock-panel", order: 21, label: "\u529F\u80FD\u575E\u9762\u677F" },
|
|
15364
|
-
() =>
|
|
16124
|
+
() => import_react22.default.createElement(DockModal, null)
|
|
15365
16125
|
));
|
|
15366
16126
|
slots.inject("shell.overlay", () => slots.register(
|
|
15367
16127
|
{ name: "shell.overlay", id: "dsh-dock-feature-overlays", order: 22, label: "\u529F\u80FD\u575E\u5168\u5C40\u6D6E\u5C42" },
|
|
15368
|
-
() =>
|
|
16128
|
+
() => import_react22.default.createElement(FeatureOverlays, null)
|
|
15369
16129
|
));
|
|
15370
16130
|
slots.inject("settings.section", () => slots.register(
|
|
15371
16131
|
{ name: "settings.section", id: "dsh-dock", order: 90, label: "\u529F\u80FD\u575E" },
|
|
15372
|
-
(props) =>
|
|
16132
|
+
(props) => import_react22.default.createElement(DockPanel, props)
|
|
15373
16133
|
));
|
|
15374
16134
|
slots.inject("conversation.input.left", () => slots.register(
|
|
15375
16135
|
{ name: "conversation.input.left", id: "dsh-dock-chips", order: 10, label: "\u529F\u80FD\u575E" },
|
|
15376
|
-
(zone) =>
|
|
16136
|
+
(zone) => import_react22.default.createElement(DockChips, Object.assign({}, zone, { ctx: ctxRef.current }))
|
|
15377
16137
|
));
|
|
15378
16138
|
slots.inject("conversation.chat.turnTail", () => slots.register(
|
|
15379
16139
|
{ name: "conversation.chat.turnTail", id: "dsh-dock-turn-tail", order: 40, label: "\u529F\u80FD\u575E" },
|
|
15380
|
-
(owner) =>
|
|
16140
|
+
(owner) => import_react22.default.createElement(FeatureTurnTail, owner)
|
|
15381
16141
|
));
|
|
15382
16142
|
}
|
|
15383
16143
|
var inject = ["timer"];
|