@goodpeanuts/dsh-sui 0.1.2-fix.1 → 0.1.2-fix.2
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 +1 -1
- package/bundles/sui-ledger/dist/capabilities/book-authorization.mjs +96 -0
- package/bundles/sui-ledger/dist/capabilities/tools.mjs +12 -2
- package/bundles/sui-ledger/dist/client.js +579 -414
- package/bundles/sui-ledger/dist/finance-state-context.mjs +1 -1
- package/bundles/sui-ledger/dist/index.mjs +14 -1
- package/bundles/sui-ledger/dist/node_modules/.pnpm/{@deepseek-ai_dsh-home-paths_159c15e70066431314381a350c2ee56a → @deepseek-ai_dsh-home-paths_43f382ed782d46f05123e7add538564e}/node_modules/@deepseek-ai/dsh-home-paths/lib/index.mjs +1 -1
- package/bundles/sui-ledger/dist/packages/finance-module/src/capabilities.mjs +1 -1
- package/bundles/sui-ledger/dist/packages/finance-module/src/service.mjs +2 -2
- package/bundles/sui-ledger/dist/packages/finance-module/src/tool-contracts.mjs +2 -2
- package/bundles/sui-ledger/dist/storage/business-runtime.mjs +1 -0
- package/bundles/sui-ledger/dist/storage/paths.mjs +1 -1
- package/bundles/sui-ledger/dist/style.css +114 -5
- package/package.json +1 -1
|
@@ -1128,6 +1128,10 @@ window.__ModuleLoader__.load({
|
|
|
1128
1128
|
section: "sync",
|
|
1129
1129
|
query: { view: "backup" }
|
|
1130
1130
|
};
|
|
1131
|
+
if (match.routeId === FinanceRouteIds.authorization) return {
|
|
1132
|
+
section: "sync",
|
|
1133
|
+
query: { view: "authorization" }
|
|
1134
|
+
};
|
|
1131
1135
|
if (match.routeId === FinanceRouteIds.setup) return { section: "sync" };
|
|
1132
1136
|
if (match.routeId === FinanceRouteIds.preferences) return { section: "preferences" };
|
|
1133
1137
|
const bookId = match.params.bookId;
|
|
@@ -1230,6 +1234,7 @@ window.__ModuleLoader__.load({
|
|
|
1230
1234
|
};
|
|
1231
1235
|
}
|
|
1232
1236
|
function ledgerRouteTarget(route) {
|
|
1237
|
+
if (route.section === "sync" && route.query?.view === "authorization") return { routeId: FinanceRouteIds.authorization };
|
|
1233
1238
|
if (route.section === "sync" && route.query?.view === "backup") return { routeId: FinanceRouteIds.maintenance };
|
|
1234
1239
|
if (route.section === "sync" && !route.bookId) return { routeId: FinanceRouteIds.setup };
|
|
1235
1240
|
if (route.section === "preferences") return { routeId: FinanceRouteIds.preferences };
|
|
@@ -1341,6 +1346,7 @@ window.__ModuleLoader__.load({
|
|
|
1341
1346
|
} else if (routeId === FinanceRouteIds.sync) set("view", search.get("view"), [
|
|
1342
1347
|
"changes",
|
|
1343
1348
|
"valuation",
|
|
1349
|
+
"authorization",
|
|
1344
1350
|
"backup"
|
|
1345
1351
|
].includes(search.get("view") ?? ""));
|
|
1346
1352
|
else if (routeId === FinanceRouteIds.accounts) set("group", search.get("group"));
|
|
@@ -1411,6 +1417,7 @@ window.__ModuleLoader__.load({
|
|
|
1411
1417
|
preferences: "finance.ledger.preferences",
|
|
1412
1418
|
maintenance: "finance.ledger.maintenance",
|
|
1413
1419
|
setup: "finance.ledger.setup",
|
|
1420
|
+
authorization: "finance.ledger.authorization",
|
|
1414
1421
|
overview: "finance.ledger.overview",
|
|
1415
1422
|
transactions: "finance.ledger.transactions",
|
|
1416
1423
|
transactionDetail: "finance.ledger.transaction-detail",
|
|
@@ -10514,6 +10521,229 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
10514
10521
|
init_memo_policy();
|
|
10515
10522
|
}));
|
|
10516
10523
|
//#endregion
|
|
10524
|
+
//#region ../../packages/finance-ui/src/book-grant.css
|
|
10525
|
+
var init_book_grant$1 = __esmMin((() => {}));
|
|
10526
|
+
//#endregion
|
|
10527
|
+
//#region ../../packages/finance-ui/src/book-grant.tsx
|
|
10528
|
+
/** A contextual switch inside financial UI, never mounted in an ordinary composer. */
|
|
10529
|
+
function BookGrantControl({ subjectId, client, onOpenLedger, disabled = false }) {
|
|
10530
|
+
const [opened, setOpened] = (0, react.useState)(false);
|
|
10531
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
10532
|
+
className: "sui-ledger-draft-ui book-grant-control",
|
|
10533
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
10534
|
+
type: "button",
|
|
10535
|
+
className: "book-grant-trigger",
|
|
10536
|
+
"aria-haspopup": "dialog",
|
|
10537
|
+
"aria-expanded": opened,
|
|
10538
|
+
title: "查看或切换本会话使用的账本",
|
|
10539
|
+
disabled,
|
|
10540
|
+
onClick: () => setOpened(true),
|
|
10541
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "book" }), "切换账本"]
|
|
10542
|
+
}), opened && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
10543
|
+
className: "sui-ledger-draft-ui",
|
|
10544
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BookGrantDialog, {
|
|
10545
|
+
subjectId,
|
|
10546
|
+
client,
|
|
10547
|
+
onClose: () => setOpened(false),
|
|
10548
|
+
onOpenLedger
|
|
10549
|
+
})
|
|
10550
|
+
}), document.body)]
|
|
10551
|
+
});
|
|
10552
|
+
}
|
|
10553
|
+
function BookGrantDialog({ subjectId, client, onClose, onOpenLedger }) {
|
|
10554
|
+
const dialog = (0, react.useRef)(null);
|
|
10555
|
+
const alive = (0, react.useRef)(true);
|
|
10556
|
+
const running = (0, react.useRef)(false);
|
|
10557
|
+
const [data, setData] = (0, react.useState)(null);
|
|
10558
|
+
const [selected, setSelected] = (0, react.useState)("");
|
|
10559
|
+
const [makeDefault, setMakeDefault] = (0, react.useState)(false);
|
|
10560
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
10561
|
+
const [error, setError] = (0, react.useState)("");
|
|
10562
|
+
const load = (0, react.useCallback)(async () => {
|
|
10563
|
+
if (running.current) return;
|
|
10564
|
+
running.current = true;
|
|
10565
|
+
setBusy(true);
|
|
10566
|
+
setError("");
|
|
10567
|
+
setData(null);
|
|
10568
|
+
setMakeDefault(false);
|
|
10569
|
+
try {
|
|
10570
|
+
if (!client.requestBookGrantSelection) throw new Error("请更新插件后重试。");
|
|
10571
|
+
const next = await client.requestBookGrantSelection(subjectId);
|
|
10572
|
+
if (!alive.current) return;
|
|
10573
|
+
setData(next);
|
|
10574
|
+
const preferred = next.grant?.bookId ?? next.defaultBookId;
|
|
10575
|
+
setSelected(next.books.find((book) => book.id === preferred)?.id ?? next.books[0]?.id ?? "");
|
|
10576
|
+
} catch {
|
|
10577
|
+
if (alive.current) setError("无法读取账本授权,请重试。");
|
|
10578
|
+
} finally {
|
|
10579
|
+
running.current = false;
|
|
10580
|
+
if (alive.current) setBusy(false);
|
|
10581
|
+
}
|
|
10582
|
+
}, [client, subjectId]);
|
|
10583
|
+
(0, react.useEffect)(() => {
|
|
10584
|
+
alive.current = true;
|
|
10585
|
+
const element = dialog.current;
|
|
10586
|
+
element.showModal();
|
|
10587
|
+
load();
|
|
10588
|
+
return () => {
|
|
10589
|
+
alive.current = false;
|
|
10590
|
+
element.close();
|
|
10591
|
+
};
|
|
10592
|
+
}, [load]);
|
|
10593
|
+
const finish = async (decision) => {
|
|
10594
|
+
if (running.current) return;
|
|
10595
|
+
if (!data || !client.respondBookGrantSelection) {
|
|
10596
|
+
onClose();
|
|
10597
|
+
return;
|
|
10598
|
+
}
|
|
10599
|
+
running.current = true;
|
|
10600
|
+
setBusy(true);
|
|
10601
|
+
setError("");
|
|
10602
|
+
try {
|
|
10603
|
+
await client.respondBookGrantSelection(subjectId, data.request.id, {
|
|
10604
|
+
decision,
|
|
10605
|
+
...decision === "confirm" ? {
|
|
10606
|
+
bookId: selected,
|
|
10607
|
+
makeDefault
|
|
10608
|
+
} : {}
|
|
10609
|
+
});
|
|
10610
|
+
window.dispatchEvent(new Event("sui-ledger:finance-updated"));
|
|
10611
|
+
if (alive.current) onClose();
|
|
10612
|
+
} catch (cause) {
|
|
10613
|
+
if (!alive.current) return;
|
|
10614
|
+
if (decision === "cancel") onClose();
|
|
10615
|
+
else if (cause instanceof Error && cause.message === "finance_draft_book_change_blocked") setError("当前会话仍有流水草稿,请先将其加入待入账或移除全部条目,再切换账本。");
|
|
10616
|
+
else setError("授权未完成,账本可能已在其他页面更改。请重新读取后确认。");
|
|
10617
|
+
} finally {
|
|
10618
|
+
running.current = false;
|
|
10619
|
+
if (alive.current) setBusy(false);
|
|
10620
|
+
}
|
|
10621
|
+
};
|
|
10622
|
+
const clearDefault = async () => {
|
|
10623
|
+
if (running.current || !client.setDefaultBook) return;
|
|
10624
|
+
running.current = true;
|
|
10625
|
+
setBusy(true);
|
|
10626
|
+
setError("");
|
|
10627
|
+
try {
|
|
10628
|
+
await client.setDefaultBook(null);
|
|
10629
|
+
if (alive.current) {
|
|
10630
|
+
setData((current) => current && {
|
|
10631
|
+
...current,
|
|
10632
|
+
defaultBookId: null
|
|
10633
|
+
});
|
|
10634
|
+
setMakeDefault(false);
|
|
10635
|
+
}
|
|
10636
|
+
} catch {
|
|
10637
|
+
if (alive.current) setError("清除默认账本失败,请重试。");
|
|
10638
|
+
} finally {
|
|
10639
|
+
running.current = false;
|
|
10640
|
+
if (alive.current) setBusy(false);
|
|
10641
|
+
}
|
|
10642
|
+
};
|
|
10643
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dialog", {
|
|
10644
|
+
ref: dialog,
|
|
10645
|
+
className: "book-grant-dialog",
|
|
10646
|
+
"aria-labelledby": "book-grant-title",
|
|
10647
|
+
onCancel: (event) => {
|
|
10648
|
+
event.preventDefault();
|
|
10649
|
+
finish("cancel");
|
|
10650
|
+
},
|
|
10651
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
10652
|
+
onSubmit: (event) => {
|
|
10653
|
+
event.preventDefault();
|
|
10654
|
+
if (selected && !busy) finish("confirm");
|
|
10655
|
+
},
|
|
10656
|
+
children: [
|
|
10657
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
10658
|
+
id: "book-grant-title",
|
|
10659
|
+
children: "选择会话账本"
|
|
10660
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
10661
|
+
type: "button",
|
|
10662
|
+
tone: "ghost",
|
|
10663
|
+
disabled: busy,
|
|
10664
|
+
"aria-label": "关闭账本授权",
|
|
10665
|
+
onClick: () => void finish("cancel"),
|
|
10666
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "close" })
|
|
10667
|
+
})] }),
|
|
10668
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "授权后,当前会话可读取所选账本并维护草稿;实际入账仍需单独人工确认。" }),
|
|
10669
|
+
data && data.books.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
10670
|
+
className: "workset-field",
|
|
10671
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "授权账本" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
10672
|
+
value: selected,
|
|
10673
|
+
disabled: busy,
|
|
10674
|
+
onChange: (event) => setSelected(event.currentTarget.value),
|
|
10675
|
+
children: data.books.map((book) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
10676
|
+
value: book.id,
|
|
10677
|
+
children: book.name || book.id
|
|
10678
|
+
}, book.id))
|
|
10679
|
+
})]
|
|
10680
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
10681
|
+
className: "book-grant-default",
|
|
10682
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
10683
|
+
type: "checkbox",
|
|
10684
|
+
checked: makeDefault,
|
|
10685
|
+
disabled: busy,
|
|
10686
|
+
onChange: (event) => setMakeDefault(event.currentTarget.checked)
|
|
10687
|
+
}), "设为默认账本,供尚未授权的会话自动使用"]
|
|
10688
|
+
})] }),
|
|
10689
|
+
data && data.books.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
10690
|
+
role: "status",
|
|
10691
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "尚无可用账本,请先在账本页面登录并同步。" }), onOpenLedger && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
10692
|
+
type: "button",
|
|
10693
|
+
disabled: busy,
|
|
10694
|
+
onClick: () => {
|
|
10695
|
+
finish("cancel").then(onOpenLedger);
|
|
10696
|
+
},
|
|
10697
|
+
children: "打开账本"
|
|
10698
|
+
})]
|
|
10699
|
+
}),
|
|
10700
|
+
data?.defaultBookId && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
10701
|
+
className: "book-grant-current-default",
|
|
10702
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["默认账本:", data.books.find((book) => book.id === data.defaultBookId)?.name ?? data.defaultBookId] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
10703
|
+
type: "button",
|
|
10704
|
+
tone: "ghost",
|
|
10705
|
+
disabled: busy,
|
|
10706
|
+
onClick: () => void clearDefault(),
|
|
10707
|
+
children: "清除默认账本"
|
|
10708
|
+
})]
|
|
10709
|
+
}),
|
|
10710
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
10711
|
+
role: "alert",
|
|
10712
|
+
children: error
|
|
10713
|
+
}),
|
|
10714
|
+
busy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
10715
|
+
role: "status",
|
|
10716
|
+
children: "正在处理…"
|
|
10717
|
+
}),
|
|
10718
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", { children: [
|
|
10719
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
10720
|
+
type: "button",
|
|
10721
|
+
disabled: busy,
|
|
10722
|
+
onClick: () => void finish("cancel"),
|
|
10723
|
+
children: "取消"
|
|
10724
|
+
}),
|
|
10725
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
10726
|
+
type: "button",
|
|
10727
|
+
disabled: busy,
|
|
10728
|
+
onClick: () => void load(),
|
|
10729
|
+
children: "重新读取"
|
|
10730
|
+
}),
|
|
10731
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
10732
|
+
type: "submit",
|
|
10733
|
+
tone: "primary",
|
|
10734
|
+
disabled: busy || !data?.books.length || !selected,
|
|
10735
|
+
children: "确认授权"
|
|
10736
|
+
})
|
|
10737
|
+
] })
|
|
10738
|
+
]
|
|
10739
|
+
})
|
|
10740
|
+
});
|
|
10741
|
+
}
|
|
10742
|
+
var init_book_grant = __esmMin((() => {
|
|
10743
|
+
init_src$2();
|
|
10744
|
+
init_book_grant$1();
|
|
10745
|
+
}));
|
|
10746
|
+
//#endregion
|
|
10517
10747
|
//#region ../../packages/finance-ui/src/draft-view.ts
|
|
10518
10748
|
/** Session surfaces share one open-note read/poll; archives are never loaded. */
|
|
10519
10749
|
function draftSource(client, subjectId) {
|
|
@@ -10755,9 +10985,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
10755
10985
|
role: "status",
|
|
10756
10986
|
children: [props.validation.issues.length, " 项待检查"]
|
|
10757
10987
|
}),
|
|
10758
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
10988
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
10759
10989
|
className: "candidate-head-actions",
|
|
10760
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
10990
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(BookGrantControl, {
|
|
10991
|
+
subjectId: props.subjectId,
|
|
10992
|
+
client: props.client,
|
|
10993
|
+
disabled: busy || dirty
|
|
10994
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
10761
10995
|
type: "button",
|
|
10762
10996
|
className: "draft-icon-btn",
|
|
10763
10997
|
"data-panel-action": "close",
|
|
@@ -10765,7 +10999,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
10765
10999
|
disabled: busy,
|
|
10766
11000
|
onClick: props.onClose,
|
|
10767
11001
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "close" })
|
|
10768
|
-
})
|
|
11002
|
+
})]
|
|
10769
11003
|
})
|
|
10770
11004
|
]
|
|
10771
11005
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -11089,336 +11323,100 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11089
11323
|
}),
|
|
11090
11324
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: editable ? "编辑流水" : "流水详情" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: operation === "matched" ? "账本已有" : missing ? `待补齐:${missing}` : operation === "delete" ? "待删除" : operation === "update" ? "待修改" : "待新建" })] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
11091
11325
|
type: "button",
|
|
11092
|
-
"aria-label": "关闭",
|
|
11093
|
-
title: "关闭",
|
|
11094
|
-
disabled: props.busy,
|
|
11095
|
-
onClick: props.onClose,
|
|
11096
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "close" })
|
|
11097
|
-
})] }),
|
|
11098
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11099
|
-
className: `candidate-edit-panel-scroll${editable ? " is-editing" : ""}`,
|
|
11100
|
-
children: editable && props.editorState ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DraftInlineEditor, {
|
|
11101
|
-
state: props.editorState,
|
|
11102
|
-
onChange: props.onEditorChange,
|
|
11103
|
-
entry: props.entry,
|
|
11104
|
-
...props.referenceData ? { referenceData: props.referenceData } : {},
|
|
11105
|
-
busy: props.busy,
|
|
11106
|
-
error: props.error,
|
|
11107
|
-
summary,
|
|
11108
|
-
onCancel: props.onClose,
|
|
11109
|
-
onSave: props.onSave
|
|
11110
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
11111
|
-
summary,
|
|
11112
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
11113
|
-
className: "candidate-panel-details",
|
|
11114
|
-
children: [
|
|
11115
|
-
["类型", facts.direction === "income" ? "收入" : facts.direction === "transfer" ? "转账" : facts.direction === "expense" ? "支出" : "待补齐"],
|
|
11116
|
-
["金额", facts.amount],
|
|
11117
|
-
["时间", facts.occurredAt],
|
|
11118
|
-
["账户", facts.account],
|
|
11119
|
-
["分类", facts.category],
|
|
11120
|
-
["商家", facts.store || "未关联"],
|
|
11121
|
-
["备注", facts.detail || "—"]
|
|
11122
|
-
].map(([label, value]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11123
|
-
className: label === "备注" ? "wide" : "",
|
|
11124
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: value })]
|
|
11125
|
-
}, label))
|
|
11126
|
-
}),
|
|
11127
|
-
operation === "delete" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11128
|
-
className: "candidate-panel-actions",
|
|
11129
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
11130
|
-
disabled: props.busy,
|
|
11131
|
-
onClick: props.onRemove,
|
|
11132
|
-
children: "从草稿删除"
|
|
11133
|
-
})
|
|
11134
|
-
}),
|
|
11135
|
-
props.error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11136
|
-
className: "candidate-panel-error",
|
|
11137
|
-
role: "alert",
|
|
11138
|
-
children: props.error
|
|
11139
|
-
})
|
|
11140
|
-
] })
|
|
11141
|
-
})
|
|
11142
|
-
]
|
|
11143
|
-
});
|
|
11144
|
-
}
|
|
11145
|
-
function groupEntriesByTab(entries) {
|
|
11146
|
-
const groups = {
|
|
11147
|
-
ready: [],
|
|
11148
|
-
pending: [],
|
|
11149
|
-
matched: []
|
|
11150
|
-
};
|
|
11151
|
-
for (const entry of entries) groups[draftEntryNeedsCompletion(entry) ? "pending" : entry.draft?.operation === "matched" ? "matched" : "ready"].push(entry);
|
|
11152
|
-
return groups;
|
|
11153
|
-
}
|
|
11154
|
-
function groupEntriesByAccount(entries, referenceData) {
|
|
11155
|
-
const groups = /* @__PURE__ */ new Map();
|
|
11156
|
-
for (const entry of entries) {
|
|
11157
|
-
const fields = {
|
|
11158
|
-
...entry.original,
|
|
11159
|
-
...entry.draft?.fields
|
|
11160
|
-
};
|
|
11161
|
-
const id = typeof fields.accountId === "string" ? fields.accountId : "__unassigned__";
|
|
11162
|
-
const name = referenceData?.accounts.find((account) => account.id === id)?.name ?? draftEntryFacts(entry, referenceData).accountKindName ?? "未指定账户";
|
|
11163
|
-
const group = groups.get(id) ?? {
|
|
11164
|
-
id,
|
|
11165
|
-
name,
|
|
11166
|
-
items: []
|
|
11167
|
-
};
|
|
11168
|
-
group.items.push(entry);
|
|
11169
|
-
groups.set(id, group);
|
|
11170
|
-
}
|
|
11171
|
-
return [...groups.values()];
|
|
11172
|
-
}
|
|
11173
|
-
var TAB_LABELS;
|
|
11174
|
-
var init_draft_card = __esmMin((() => {
|
|
11175
|
-
init_src$2();
|
|
11176
|
-
init_web_contracts();
|
|
11177
|
-
init_src();
|
|
11178
|
-
init_draft_entry_editor();
|
|
11179
|
-
init_draft_view();
|
|
11180
|
-
TAB_LABELS = {
|
|
11181
|
-
ready: "待处理",
|
|
11182
|
-
pending: "待补齐",
|
|
11183
|
-
matched: "账本已有"
|
|
11184
|
-
};
|
|
11185
|
-
}));
|
|
11186
|
-
//#endregion
|
|
11187
|
-
//#region ../../packages/finance-ui/src/book-grant.css
|
|
11188
|
-
var init_book_grant$1 = __esmMin((() => {}));
|
|
11189
|
-
//#endregion
|
|
11190
|
-
//#region ../../packages/finance-ui/src/book-grant.tsx
|
|
11191
|
-
/** Available before the first draft exists: authorization must not depend on authorized work. */
|
|
11192
|
-
function BookGrantControl({ subjectId, client, onOpenLedger }) {
|
|
11193
|
-
const [opened, setOpened] = (0, react.useState)(false);
|
|
11194
|
-
const [bound, setBound] = (0, react.useState)(false);
|
|
11195
|
-
(0, react.useEffect)(() => {
|
|
11196
|
-
let active = true;
|
|
11197
|
-
const refresh = () => {
|
|
11198
|
-
client.getSubjectGrant(subjectId).then((grant) => {
|
|
11199
|
-
if (active) setBound(Boolean(grant));
|
|
11200
|
-
}).catch(() => {});
|
|
11201
|
-
};
|
|
11202
|
-
refresh();
|
|
11203
|
-
window.addEventListener("sui-ledger:finance-updated", refresh);
|
|
11204
|
-
return () => {
|
|
11205
|
-
active = false;
|
|
11206
|
-
window.removeEventListener("sui-ledger:finance-updated", refresh);
|
|
11207
|
-
};
|
|
11208
|
-
}, [client, subjectId]);
|
|
11209
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11210
|
-
className: "sui-ledger-draft-ui book-grant-control",
|
|
11211
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
11212
|
-
type: "button",
|
|
11213
|
-
className: "book-grant-trigger",
|
|
11214
|
-
"aria-haspopup": "dialog",
|
|
11215
|
-
"aria-expanded": opened,
|
|
11216
|
-
title: bound ? "查看或切换会话账本" : "选择当前会话可访问的账本",
|
|
11217
|
-
onClick: () => setOpened(true),
|
|
11218
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "book" }), "账本授权"]
|
|
11219
|
-
}), opened && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11220
|
-
className: "sui-ledger-draft-ui",
|
|
11221
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BookGrantDialog, {
|
|
11222
|
-
subjectId,
|
|
11223
|
-
client,
|
|
11224
|
-
onClose: () => setOpened(false),
|
|
11225
|
-
onOpenLedger
|
|
11226
|
-
})
|
|
11227
|
-
}), document.body)]
|
|
11228
|
-
});
|
|
11229
|
-
}
|
|
11230
|
-
function BookGrantDialog({ subjectId, client, onClose, onOpenLedger }) {
|
|
11231
|
-
const dialog = (0, react.useRef)(null);
|
|
11232
|
-
const alive = (0, react.useRef)(true);
|
|
11233
|
-
const running = (0, react.useRef)(false);
|
|
11234
|
-
const [data, setData] = (0, react.useState)(null);
|
|
11235
|
-
const [selected, setSelected] = (0, react.useState)("");
|
|
11236
|
-
const [makeDefault, setMakeDefault] = (0, react.useState)(false);
|
|
11237
|
-
const [busy, setBusy] = (0, react.useState)(false);
|
|
11238
|
-
const [error, setError] = (0, react.useState)("");
|
|
11239
|
-
const load = (0, react.useCallback)(async () => {
|
|
11240
|
-
if (running.current) return;
|
|
11241
|
-
running.current = true;
|
|
11242
|
-
setBusy(true);
|
|
11243
|
-
setError("");
|
|
11244
|
-
setData(null);
|
|
11245
|
-
setMakeDefault(false);
|
|
11246
|
-
try {
|
|
11247
|
-
if (!client.requestBookGrantSelection) throw new Error("请更新插件后重试。");
|
|
11248
|
-
const next = await client.requestBookGrantSelection(subjectId);
|
|
11249
|
-
if (!alive.current) return;
|
|
11250
|
-
setData(next);
|
|
11251
|
-
const preferred = next.grant?.bookId ?? next.defaultBookId;
|
|
11252
|
-
setSelected(next.books.find((book) => book.id === preferred)?.id ?? next.books[0]?.id ?? "");
|
|
11253
|
-
} catch {
|
|
11254
|
-
if (alive.current) setError("无法读取账本授权,请重试。");
|
|
11255
|
-
} finally {
|
|
11256
|
-
running.current = false;
|
|
11257
|
-
if (alive.current) setBusy(false);
|
|
11258
|
-
}
|
|
11259
|
-
}, [client, subjectId]);
|
|
11260
|
-
(0, react.useEffect)(() => {
|
|
11261
|
-
alive.current = true;
|
|
11262
|
-
const element = dialog.current;
|
|
11263
|
-
element.showModal();
|
|
11264
|
-
load();
|
|
11265
|
-
return () => {
|
|
11266
|
-
alive.current = false;
|
|
11267
|
-
element.close();
|
|
11268
|
-
};
|
|
11269
|
-
}, [load]);
|
|
11270
|
-
const finish = async (decision) => {
|
|
11271
|
-
if (running.current) return;
|
|
11272
|
-
if (!data || !client.respondBookGrantSelection) {
|
|
11273
|
-
onClose();
|
|
11274
|
-
return;
|
|
11275
|
-
}
|
|
11276
|
-
running.current = true;
|
|
11277
|
-
setBusy(true);
|
|
11278
|
-
setError("");
|
|
11279
|
-
try {
|
|
11280
|
-
await client.respondBookGrantSelection(subjectId, data.request.id, {
|
|
11281
|
-
decision,
|
|
11282
|
-
...decision === "confirm" ? {
|
|
11283
|
-
bookId: selected,
|
|
11284
|
-
makeDefault
|
|
11285
|
-
} : {}
|
|
11286
|
-
});
|
|
11287
|
-
window.dispatchEvent(new Event("sui-ledger:finance-updated"));
|
|
11288
|
-
if (alive.current) onClose();
|
|
11289
|
-
} catch (cause) {
|
|
11290
|
-
if (!alive.current) return;
|
|
11291
|
-
if (decision === "cancel") onClose();
|
|
11292
|
-
else if (cause instanceof Error && cause.message === "finance_draft_book_change_blocked") setError("当前会话仍有流水草稿,请先将其加入待入账或移除全部条目,再切换账本。");
|
|
11293
|
-
else setError("授权未完成,账本可能已在其他页面更改。请重新读取后确认。");
|
|
11294
|
-
} finally {
|
|
11295
|
-
running.current = false;
|
|
11296
|
-
if (alive.current) setBusy(false);
|
|
11297
|
-
}
|
|
11298
|
-
};
|
|
11299
|
-
const clearDefault = async () => {
|
|
11300
|
-
if (running.current || !client.setDefaultBook) return;
|
|
11301
|
-
running.current = true;
|
|
11302
|
-
setBusy(true);
|
|
11303
|
-
setError("");
|
|
11304
|
-
try {
|
|
11305
|
-
await client.setDefaultBook(null);
|
|
11306
|
-
if (alive.current) {
|
|
11307
|
-
setData((current) => current && {
|
|
11308
|
-
...current,
|
|
11309
|
-
defaultBookId: null
|
|
11310
|
-
});
|
|
11311
|
-
setMakeDefault(false);
|
|
11312
|
-
}
|
|
11313
|
-
} catch {
|
|
11314
|
-
if (alive.current) setError("清除默认账本失败,请重试。");
|
|
11315
|
-
} finally {
|
|
11316
|
-
running.current = false;
|
|
11317
|
-
if (alive.current) setBusy(false);
|
|
11318
|
-
}
|
|
11319
|
-
};
|
|
11320
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dialog", {
|
|
11321
|
-
ref: dialog,
|
|
11322
|
-
className: "book-grant-dialog",
|
|
11323
|
-
"aria-labelledby": "book-grant-title",
|
|
11324
|
-
onCancel: (event) => {
|
|
11325
|
-
event.preventDefault();
|
|
11326
|
-
finish("cancel");
|
|
11327
|
-
},
|
|
11328
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
11329
|
-
onSubmit: (event) => {
|
|
11330
|
-
event.preventDefault();
|
|
11331
|
-
if (selected && !busy) finish("confirm");
|
|
11332
|
-
},
|
|
11333
|
-
children: [
|
|
11334
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
11335
|
-
id: "book-grant-title",
|
|
11336
|
-
children: "选择会话账本"
|
|
11337
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
11338
|
-
type: "button",
|
|
11339
|
-
tone: "ghost",
|
|
11340
|
-
disabled: busy,
|
|
11341
|
-
"aria-label": "关闭账本授权",
|
|
11342
|
-
onClick: () => void finish("cancel"),
|
|
11343
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "close" })
|
|
11344
|
-
})] }),
|
|
11345
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "授权后,当前会话可读取所选账本并维护草稿;实际入账仍需单独人工确认。" }),
|
|
11346
|
-
data && data.books.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
11347
|
-
className: "workset-field",
|
|
11348
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "授权账本" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
11349
|
-
value: selected,
|
|
11350
|
-
disabled: busy,
|
|
11351
|
-
onChange: (event) => setSelected(event.currentTarget.value),
|
|
11352
|
-
children: data.books.map((book) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
11353
|
-
value: book.id,
|
|
11354
|
-
children: book.name || book.id
|
|
11355
|
-
}, book.id))
|
|
11356
|
-
})]
|
|
11357
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
11358
|
-
className: "book-grant-default",
|
|
11359
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
11360
|
-
type: "checkbox",
|
|
11361
|
-
checked: makeDefault,
|
|
11362
|
-
disabled: busy,
|
|
11363
|
-
onChange: (event) => setMakeDefault(event.currentTarget.checked)
|
|
11364
|
-
}), "设为默认账本,供尚未授权的会话自动使用"]
|
|
11365
|
-
})] }),
|
|
11366
|
-
data && data.books.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11367
|
-
role: "status",
|
|
11368
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "尚无可用账本,请先在账本页面登录并同步。" }), onOpenLedger && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
11369
|
-
type: "button",
|
|
11370
|
-
disabled: busy,
|
|
11371
|
-
onClick: () => {
|
|
11372
|
-
finish("cancel").then(onOpenLedger);
|
|
11373
|
-
},
|
|
11374
|
-
children: "打开账本"
|
|
11375
|
-
})]
|
|
11376
|
-
}),
|
|
11377
|
-
data?.defaultBookId && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11378
|
-
className: "book-grant-current-default",
|
|
11379
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", { children: ["默认账本:", data.books.find((book) => book.id === data.defaultBookId)?.name ?? data.defaultBookId] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
11380
|
-
type: "button",
|
|
11381
|
-
tone: "ghost",
|
|
11382
|
-
disabled: busy,
|
|
11383
|
-
onClick: () => void clearDefault(),
|
|
11384
|
-
children: "清除默认账本"
|
|
11385
|
-
})]
|
|
11386
|
-
}),
|
|
11387
|
-
error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11388
|
-
role: "alert",
|
|
11389
|
-
children: error
|
|
11390
|
-
}),
|
|
11391
|
-
busy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11392
|
-
role: "status",
|
|
11393
|
-
children: "正在处理…"
|
|
11394
|
-
}),
|
|
11395
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", { children: [
|
|
11396
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
11397
|
-
type: "button",
|
|
11398
|
-
disabled: busy,
|
|
11399
|
-
onClick: () => void finish("cancel"),
|
|
11400
|
-
children: "取消"
|
|
11326
|
+
"aria-label": "关闭",
|
|
11327
|
+
title: "关闭",
|
|
11328
|
+
disabled: props.busy,
|
|
11329
|
+
onClick: props.onClose,
|
|
11330
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { name: "close" })
|
|
11331
|
+
})] }),
|
|
11332
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11333
|
+
className: `candidate-edit-panel-scroll${editable ? " is-editing" : ""}`,
|
|
11334
|
+
children: editable && props.editorState ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DraftInlineEditor, {
|
|
11335
|
+
state: props.editorState,
|
|
11336
|
+
onChange: props.onEditorChange,
|
|
11337
|
+
entry: props.entry,
|
|
11338
|
+
...props.referenceData ? { referenceData: props.referenceData } : {},
|
|
11339
|
+
busy: props.busy,
|
|
11340
|
+
error: props.error,
|
|
11341
|
+
summary,
|
|
11342
|
+
onCancel: props.onClose,
|
|
11343
|
+
onSave: props.onSave
|
|
11344
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
11345
|
+
summary,
|
|
11346
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
11347
|
+
className: "candidate-panel-details",
|
|
11348
|
+
children: [
|
|
11349
|
+
["类型", facts.direction === "income" ? "收入" : facts.direction === "transfer" ? "转账" : facts.direction === "expense" ? "支出" : "待补齐"],
|
|
11350
|
+
["金额", facts.amount],
|
|
11351
|
+
["时间", facts.occurredAt],
|
|
11352
|
+
["账户", facts.account],
|
|
11353
|
+
["分类", facts.category],
|
|
11354
|
+
["商家", facts.store || "未关联"],
|
|
11355
|
+
["备注", facts.detail || "—"]
|
|
11356
|
+
].map(([label, value]) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
11357
|
+
className: label === "备注" ? "wide" : "",
|
|
11358
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: label }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: value })]
|
|
11359
|
+
}, label))
|
|
11401
11360
|
}),
|
|
11402
|
-
|
|
11403
|
-
|
|
11404
|
-
|
|
11405
|
-
|
|
11406
|
-
|
|
11361
|
+
operation === "delete" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
11362
|
+
className: "candidate-panel-actions",
|
|
11363
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
11364
|
+
disabled: props.busy,
|
|
11365
|
+
onClick: props.onRemove,
|
|
11366
|
+
children: "从草稿删除"
|
|
11367
|
+
})
|
|
11407
11368
|
}),
|
|
11408
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
|
|
11412
|
-
children: "确认授权"
|
|
11369
|
+
props.error && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
11370
|
+
className: "candidate-panel-error",
|
|
11371
|
+
role: "alert",
|
|
11372
|
+
children: props.error
|
|
11413
11373
|
})
|
|
11414
11374
|
] })
|
|
11415
|
-
|
|
11416
|
-
|
|
11375
|
+
})
|
|
11376
|
+
]
|
|
11417
11377
|
});
|
|
11418
11378
|
}
|
|
11419
|
-
|
|
11379
|
+
function groupEntriesByTab(entries) {
|
|
11380
|
+
const groups = {
|
|
11381
|
+
ready: [],
|
|
11382
|
+
pending: [],
|
|
11383
|
+
matched: []
|
|
11384
|
+
};
|
|
11385
|
+
for (const entry of entries) groups[draftEntryNeedsCompletion(entry) ? "pending" : entry.draft?.operation === "matched" ? "matched" : "ready"].push(entry);
|
|
11386
|
+
return groups;
|
|
11387
|
+
}
|
|
11388
|
+
function groupEntriesByAccount(entries, referenceData) {
|
|
11389
|
+
const groups = /* @__PURE__ */ new Map();
|
|
11390
|
+
for (const entry of entries) {
|
|
11391
|
+
const fields = {
|
|
11392
|
+
...entry.original,
|
|
11393
|
+
...entry.draft?.fields
|
|
11394
|
+
};
|
|
11395
|
+
const id = typeof fields.accountId === "string" ? fields.accountId : "__unassigned__";
|
|
11396
|
+
const name = referenceData?.accounts.find((account) => account.id === id)?.name ?? draftEntryFacts(entry, referenceData).accountKindName ?? "未指定账户";
|
|
11397
|
+
const group = groups.get(id) ?? {
|
|
11398
|
+
id,
|
|
11399
|
+
name,
|
|
11400
|
+
items: []
|
|
11401
|
+
};
|
|
11402
|
+
group.items.push(entry);
|
|
11403
|
+
groups.set(id, group);
|
|
11404
|
+
}
|
|
11405
|
+
return [...groups.values()];
|
|
11406
|
+
}
|
|
11407
|
+
var TAB_LABELS;
|
|
11408
|
+
var init_draft_card = __esmMin((() => {
|
|
11420
11409
|
init_src$2();
|
|
11421
|
-
|
|
11410
|
+
init_web_contracts();
|
|
11411
|
+
init_src();
|
|
11412
|
+
init_draft_entry_editor();
|
|
11413
|
+
init_book_grant();
|
|
11414
|
+
init_draft_view();
|
|
11415
|
+
TAB_LABELS = {
|
|
11416
|
+
ready: "待处理",
|
|
11417
|
+
pending: "待补齐",
|
|
11418
|
+
matched: "账本已有"
|
|
11419
|
+
};
|
|
11422
11420
|
}));
|
|
11423
11421
|
//#endregion
|
|
11424
11422
|
//#region ../../packages/finance-ui/src/ledger-route-page.tsx
|
|
@@ -11600,6 +11598,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11600
11598
|
description: "备份与恢复。",
|
|
11601
11599
|
loadPage: loadLedgerPage
|
|
11602
11600
|
},
|
|
11601
|
+
{
|
|
11602
|
+
id: FinanceRouteIds.authorization,
|
|
11603
|
+
path: "/ledger/authorization",
|
|
11604
|
+
description: "账本授权。",
|
|
11605
|
+
loadPage: loadLedgerPage
|
|
11606
|
+
},
|
|
11603
11607
|
{
|
|
11604
11608
|
id: FinanceRouteIds.setup,
|
|
11605
11609
|
path: "/ledger/setup",
|
|
@@ -15261,6 +15265,53 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
15261
15265
|
init_local_ledger_helpers();
|
|
15262
15266
|
}));
|
|
15263
15267
|
//#endregion
|
|
15268
|
+
//#region ../../packages/finance-ui/src/ledger-sync-tabs.css
|
|
15269
|
+
var init_ledger_sync_tabs$1 = __esmMin((() => {}));
|
|
15270
|
+
//#endregion
|
|
15271
|
+
//#region ../../packages/finance-ui/src/ledger-sync-tabs.tsx
|
|
15272
|
+
function LedgerSyncTabs({ view, bookId, onNavigate, busy = false }) {
|
|
15273
|
+
const element = (0, react.useRef)(null);
|
|
15274
|
+
(0, react.useLayoutEffect)(() => {
|
|
15275
|
+
const nav = element.current;
|
|
15276
|
+
const reveal = () => {
|
|
15277
|
+
const active = nav.querySelector("[aria-current=\"page\"]");
|
|
15278
|
+
if (!active) return;
|
|
15279
|
+
const item = active.getBoundingClientRect(), bounds = nav.getBoundingClientRect();
|
|
15280
|
+
if (item.left < bounds.left) nav.scrollLeft -= bounds.left - item.left;
|
|
15281
|
+
else if (item.right > bounds.right) nav.scrollLeft += item.right - bounds.right;
|
|
15282
|
+
};
|
|
15283
|
+
reveal();
|
|
15284
|
+
const observer = new ResizeObserver(reveal);
|
|
15285
|
+
observer.observe(nav);
|
|
15286
|
+
return () => observer.disconnect();
|
|
15287
|
+
}, [view]);
|
|
15288
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("nav", {
|
|
15289
|
+
ref: element,
|
|
15290
|
+
className: "ledger-sync-tabs",
|
|
15291
|
+
"aria-label": "数据与同步分区",
|
|
15292
|
+
children: [
|
|
15293
|
+
["status", "同步状态"],
|
|
15294
|
+
["changes", "流水变更"],
|
|
15295
|
+
["valuation", "汇率与计算"],
|
|
15296
|
+
["authorization", "账本授权"],
|
|
15297
|
+
["backup", "备份与恢复"]
|
|
15298
|
+
].map(([value, label]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
15299
|
+
type: "button",
|
|
15300
|
+
"aria-current": view === value ? "page" : void 0,
|
|
15301
|
+
disabled: busy || !bookId && (value === "changes" || value === "valuation"),
|
|
15302
|
+
onClick: () => onNavigate({
|
|
15303
|
+
...bookId ? { bookId } : {},
|
|
15304
|
+
section: "sync",
|
|
15305
|
+
...value === "status" ? {} : { query: { view: value } }
|
|
15306
|
+
}),
|
|
15307
|
+
children: label
|
|
15308
|
+
}, value))
|
|
15309
|
+
});
|
|
15310
|
+
}
|
|
15311
|
+
var init_ledger_sync_tabs = __esmMin((() => {
|
|
15312
|
+
init_ledger_sync_tabs$1();
|
|
15313
|
+
}));
|
|
15314
|
+
//#endregion
|
|
15264
15315
|
//#region ../../packages/finance-ui/src/local-ledger-changes.tsx
|
|
15265
15316
|
function LedgerChanges({ bookId, refreshKey, onNavigate }) {
|
|
15266
15317
|
const fetchImpl = useLedgerFetch();
|
|
@@ -18028,36 +18079,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18028
18079
|
const relevant = syncRecordsWithLiveOperation(syncRecords, book.id, liveSyncRecord);
|
|
18029
18080
|
const latest = [...relevant].filter((item) => syncStatusKind(item.status) === "complete").sort((left, right) => String(right.completedAt).localeCompare(String(left.completedAt)))[0];
|
|
18030
18081
|
const view = route.query?.view === "changes" || route.query?.view === "valuation" ? route.query.view : "status";
|
|
18031
|
-
const tabs = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
18032
|
-
|
|
18033
|
-
|
|
18034
|
-
|
|
18035
|
-
{
|
|
18036
|
-
value: "status",
|
|
18037
|
-
label: "同步状态"
|
|
18038
|
-
},
|
|
18039
|
-
{
|
|
18040
|
-
value: "changes",
|
|
18041
|
-
label: "流水变更"
|
|
18042
|
-
},
|
|
18043
|
-
{
|
|
18044
|
-
value: "valuation",
|
|
18045
|
-
label: "汇率与计算"
|
|
18046
|
-
},
|
|
18047
|
-
{
|
|
18048
|
-
value: "backup",
|
|
18049
|
-
label: "备份与恢复"
|
|
18050
|
-
}
|
|
18051
|
-
].map((tab) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
18052
|
-
type: "button",
|
|
18053
|
-
"aria-current": view === tab.value ? "page" : void 0,
|
|
18054
|
-
onClick: () => onNavigate({
|
|
18055
|
-
bookId: book.id,
|
|
18056
|
-
section: "sync",
|
|
18057
|
-
...tab.value === "status" ? {} : { query: { view: tab.value } }
|
|
18058
|
-
}),
|
|
18059
|
-
children: tab.label
|
|
18060
|
-
}, tab.value))
|
|
18082
|
+
const tabs = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerSyncTabs, {
|
|
18083
|
+
view,
|
|
18084
|
+
bookId: book.id,
|
|
18085
|
+
onNavigate
|
|
18061
18086
|
});
|
|
18062
18087
|
if (view === "changes") return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
18063
18088
|
className: "ledger-page ledger-changes-page",
|
|
@@ -18872,6 +18897,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
18872
18897
|
init_finance_client();
|
|
18873
18898
|
init_local_ledger_helpers();
|
|
18874
18899
|
init_local_ledger_visuals();
|
|
18900
|
+
init_ledger_sync_tabs();
|
|
18875
18901
|
init_local_ledger_changes();
|
|
18876
18902
|
init_account_period();
|
|
18877
18903
|
PAGE_SIZE = 15;
|
|
@@ -20328,25 +20354,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
20328
20354
|
className: "page-head",
|
|
20329
20355
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", { children: "数据与同步" })
|
|
20330
20356
|
}),
|
|
20331
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
20332
|
-
|
|
20333
|
-
|
|
20334
|
-
|
|
20335
|
-
|
|
20336
|
-
["changes", "流水变更"],
|
|
20337
|
-
["valuation", "汇率与计算"],
|
|
20338
|
-
["backup", "备份与恢复"]
|
|
20339
|
-
].map(([view, label]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
20340
|
-
type: "button",
|
|
20341
|
-
"aria-current": view === "backup" ? "page" : void 0,
|
|
20342
|
-
disabled: view !== "backup" && view !== "status" && !bookId || !!busy,
|
|
20343
|
-
onClick: () => onNavigate({
|
|
20344
|
-
...bookId ? { bookId } : {},
|
|
20345
|
-
section: "sync",
|
|
20346
|
-
...view === "status" ? {} : { query: { view } }
|
|
20347
|
-
}),
|
|
20348
|
-
children: label
|
|
20349
|
-
}, view))
|
|
20357
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerSyncTabs, {
|
|
20358
|
+
view: "backup",
|
|
20359
|
+
bookId,
|
|
20360
|
+
onNavigate,
|
|
20361
|
+
busy: Boolean(busy)
|
|
20350
20362
|
}),
|
|
20351
20363
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
20352
20364
|
className: "backup-action-row",
|
|
@@ -20510,6 +20522,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
20510
20522
|
}
|
|
20511
20523
|
var BASE, post;
|
|
20512
20524
|
var init_backup_recovery = __esmMin((() => {
|
|
20525
|
+
init_ledger_sync_tabs();
|
|
20513
20526
|
init_ledger_transport();
|
|
20514
20527
|
init_src$2();
|
|
20515
20528
|
init_backup_recovery$1();
|
|
@@ -22352,6 +22365,174 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22352
22365
|
};
|
|
22353
22366
|
}));
|
|
22354
22367
|
//#endregion
|
|
22368
|
+
//#region ../../packages/finance-ui/src/book-authorization.css
|
|
22369
|
+
var init_book_authorization$1 = __esmMin((() => {}));
|
|
22370
|
+
//#endregion
|
|
22371
|
+
//#region ../../packages/finance-ui/src/book-authorization.tsx
|
|
22372
|
+
/** Profile-wide opt-in. It does not mint grants just because a chat is opened. */
|
|
22373
|
+
function BookAuthorizationPage({ client, books, bookId, onNavigate }) {
|
|
22374
|
+
const [current, setCurrent] = (0, react.useState)(null);
|
|
22375
|
+
const [selected, setSelected] = (0, react.useState)("");
|
|
22376
|
+
const [remember, setRemember] = (0, react.useState)(false);
|
|
22377
|
+
const [loading, setLoading] = (0, react.useState)(true);
|
|
22378
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
22379
|
+
const [error, setError] = (0, react.useState)("");
|
|
22380
|
+
const [notice, setNotice] = (0, react.useState)("");
|
|
22381
|
+
const alive = (0, react.useRef)(true), locked = (0, react.useRef)(false);
|
|
22382
|
+
const [reload, setReload] = (0, react.useState)(0);
|
|
22383
|
+
(0, react.useEffect)(() => {
|
|
22384
|
+
let active = true;
|
|
22385
|
+
alive.current = true;
|
|
22386
|
+
setLoading(true);
|
|
22387
|
+
setError("");
|
|
22388
|
+
client.getDefaultBook().then((value) => {
|
|
22389
|
+
if (!active) return;
|
|
22390
|
+
setCurrent(value);
|
|
22391
|
+
setRemember(Boolean(value));
|
|
22392
|
+
setSelected(books.find((book) => book.id === value)?.id ?? books.find((book) => book.id === bookId)?.id ?? books[0]?.id ?? "");
|
|
22393
|
+
}).catch(() => {
|
|
22394
|
+
if (active) setError("无法读取账本授权,请重试。");
|
|
22395
|
+
}).finally(() => {
|
|
22396
|
+
if (active) setLoading(false);
|
|
22397
|
+
});
|
|
22398
|
+
return () => {
|
|
22399
|
+
active = false;
|
|
22400
|
+
alive.current = false;
|
|
22401
|
+
};
|
|
22402
|
+
}, [
|
|
22403
|
+
client,
|
|
22404
|
+
books,
|
|
22405
|
+
bookId,
|
|
22406
|
+
reload
|
|
22407
|
+
]);
|
|
22408
|
+
const save = async (value) => {
|
|
22409
|
+
if (locked.current || !client.setDefaultBook) return;
|
|
22410
|
+
locked.current = true;
|
|
22411
|
+
setBusy(true);
|
|
22412
|
+
setError("");
|
|
22413
|
+
setNotice("");
|
|
22414
|
+
try {
|
|
22415
|
+
await client.setDefaultBook(value);
|
|
22416
|
+
if (!alive.current) return;
|
|
22417
|
+
setCurrent(value);
|
|
22418
|
+
setRemember(Boolean(value));
|
|
22419
|
+
setNotice(value ? "授权已保存,后续会话使用财务功能时将自动使用此账本。" : "已停止为新会话自动授权;已有会话的授权与草稿不受影响。");
|
|
22420
|
+
window.dispatchEvent(new Event("sui-ledger:finance-updated"));
|
|
22421
|
+
} catch {
|
|
22422
|
+
if (alive.current) setError("保存账本授权失败,请重新读取后重试。");
|
|
22423
|
+
} finally {
|
|
22424
|
+
locked.current = false;
|
|
22425
|
+
if (alive.current) setBusy(false);
|
|
22426
|
+
}
|
|
22427
|
+
};
|
|
22428
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
22429
|
+
className: "ledger-page book-authorization-page",
|
|
22430
|
+
children: [
|
|
22431
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
22432
|
+
className: "page-head",
|
|
22433
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", { children: "数据与同步" })
|
|
22434
|
+
}),
|
|
22435
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerSyncTabs, {
|
|
22436
|
+
view: "authorization",
|
|
22437
|
+
bookId,
|
|
22438
|
+
onNavigate,
|
|
22439
|
+
busy
|
|
22440
|
+
}),
|
|
22441
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
22442
|
+
className: "book-authorization-settings",
|
|
22443
|
+
"aria-labelledby": "book-authorization-title",
|
|
22444
|
+
children: [
|
|
22445
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
22446
|
+
id: "book-authorization-title",
|
|
22447
|
+
children: "账本授权"
|
|
22448
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
22449
|
+
className: "book-authorization-status",
|
|
22450
|
+
children: loading ? "正在读取" : current ? "已授权" : "未设置"
|
|
22451
|
+
})] }),
|
|
22452
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "选择默认账本,之后使用财务功能时无需重复授权。" }),
|
|
22453
|
+
loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
22454
|
+
role: "status",
|
|
22455
|
+
children: "正在读取账本授权…"
|
|
22456
|
+
}) : books.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "尚无可用账本,请先登录并同步。" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22457
|
+
type: "button",
|
|
22458
|
+
onClick: () => onNavigate({ section: "sync" }),
|
|
22459
|
+
children: "登录并同步账本"
|
|
22460
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
22461
|
+
onSubmit: (event) => {
|
|
22462
|
+
event.preventDefault();
|
|
22463
|
+
if (!busy && (remember ? selected : current)) save(remember ? selected : null);
|
|
22464
|
+
},
|
|
22465
|
+
children: [
|
|
22466
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
22467
|
+
className: "book-authorization-field",
|
|
22468
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "默认账本" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
22469
|
+
value: selected,
|
|
22470
|
+
disabled: busy || Boolean(error),
|
|
22471
|
+
onChange: (event) => setSelected(event.currentTarget.value),
|
|
22472
|
+
children: books.map((book) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
22473
|
+
value: book.id,
|
|
22474
|
+
children: book.name || book.id
|
|
22475
|
+
}, book.id))
|
|
22476
|
+
})]
|
|
22477
|
+
}),
|
|
22478
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
22479
|
+
className: "book-authorization-remember",
|
|
22480
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
22481
|
+
type: "checkbox",
|
|
22482
|
+
checked: remember,
|
|
22483
|
+
disabled: busy || Boolean(error),
|
|
22484
|
+
onChange: (event) => setRemember(event.currentTarget.checked)
|
|
22485
|
+
}), "后续会话使用财务功能时自动使用此账本"]
|
|
22486
|
+
}),
|
|
22487
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
22488
|
+
className: "book-authorization-note",
|
|
22489
|
+
children: "仅在使用财务功能时读取账本。实际入账仍需人工确认。"
|
|
22490
|
+
}),
|
|
22491
|
+
current && !books.some((book) => book.id === current) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
22492
|
+
role: "status",
|
|
22493
|
+
children: "原授权账本暂不可用,请重新选择可用账本。"
|
|
22494
|
+
}),
|
|
22495
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("footer", { children: [current && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22496
|
+
type: "button",
|
|
22497
|
+
disabled: busy,
|
|
22498
|
+
onClick: () => void save(null),
|
|
22499
|
+
children: "停止自动授权"
|
|
22500
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22501
|
+
type: "submit",
|
|
22502
|
+
tone: "primary",
|
|
22503
|
+
disabled: busy || (remember ? !selected : !current) || Boolean(error) || !client.setDefaultBook,
|
|
22504
|
+
children: current ? "保存更改" : "确认授权"
|
|
22505
|
+
})] })
|
|
22506
|
+
]
|
|
22507
|
+
}),
|
|
22508
|
+
busy && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
22509
|
+
role: "status",
|
|
22510
|
+
children: "正在保存…"
|
|
22511
|
+
}),
|
|
22512
|
+
notice && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
22513
|
+
role: "status",
|
|
22514
|
+
children: notice
|
|
22515
|
+
}),
|
|
22516
|
+
error && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
22517
|
+
role: "alert",
|
|
22518
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: error }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22519
|
+
type: "button",
|
|
22520
|
+
disabled: busy,
|
|
22521
|
+
onClick: () => setReload((value) => value + 1),
|
|
22522
|
+
children: "重新读取"
|
|
22523
|
+
})]
|
|
22524
|
+
})
|
|
22525
|
+
]
|
|
22526
|
+
})
|
|
22527
|
+
]
|
|
22528
|
+
});
|
|
22529
|
+
}
|
|
22530
|
+
var init_book_authorization = __esmMin((() => {
|
|
22531
|
+
init_src$2();
|
|
22532
|
+
init_ledger_sync_tabs();
|
|
22533
|
+
init_book_authorization$1();
|
|
22534
|
+
}));
|
|
22535
|
+
//#endregion
|
|
22355
22536
|
//#region ../../packages/finance-ui/src/first-run-setup.css
|
|
22356
22537
|
var init_first_run_setup$1 = __esmMin((() => {}));
|
|
22357
22538
|
//#endregion
|
|
@@ -22423,34 +22604,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22423
22604
|
className: "page-head",
|
|
22424
22605
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", { children: showTabs ? "数据与同步" : "连接随手记账本" })
|
|
22425
22606
|
}),
|
|
22426
|
-
showTabs && /* @__PURE__ */ (0, react_jsx_runtime.
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22431
|
-
type: "button",
|
|
22432
|
-
"aria-current": "page",
|
|
22433
|
-
children: "同步状态"
|
|
22434
|
-
}),
|
|
22435
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22436
|
-
type: "button",
|
|
22437
|
-
disabled: true,
|
|
22438
|
-
children: "流水变更"
|
|
22439
|
-
}),
|
|
22440
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22441
|
-
type: "button",
|
|
22442
|
-
disabled: true,
|
|
22443
|
-
children: "汇率与计算"
|
|
22444
|
-
}),
|
|
22445
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22446
|
-
type: "button",
|
|
22447
|
-
onClick: () => onNavigate({
|
|
22448
|
-
section: "sync",
|
|
22449
|
-
query: { view: "backup" }
|
|
22450
|
-
}),
|
|
22451
|
-
children: "备份与恢复"
|
|
22452
|
-
})
|
|
22453
|
-
]
|
|
22607
|
+
showTabs && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerSyncTabs, {
|
|
22608
|
+
view: "status",
|
|
22609
|
+
onNavigate,
|
|
22610
|
+
busy
|
|
22454
22611
|
}),
|
|
22455
22612
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
22456
22613
|
className: "ledger-card first-run-card",
|
|
@@ -22558,6 +22715,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22558
22715
|
});
|
|
22559
22716
|
}
|
|
22560
22717
|
var init_first_run_setup = __esmMin((() => {
|
|
22718
|
+
init_ledger_sync_tabs();
|
|
22561
22719
|
init_src$2();
|
|
22562
22720
|
init_ledger_sync_progress();
|
|
22563
22721
|
init_session_recovery();
|
|
@@ -22622,7 +22780,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22622
22780
|
return () => controller.abort();
|
|
22623
22781
|
}, [fetchImpl]);
|
|
22624
22782
|
(0, react.useEffect)(() => {
|
|
22625
|
-
if (loading || props.route.section === "preferences" || props.route.query?.view
|
|
22783
|
+
if (loading || props.route.section === "preferences" || ["backup", "authorization"].includes(props.route.query?.view ?? "")) return;
|
|
22626
22784
|
if (books.length === 0) return;
|
|
22627
22785
|
const requestedBook = props.route.bookId;
|
|
22628
22786
|
if (requestedBook && !books.some((item) => item.id === requestedBook)) return;
|
|
@@ -22734,6 +22892,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22734
22892
|
}) : section === "preferences" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PersonalPreferencesPage, {
|
|
22735
22893
|
onDirtyChange: setPreferencesDirty,
|
|
22736
22894
|
onSavingChange: setPreferencesSaving
|
|
22895
|
+
}) : section === "sync" && props.route.query?.view === "authorization" && !loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BookAuthorizationPage, {
|
|
22896
|
+
client: props.financeClient,
|
|
22897
|
+
books,
|
|
22898
|
+
bookId: bookId || void 0,
|
|
22899
|
+
onNavigate: props.onNavigate
|
|
22737
22900
|
}) : loading ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerState, {
|
|
22738
22901
|
icon: "refresh",
|
|
22739
22902
|
title: "正在读取账本",
|
|
@@ -22858,6 +23021,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22858
23021
|
init_local_ledger_visuals();
|
|
22859
23022
|
init_backup_recovery();
|
|
22860
23023
|
init_service_records_page();
|
|
23024
|
+
init_book_authorization();
|
|
22861
23025
|
init_first_run_setup();
|
|
22862
23026
|
LEDGER_BOOK_KEY = "sui-ledger.local-ledger.book";
|
|
22863
23027
|
LEDGER_SECTION_KEY = "sui-ledger.local-ledger.section";
|
|
@@ -22945,6 +23109,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22945
23109
|
description: "备份与恢复。",
|
|
22946
23110
|
loadPage: stubLoadPage
|
|
22947
23111
|
},
|
|
23112
|
+
{
|
|
23113
|
+
id: FinanceRouteIds.authorization,
|
|
23114
|
+
path: "/ledger/authorization",
|
|
23115
|
+
ownerModuleId: OWNER_MODULE_ID,
|
|
23116
|
+
description: "账本授权。",
|
|
23117
|
+
loadPage: stubLoadPage
|
|
23118
|
+
},
|
|
22948
23119
|
{
|
|
22949
23120
|
id: FinanceRouteIds.setup,
|
|
22950
23121
|
path: "/ledger/setup",
|
|
@@ -23451,11 +23622,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23451
23622
|
init_src$2();
|
|
23452
23623
|
/** DSH's session-scoped input dock stays mounted even while the icon is absent. */
|
|
23453
23624
|
function DraftComposerDock(props) {
|
|
23454
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.
|
|
23455
|
-
subjectId: `dsh-session-${props.sessionId}`,
|
|
23456
|
-
client: props.financeClient,
|
|
23457
|
-
onOpenLedger: props.onOpenLedger
|
|
23458
|
-
}, `grant-${props.sessionId}`), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionDraftDock, { ...props }, props.sessionId)] });
|
|
23625
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(SessionDraftDock, { ...props }, props.sessionId);
|
|
23459
23626
|
}
|
|
23460
23627
|
function SessionDraftDock(props) {
|
|
23461
23628
|
const timeline = props.useChat((snapshot) => snapshot.timeline);
|
|
@@ -23790,6 +23957,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23790
23957
|
function DraftAddToolview({ block }) {
|
|
23791
23958
|
const result = asRecord(parseResult(block));
|
|
23792
23959
|
const counts = asRecord(result?.counts);
|
|
23960
|
+
const state = blockState(block);
|
|
23793
23961
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(Frame, {
|
|
23794
23962
|
title: "流水草稿 · 追加",
|
|
23795
23963
|
block,
|
|
@@ -23815,7 +23983,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23815
23983
|
}) : null,
|
|
23816
23984
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Field, {
|
|
23817
23985
|
k: "提示",
|
|
23818
|
-
v: blockState(block) === "ok" && result?.draftId ? "已加到会话草稿便签,可从输入框上方的草稿图标打开;未入账。" : "尚未追加成功,请查看调用结果。"
|
|
23986
|
+
v: blockState(block) === "ok" && result?.draftId ? "已加到会话草稿便签,可从输入框上方的草稿图标打开;未入账。" : state === "running" || state === "preparing" ? "正在处理,请稍候。" : "尚未追加成功,请查看调用结果。"
|
|
23819
23987
|
})
|
|
23820
23988
|
]
|
|
23821
23989
|
});
|
|
@@ -23972,10 +24140,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
23972
24140
|
id: "sui-ledger-draft",
|
|
23973
24141
|
order: 15,
|
|
23974
24142
|
locale: NS,
|
|
23975
|
-
inject: () => ({
|
|
23976
|
-
financeClient,
|
|
23977
|
-
onOpenLedger: () => ctx.layout.selectPanel(PANEL_ID)
|
|
23978
|
-
})
|
|
24143
|
+
inject: () => ({ financeClient })
|
|
23979
24144
|
}, DraftComposerDock));
|
|
23980
24145
|
for (const { key, component } of TOOLVIEWS) ctx.slots.inject("tool.call.toolview", () => ctx.slots.register({
|
|
23981
24146
|
name: "tool.call.toolview",
|