@goodpeanuts/dsh-sui 0.1.0 → 0.1.1
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 +4 -2
- package/bundles/sui-ledger/dist/client.js +252 -7
- package/bundles/sui-ledger/dist/index.mjs +1 -1
- package/bundles/sui-ledger/dist/packages/finance-module/src/routes.mjs +4 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/sdk-adapter.mjs +1 -0
- package/bundles/sui-ledger/dist/packages/finance-module/src/service.mjs +4 -0
- package/bundles/sui-ledger/dist/style.css +32 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,7 +18,9 @@ dsh plugin --profile web add @goodpeanuts/dsh-sui
|
|
|
18
18
|
|
|
19
19
|
### 首次登录与同步
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
首次打开本地账本时,可直接填写随手记账号和密码并登录。单账本会自动同步最近两个月;多个账本可选择其中一个同步,更早的数据可在“数据与同步”选择全量同步。凭据保存在系统钥匙串。
|
|
22
|
+
|
|
23
|
+
也可先停止使用同一数据目录的宿主,在终端执行:
|
|
22
24
|
|
|
23
25
|
```sh
|
|
24
26
|
npx --yes --package=@goodpeanuts/dsh-sui feidee auth set '你的随手记账号'
|
|
@@ -27,7 +29,7 @@ npx --yes --package=@goodpeanuts/dsh-sui feidee books --pretty
|
|
|
27
29
|
npx --yes --package=@goodpeanuts/dsh-sui feidee sync recent --book '上一步返回的账本ID'
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
按隐藏提示输入密码;同步完成后启动宿主。插件和命令默认共用 `$DSH_HOME/sui-ledger`(默认 `~/.dsh/sui-ledger`);若修改了插件数据目录,运行命令时请将环境变量 `SUI_LEDGER_DATA_DIR` 设为相同目录。
|
|
31
33
|
|
|
32
34
|
打开宿主后,从左侧 `sui-ledger` 进入账本。安装态默认禁止远端交易写入,本地草稿编辑和读取同步可用;实际策略通过 `/api/sui-ledger/finance/write-policy` 核对。模型服务在 DSH 设置中配置。
|
|
33
35
|
|
|
@@ -1128,6 +1128,7 @@ window.__ModuleLoader__.load({
|
|
|
1128
1128
|
section: "sync",
|
|
1129
1129
|
query: { view: "backup" }
|
|
1130
1130
|
};
|
|
1131
|
+
if (match.routeId === FinanceRouteIds.setup) return { section: "sync" };
|
|
1131
1132
|
if (match.routeId === FinanceRouteIds.preferences) return { section: "preferences" };
|
|
1132
1133
|
const bookId = match.params.bookId;
|
|
1133
1134
|
if (!bookId || match.routeId === FinanceRouteIds.index) return {
|
|
@@ -1229,7 +1230,8 @@ window.__ModuleLoader__.load({
|
|
|
1229
1230
|
};
|
|
1230
1231
|
}
|
|
1231
1232
|
function ledgerRouteTarget(route) {
|
|
1232
|
-
if (route.section === "sync" &&
|
|
1233
|
+
if (route.section === "sync" && route.query?.view === "backup") return { routeId: FinanceRouteIds.maintenance };
|
|
1234
|
+
if (route.section === "sync" && !route.bookId) return { routeId: FinanceRouteIds.setup };
|
|
1233
1235
|
if (route.section === "preferences") return { routeId: FinanceRouteIds.preferences };
|
|
1234
1236
|
if (!route.bookId) return { routeId: FinanceRouteIds.index };
|
|
1235
1237
|
const params = { bookId: route.bookId };
|
|
@@ -1408,6 +1410,7 @@ window.__ModuleLoader__.load({
|
|
|
1408
1410
|
index: "finance.ledger.index",
|
|
1409
1411
|
preferences: "finance.ledger.preferences",
|
|
1410
1412
|
maintenance: "finance.ledger.maintenance",
|
|
1413
|
+
setup: "finance.ledger.setup",
|
|
1411
1414
|
overview: "finance.ledger.overview",
|
|
1412
1415
|
transactions: "finance.ledger.transactions",
|
|
1413
1416
|
transactionDetail: "finance.ledger.transaction-detail",
|
|
@@ -11238,6 +11241,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11238
11241
|
async loginSession(credential) {
|
|
11239
11242
|
return (await request("/finance/session/login", jsonRequest("POST", credential ?? {}))).session;
|
|
11240
11243
|
},
|
|
11244
|
+
async listRemoteBooks() {
|
|
11245
|
+
return (await request("/finance/session/books", jsonRequest("POST", {}))).books;
|
|
11246
|
+
},
|
|
11241
11247
|
async verifyCommit(commitId) {
|
|
11242
11248
|
return (await request(`/finance/commits/${encodeURIComponent(commitId)}/verify`, jsonRequest("POST", {}))).commit;
|
|
11243
11249
|
},
|
|
@@ -11348,6 +11354,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
11348
11354
|
description: "备份与恢复。",
|
|
11349
11355
|
loadPage: loadLedgerPage
|
|
11350
11356
|
},
|
|
11357
|
+
{
|
|
11358
|
+
id: FinanceRouteIds.setup,
|
|
11359
|
+
path: "/ledger/setup",
|
|
11360
|
+
description: "首次登录与同步。",
|
|
11361
|
+
loadPage: loadLedgerPage
|
|
11362
|
+
},
|
|
11351
11363
|
{
|
|
11352
11364
|
id: FinanceRouteIds.index,
|
|
11353
11365
|
path: "/ledger",
|
|
@@ -20080,7 +20092,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
20080
20092
|
].map(([view, label]) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
20081
20093
|
type: "button",
|
|
20082
20094
|
"aria-current": view === "backup" ? "page" : void 0,
|
|
20083
|
-
disabled: view !== "backup" && !bookId || !!busy,
|
|
20095
|
+
disabled: view !== "backup" && view !== "status" && !bookId || !!busy,
|
|
20084
20096
|
onClick: () => onNavigate({
|
|
20085
20097
|
...bookId ? { bookId } : {},
|
|
20086
20098
|
section: "sync",
|
|
@@ -22093,6 +22105,218 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22093
22105
|
};
|
|
22094
22106
|
}));
|
|
22095
22107
|
//#endregion
|
|
22108
|
+
//#region ../../packages/finance-ui/src/first-run-setup.css
|
|
22109
|
+
var init_first_run_setup$1 = __esmMin((() => {}));
|
|
22110
|
+
//#endregion
|
|
22111
|
+
//#region ../../packages/finance-ui/src/first-run-setup.tsx
|
|
22112
|
+
/** The local ledger does not exist yet, so login and sync must not require a book route. */
|
|
22113
|
+
function FirstRunSetup({ client, coordinator, onNavigate, showTabs }) {
|
|
22114
|
+
const session = useFinanceSession(client);
|
|
22115
|
+
const [username, setUsername] = (0, react.useState)("");
|
|
22116
|
+
const [password, setPassword] = (0, react.useState)("");
|
|
22117
|
+
const [books, setBooks] = (0, react.useState)();
|
|
22118
|
+
const [selected, setSelected] = (0, react.useState)("");
|
|
22119
|
+
const [working, setWorking] = (0, react.useState)(false);
|
|
22120
|
+
const [error, setError] = (0, react.useState)("");
|
|
22121
|
+
const alive = (0, react.useRef)(true);
|
|
22122
|
+
(0, react.useEffect)(() => {
|
|
22123
|
+
alive.current = true;
|
|
22124
|
+
return () => {
|
|
22125
|
+
alive.current = false;
|
|
22126
|
+
};
|
|
22127
|
+
}, []);
|
|
22128
|
+
const busy = working || session.sending || Boolean(coordinator.syncingMode);
|
|
22129
|
+
const discover = async () => {
|
|
22130
|
+
if (!client.listRemoteBooks) throw new Error("当前插件无法读取远端账本,请更新插件后重试。");
|
|
22131
|
+
const found = await client.listRemoteBooks();
|
|
22132
|
+
if (!alive.current) return;
|
|
22133
|
+
setBooks(found);
|
|
22134
|
+
setSelected(found[0]?.id ?? "");
|
|
22135
|
+
if (found.length === 1) await coordinator.startSync(found[0].id, "recent");
|
|
22136
|
+
};
|
|
22137
|
+
const login = async (credential) => {
|
|
22138
|
+
if (busy) return;
|
|
22139
|
+
setWorking(true);
|
|
22140
|
+
setError("");
|
|
22141
|
+
setBooks(void 0);
|
|
22142
|
+
try {
|
|
22143
|
+
const state = await session.login(credential);
|
|
22144
|
+
if (!alive.current) return;
|
|
22145
|
+
if (!state || state.status !== "authenticated" || state.loginFailure || state.saveFailed) {
|
|
22146
|
+
const failure = state?.loginFailure ?? state?.status;
|
|
22147
|
+
setError(state?.saveFailed ? "登录成功,但凭据未能保存到系统凭据库,请检查后重试。" : failure === "invalid_credentials" ? "随手记账号或密码不正确,请重试。" : failure === "missing_credentials" ? "尚未保存登录凭据,请填写账号和密码。" : failure === "credential_unavailable" ? "无法访问系统凭据库,请检查系统权限。" : failure === "network_unavailable" ? "无法连接随手记,请检查网络后重试。" : "登录未完成,请检查账号、密码和网络后重试。");
|
|
22148
|
+
return;
|
|
22149
|
+
}
|
|
22150
|
+
await discover();
|
|
22151
|
+
} catch {
|
|
22152
|
+
if (alive.current) setError("无法读取远端账本,请检查网络和登录状态后重试。");
|
|
22153
|
+
} finally {
|
|
22154
|
+
if (alive.current) setWorking(false);
|
|
22155
|
+
}
|
|
22156
|
+
};
|
|
22157
|
+
const submit = (event) => {
|
|
22158
|
+
event.preventDefault();
|
|
22159
|
+
if (!username.trim() || !password || busy) return;
|
|
22160
|
+
const credential = {
|
|
22161
|
+
username: username.trim(),
|
|
22162
|
+
password
|
|
22163
|
+
};
|
|
22164
|
+
setPassword("");
|
|
22165
|
+
login(credential);
|
|
22166
|
+
};
|
|
22167
|
+
const syncSelected = async () => {
|
|
22168
|
+
if (!selected || busy) return;
|
|
22169
|
+
setError("");
|
|
22170
|
+
await coordinator.startSync(selected, "recent");
|
|
22171
|
+
};
|
|
22172
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
22173
|
+
className: "ledger-page first-run-setup",
|
|
22174
|
+
children: [
|
|
22175
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("header", {
|
|
22176
|
+
className: "page-head",
|
|
22177
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", { children: showTabs ? "数据与同步" : "连接随手记账本" })
|
|
22178
|
+
}),
|
|
22179
|
+
showTabs && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
|
|
22180
|
+
className: "ledger-sync-tabs",
|
|
22181
|
+
"aria-label": "数据与同步分区",
|
|
22182
|
+
children: [
|
|
22183
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22184
|
+
type: "button",
|
|
22185
|
+
"aria-current": "page",
|
|
22186
|
+
children: "同步状态"
|
|
22187
|
+
}),
|
|
22188
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22189
|
+
type: "button",
|
|
22190
|
+
disabled: true,
|
|
22191
|
+
children: "流水变更"
|
|
22192
|
+
}),
|
|
22193
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22194
|
+
type: "button",
|
|
22195
|
+
disabled: true,
|
|
22196
|
+
children: "汇率与计算"
|
|
22197
|
+
}),
|
|
22198
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
22199
|
+
type: "button",
|
|
22200
|
+
onClick: () => onNavigate({
|
|
22201
|
+
section: "sync",
|
|
22202
|
+
query: { view: "backup" }
|
|
22203
|
+
}),
|
|
22204
|
+
children: "备份与恢复"
|
|
22205
|
+
})
|
|
22206
|
+
]
|
|
22207
|
+
}),
|
|
22208
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
22209
|
+
className: "ledger-card first-run-card",
|
|
22210
|
+
"aria-label": "首次连接随手记",
|
|
22211
|
+
children: [
|
|
22212
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", { children: "登录随手记并同步账本" }),
|
|
22213
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "登录后将同步所选账本最近两个月的数据;如需更早的流水,可在同步页面选择全量同步。" }),
|
|
22214
|
+
session.state?.canSaveCredentials !== false && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("form", {
|
|
22215
|
+
onSubmit: submit,
|
|
22216
|
+
className: "first-run-form",
|
|
22217
|
+
children: [
|
|
22218
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
22219
|
+
className: "workset-field",
|
|
22220
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "随手记账号" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
22221
|
+
autoComplete: "username",
|
|
22222
|
+
value: username,
|
|
22223
|
+
disabled: busy,
|
|
22224
|
+
onChange: (event) => setUsername(event.currentTarget.value)
|
|
22225
|
+
})]
|
|
22226
|
+
}),
|
|
22227
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
22228
|
+
className: "workset-field",
|
|
22229
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "随手记密码" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
22230
|
+
type: "password",
|
|
22231
|
+
autoComplete: "current-password",
|
|
22232
|
+
value: password,
|
|
22233
|
+
disabled: busy,
|
|
22234
|
+
onChange: (event) => setPassword(event.currentTarget.value)
|
|
22235
|
+
})]
|
|
22236
|
+
}),
|
|
22237
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22238
|
+
type: "submit",
|
|
22239
|
+
tone: "primary",
|
|
22240
|
+
disabled: busy || !username.trim() || !password || !session.canLogin,
|
|
22241
|
+
children: "登录并同步"
|
|
22242
|
+
})
|
|
22243
|
+
]
|
|
22244
|
+
}),
|
|
22245
|
+
session.state?.canSaveCredentials === false && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "当前使用启动环境中的凭据,请使用已有凭据登录。" }),
|
|
22246
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
22247
|
+
className: "first-run-actions",
|
|
22248
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22249
|
+
type: "button",
|
|
22250
|
+
disabled: busy || !session.canLogin,
|
|
22251
|
+
onClick: () => void login(),
|
|
22252
|
+
children: "使用已有凭据登录"
|
|
22253
|
+
}), !showTabs && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22254
|
+
type: "button",
|
|
22255
|
+
tone: "ghost",
|
|
22256
|
+
disabled: busy,
|
|
22257
|
+
onClick: () => onNavigate({
|
|
22258
|
+
section: "sync",
|
|
22259
|
+
query: { view: "backup" }
|
|
22260
|
+
}),
|
|
22261
|
+
children: "从备份恢复"
|
|
22262
|
+
})]
|
|
22263
|
+
}),
|
|
22264
|
+
books && books.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
22265
|
+
role: "status",
|
|
22266
|
+
children: "该账号下没有可同步的账本。"
|
|
22267
|
+
}),
|
|
22268
|
+
books && books.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
22269
|
+
className: "first-run-choice",
|
|
22270
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
22271
|
+
className: "workset-field",
|
|
22272
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: "选择要同步的账本" }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
22273
|
+
value: selected,
|
|
22274
|
+
disabled: busy,
|
|
22275
|
+
onChange: (event) => setSelected(event.currentTarget.value),
|
|
22276
|
+
children: books.map((book) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
22277
|
+
value: book.id,
|
|
22278
|
+
children: book.name
|
|
22279
|
+
}, book.id))
|
|
22280
|
+
})]
|
|
22281
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22282
|
+
type: "button",
|
|
22283
|
+
tone: "primary",
|
|
22284
|
+
disabled: busy || !selected,
|
|
22285
|
+
onClick: () => void syncSelected(),
|
|
22286
|
+
children: "同步所选账本"
|
|
22287
|
+
})]
|
|
22288
|
+
}),
|
|
22289
|
+
books && books.length === 1 && coordinator.pendingSync?.phase === "terminal" && coordinator.pendingSync.terminal?.status === "failed" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
22290
|
+
type: "button",
|
|
22291
|
+
disabled: busy,
|
|
22292
|
+
onClick: () => void syncSelected(),
|
|
22293
|
+
children: "重新同步"
|
|
22294
|
+
}),
|
|
22295
|
+
(error || coordinator.syncError?.message || session.requestError) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
22296
|
+
role: "alert",
|
|
22297
|
+
className: "first-run-error",
|
|
22298
|
+
children: error || coordinator.syncError?.message || session.requestError
|
|
22299
|
+
}),
|
|
22300
|
+
working && !coordinator.syncingMode && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
22301
|
+
role: "status",
|
|
22302
|
+
children: "正在登录并读取账本…"
|
|
22303
|
+
}),
|
|
22304
|
+
coordinator.pendingSync && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerSyncProgress, {
|
|
22305
|
+
operation: coordinator.pendingSync,
|
|
22306
|
+
stale: coordinator.progressStale
|
|
22307
|
+
})
|
|
22308
|
+
]
|
|
22309
|
+
})
|
|
22310
|
+
]
|
|
22311
|
+
});
|
|
22312
|
+
}
|
|
22313
|
+
var init_first_run_setup = __esmMin((() => {
|
|
22314
|
+
init_src$2();
|
|
22315
|
+
init_ledger_sync_progress();
|
|
22316
|
+
init_session_recovery();
|
|
22317
|
+
init_first_run_setup$1();
|
|
22318
|
+
}));
|
|
22319
|
+
//#endregion
|
|
22096
22320
|
//#region ../../packages/finance-ui/src/local-ledger.tsx
|
|
22097
22321
|
function LocalLedger(props) {
|
|
22098
22322
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerTransportProvider, {
|
|
@@ -22203,7 +22427,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22203
22427
|
"aria-label": "本地账本页面",
|
|
22204
22428
|
children: [sections.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
22205
22429
|
type: "button",
|
|
22206
|
-
disabled: preferencesSaving
|
|
22430
|
+
disabled: preferencesSaving || !loading && !book && section !== "preferences" && ![
|
|
22431
|
+
"overview",
|
|
22432
|
+
"sync",
|
|
22433
|
+
"preferences"
|
|
22434
|
+
].includes(item.id),
|
|
22207
22435
|
className: section === item.id ? "active" : "",
|
|
22208
22436
|
"aria-current": section === item.id ? "page" : void 0,
|
|
22209
22437
|
onClick: () => selectSection(item.id),
|
|
@@ -22245,11 +22473,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22245
22473
|
children: [pendingSection && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UnsavedPreferencesNotice, {
|
|
22246
22474
|
onKeep: () => setPendingSection(void 0),
|
|
22247
22475
|
onDiscard: () => selectSection(pendingSection, true)
|
|
22248
|
-
}), section === "sync" && (props.route.query?.view === "backup" || !!error
|
|
22476
|
+
}), section === "sync" && (props.route.query?.view === "backup" || !!error) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BackupRecoveryPage, {
|
|
22249
22477
|
...bookId || books[0]?.id ? { bookId: bookId || books[0]?.id } : {},
|
|
22250
22478
|
onNavigate: props.onNavigate,
|
|
22251
22479
|
onRestored: () => {
|
|
22252
22480
|
discardPreferencesDraft(void 0, fetchImpl);
|
|
22481
|
+
if (props.route.query?.view !== "backup") props.onNavigate({
|
|
22482
|
+
section: "sync",
|
|
22483
|
+
query: { view: "backup" }
|
|
22484
|
+
});
|
|
22253
22485
|
reconcileLedgerIndex();
|
|
22254
22486
|
}
|
|
22255
22487
|
}) : section === "preferences" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(PersonalPreferencesPage, {
|
|
@@ -22267,10 +22499,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22267
22499
|
icon: "warning",
|
|
22268
22500
|
title: "账本页面不存在",
|
|
22269
22501
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "当前地址中的报表或资料类型无效。地址已保留,你可以从上方导航选择其他分区。" })
|
|
22270
|
-
}) : !book ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerState, {
|
|
22502
|
+
}) : !book && (bookId || books.length) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LedgerState, {
|
|
22271
22503
|
icon: "receipt",
|
|
22272
|
-
title:
|
|
22273
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children:
|
|
22504
|
+
title: "找不到这个账本",
|
|
22505
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: "当前地址指定的账本不存在或不可访问。" })
|
|
22506
|
+
}) : !book ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FirstRunSetup, {
|
|
22507
|
+
client: props.financeClient,
|
|
22508
|
+
coordinator: syncCoordinator,
|
|
22509
|
+
onNavigate: props.onNavigate,
|
|
22510
|
+
showTabs: section === "sync"
|
|
22274
22511
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(AutomaticValuationRefresh, {
|
|
22275
22512
|
bookId: book.id,
|
|
22276
22513
|
refreshKey: latestSync?.completedAt
|
|
@@ -22374,6 +22611,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22374
22611
|
init_local_ledger_visuals();
|
|
22375
22612
|
init_backup_recovery();
|
|
22376
22613
|
init_service_records_page();
|
|
22614
|
+
init_first_run_setup();
|
|
22377
22615
|
LEDGER_BOOK_KEY = "sui-ledger.local-ledger.book";
|
|
22378
22616
|
LEDGER_SECTION_KEY = "sui-ledger.local-ledger.section";
|
|
22379
22617
|
sections = [
|
|
@@ -22460,6 +22698,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
22460
22698
|
description: "备份与恢复。",
|
|
22461
22699
|
loadPage: stubLoadPage
|
|
22462
22700
|
},
|
|
22701
|
+
{
|
|
22702
|
+
id: FinanceRouteIds.setup,
|
|
22703
|
+
path: "/ledger/setup",
|
|
22704
|
+
ownerModuleId: OWNER_MODULE_ID,
|
|
22705
|
+
description: "首次登录与同步。",
|
|
22706
|
+
loadPage: stubLoadPage
|
|
22707
|
+
},
|
|
22463
22708
|
{
|
|
22464
22709
|
id: FinanceRouteIds.preferences,
|
|
22465
22710
|
path: "/ledger/preferences",
|
|
@@ -135,7 +135,7 @@ async function apply(ctx, config) {
|
|
|
135
135
|
path: "/api/sui-ledger",
|
|
136
136
|
handler: async (req, res) => {
|
|
137
137
|
const url = new URL(req.url ?? "/", "http://localhost"), path = url.pathname.slice(15);
|
|
138
|
-
if (path === "/maintenance" || path.startsWith("/maintenance/") || path === "/finance/services" || path.startsWith("/finance/services/")) {
|
|
138
|
+
if (path === "/maintenance" || path.startsWith("/maintenance/") || path === "/finance/services" || path.startsWith("/finance/services/") || path === "/finance/session" || path.startsWith("/finance/session/")) {
|
|
139
139
|
const rejection = web.connection.requestRejection(req);
|
|
140
140
|
if (rejection !== void 0) {
|
|
141
141
|
res.statusCode = rejection;
|
|
@@ -147,6 +147,10 @@ function createFinanceTrustedControlRoute(finance, interaction, preferences) {
|
|
|
147
147
|
if (Object.keys(body).length) badRequest("Session check accepts an empty object");
|
|
148
148
|
return json(200, { session: await finance.checkSession() });
|
|
149
149
|
}
|
|
150
|
+
if (request.method === "POST" && request.pathname === "/v1/finance/session/books" && finance.listRemoteBooks) {
|
|
151
|
+
if (Object.keys(await request.body()).length) badRequest("Book discovery accepts an empty object");
|
|
152
|
+
return json(200, { books: await financeCall(() => finance.listRemoteBooks()) });
|
|
153
|
+
}
|
|
150
154
|
if (request.method === "POST" && request.pathname === "/v1/finance/session/login") {
|
|
151
155
|
const body = await request.body();
|
|
152
156
|
if (Object.keys(body).some((key) => key !== "username" && key !== "password")) badRequest("Invalid login request");
|
|
@@ -16,6 +16,7 @@ function createFinanceLedgerPort(finance) {
|
|
|
16
16
|
sessionStatus: () => finance.sessionStatus(),
|
|
17
17
|
checkSession: () => finance.checkSession(),
|
|
18
18
|
loginSession: (credential) => finance.loginSession(credential),
|
|
19
|
+
liveBooks: () => finance.liveBooks(),
|
|
19
20
|
verifyTransaction: (bookId, input, attempt) => finance.verifyTransaction(bookId, input, attempt),
|
|
20
21
|
hasMutationReceipt: (bookId, input) => finance.hasMutationReceipt(bookId, input),
|
|
21
22
|
assertDeletedCreationReplaceable: (bookId, input, remoteId, replacementId) => finance.assertDeletedCreationReplaceable(bookId, input, remoteId, replacementId),
|
|
@@ -914,6 +914,10 @@ var FinanceApplicationService = class {
|
|
|
914
914
|
if (!this.options.ledger.loginSession) throw new Error("finance_session_unavailable");
|
|
915
915
|
return this.options.ledger.loginSession(credential);
|
|
916
916
|
}
|
|
917
|
+
listRemoteBooks() {
|
|
918
|
+
if (!this.options.ledger.liveBooks) throw new Error("finance_session_unavailable");
|
|
919
|
+
return this.options.ledger.liveBooks();
|
|
920
|
+
}
|
|
917
921
|
async respondCommit(commitId, decision, overrideCheckpointIds = [], background = false) {
|
|
918
922
|
const commit = this.getCommit(commitId);
|
|
919
923
|
if (commit.status !== "awaiting_confirmation") return commit;
|
|
@@ -147,6 +147,38 @@
|
|
|
147
147
|
padding: 22px;
|
|
148
148
|
}
|
|
149
149
|
}
|
|
150
|
+
.first-run-card {
|
|
151
|
+
max-width: 640px;
|
|
152
|
+
padding: 24px;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.first-run-card h2 {
|
|
156
|
+
margin: 0 0 8px;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.first-run-card > p {
|
|
160
|
+
line-height: 1.6;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.first-run-form, .first-run-choice {
|
|
164
|
+
gap: 12px;
|
|
165
|
+
margin: 20px 0 12px;
|
|
166
|
+
display: grid;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.first-run-form .button, .first-run-choice .button {
|
|
170
|
+
justify-self: start;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.first-run-actions {
|
|
174
|
+
flex-wrap: wrap;
|
|
175
|
+
gap: 8px;
|
|
176
|
+
display: flex;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
.first-run-error {
|
|
180
|
+
color: var(--danger, #b42318);
|
|
181
|
+
}
|
|
150
182
|
:root {
|
|
151
183
|
color-scheme: light;
|
|
152
184
|
color: #252823;
|