dsh-workbench-sites 1.10.0 → 1.12.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/lib/client.js CHANGED
@@ -38,6 +38,123 @@ var __copyProps = (to, from, except, desc) => {
38
38
  };
39
39
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
40
 
41
+ // packages/addons/lib/filter-checklist.cjs
42
+ var require_filter_checklist = __commonJS({
43
+ "packages/addons/lib/filter-checklist.cjs"(exports2, module2) {
44
+ "use strict";
45
+ var React2 = require("react");
46
+ var h2 = React2.createElement;
47
+ var NEAR = 24;
48
+ function nearBottom(el, threshold) {
49
+ if (!el) return false;
50
+ var gap = Number(threshold);
51
+ if (!isFinite(gap) || gap < 0) gap = NEAR;
52
+ return el.scrollTop + el.clientHeight >= el.scrollHeight - gap;
53
+ }
54
+ function FilterChecklist(props) {
55
+ var items = props.items || [];
56
+ var selected = props.selected || [];
57
+ var disabled = props.disabled === true;
58
+ var loading = props.loading === true;
59
+ var hasMore = props.hasMore === true;
60
+ var query = props.query || "";
61
+ var total = typeof props.total === "number" ? props.total : items.length;
62
+ var title = props.title || "\u5168\u90E8";
63
+ var selectedText = props.selectedText || "\u5DF2\u9009";
64
+ var clearText = props.clearText || "\u6E05\u7A7A";
65
+ var searchPlaceholder = props.searchPlaceholder || "\u641C\u7D22";
66
+ var emptyText = props.emptyText || "\u6682\u65E0\u6570\u636E";
67
+ var noMatchText = props.noMatchText || "\u6CA1\u6709\u5339\u914D\u9879";
68
+ var loadingText = props.loadingText || "\u52A0\u8F7D\u4E2D\u2026";
69
+ var noMoreText = typeof props.noMoreText === "string" ? props.noMoreText : "\u6CA1\u6709\u66F4\u591A";
70
+ var onToggle = props.onToggle || function() {
71
+ };
72
+ var onQuery = props.onQuery || function() {
73
+ };
74
+ var onLoadMore = props.onLoadMore;
75
+ var onClear = props.onClear || function() {
76
+ };
77
+ function toggle(id) {
78
+ if (disabled) return;
79
+ onToggle(id);
80
+ }
81
+ function scroll(e) {
82
+ if (disabled || loading || !hasMore || !onLoadMore) return;
83
+ if (nearBottom(e.currentTarget)) onLoadMore();
84
+ }
85
+ var head = h2(
86
+ "div",
87
+ { className: "wbck-head" },
88
+ h2("span", { className: "wbck-grow" }, title + (total ? " \xB7 " + total : "")),
89
+ selected.length ? h2("span", { className: "wbck-sel" }, selectedText + " " + selected.length) : null,
90
+ selected.length || query ? h2("button", {
91
+ type: "button",
92
+ className: "wbck-clear",
93
+ title: clearText,
94
+ disabled,
95
+ onClick: function() {
96
+ if (disabled) return;
97
+ onClear();
98
+ }
99
+ }, clearText) : null
100
+ );
101
+ var body;
102
+ if (!items.length) {
103
+ body = h2("div", { className: "wbck-note", role: "status" }, loading ? loadingText : query ? noMatchText : emptyText);
104
+ } else {
105
+ body = items.map(function(x) {
106
+ var on = selected.indexOf(String(x.id)) >= 0;
107
+ return h2(
108
+ "label",
109
+ { key: x.id, className: "wbck-opt" + (on ? " is-on" : "") },
110
+ h2("input", {
111
+ type: "checkbox",
112
+ checked: on,
113
+ disabled,
114
+ onChange: function() {
115
+ toggle(x.id);
116
+ }
117
+ }),
118
+ h2("span", { className: "wbck-nm", title: x.name }, x.name),
119
+ x.meta ? h2("span", { className: "wbck-meta" }, x.meta) : null
120
+ );
121
+ });
122
+ var more = loading ? loadingText : hasMore ? "" : noMoreText;
123
+ if (more) body = body.concat([h2("div", { key: "__more", className: "wbck-more", role: "status" }, more)]);
124
+ }
125
+ return h2(
126
+ "div",
127
+ { className: "wbck", "data-role": "checklist" },
128
+ h2(
129
+ "div",
130
+ { className: "wbck-search" },
131
+ h2("input", {
132
+ type: "search",
133
+ autoFocus: props.autoFocus !== false,
134
+ className: "wbck-input",
135
+ placeholder: searchPlaceholder,
136
+ "aria-label": searchPlaceholder,
137
+ value: query,
138
+ disabled,
139
+ onChange: function(e) {
140
+ onQuery(e.target.value);
141
+ }
142
+ })
143
+ ),
144
+ props.beforeHead || null,
145
+ head,
146
+ h2("div", {
147
+ className: "wbck-list",
148
+ onScroll: scroll,
149
+ "aria-busy": loading ? "true" : "false"
150
+ }, body)
151
+ );
152
+ }
153
+ module2.exports = FilterChecklist;
154
+ module2.exports.nearBottom = nearBottom;
155
+ }
156
+ });
157
+
41
158
  // packages/addons/sites/client/ui/tagfilter.cjs
42
159
  var require_tagfilter = __commonJS({
43
160
  "packages/addons/sites/client/ui/tagfilter.cjs"(exports2, module2) {
@@ -46,6 +163,7 @@ var require_tagfilter = __commonJS({
46
163
  var useState = React2.useState;
47
164
  var useEffect = React2.useEffect;
48
165
  var useCallback = React2.useCallback;
166
+ var FilterChecklist = require_filter_checklist();
49
167
  module2.exports = function TagFilter2(props) {
50
168
  var api = props.api;
51
169
  var text = props.text;
@@ -69,7 +187,16 @@ var require_tagfilter = __commonJS({
69
187
  var out = r.result || {};
70
188
  var records = out.records || [];
71
189
  setRows(function(prev) {
72
- return append ? prev.concat(records) : records;
190
+ if (!append) return records;
191
+ var seen = {};
192
+ var out2 = [];
193
+ prev.concat(records).forEach(function(x) {
194
+ var key = String(x.id);
195
+ if (seen[key]) return;
196
+ seen[key] = true;
197
+ out2.push(x);
198
+ });
199
+ return out2;
73
200
  });
74
201
  setTotal(out.total || 0);
75
202
  setPage(out.current || pageNumber);
@@ -128,67 +255,47 @@ var require_tagfilter = __commonJS({
128
255
  { className: "wbs-tagmenu", style: { width: 260 }, onClick: function(e) {
129
256
  e.stopPropagation();
130
257
  } },
131
- h2(
132
- "div",
133
- { style: { padding: "2px 4px 6px" } },
134
- h2("input", {
135
- className: "wbs-input",
136
- autoFocus: true,
137
- value: query,
138
- placeholder: text("tagSearchPlaceholder"),
139
- onChange: function(e) {
140
- setQuery(e.target.value);
141
- }
142
- })
143
- ),
144
- ids.length ? h2(
145
- "div",
146
- { style: { padding: "0 4px 4px", display: "flex", flexDirection: "column", gap: 3 } },
147
- h2("div", { className: "wbs-tagmenu-head" }, h2("span", null, text("tagSelected") + " " + ids.length)),
148
- ids.map(function(id) {
149
- return h2(
150
- "button",
151
- { key: id, className: "wbs-mini", style: { justifyContent: "space-between" }, onClick: function() {
152
- toggle(id);
153
- } },
154
- h2("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, names[String(id)] || "#" + id),
155
- h2("span", null, "\xD7")
156
- );
157
- })
158
- ) : null,
159
- h2(
160
- "div",
161
- { className: "wbs-tagmenu-head" },
162
- h2("span", null, text("allTags") + (total ? " \xB7 " + total : "")),
163
- h2("span", { className: "wbs-grow" }),
164
- h2("button", { className: "wbs-mini", title: text("clear"), onClick: function() {
258
+ h2(FilterChecklist, {
259
+ beforeHead: ids.length ? h2(
260
+ "div",
261
+ { style: { padding: "0 4px 4px" } },
262
+ h2("div", { className: "wbs-tagmenu-head" }, h2("span", null, text("tagSelected") + " " + ids.length)),
263
+ ids.map(function(id) {
264
+ return h2(
265
+ "button",
266
+ { key: id, className: "wbs-mini", style: { justifyContent: "space-between" }, onClick: function() {
267
+ toggle(id);
268
+ } },
269
+ h2("span", { style: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } }, names[String(id)] || "#" + id),
270
+ h2("span", null, "\xD7")
271
+ );
272
+ })
273
+ ) : null,
274
+ items: rows.map(function(x) {
275
+ return { id: x.id, name: x.name };
276
+ }),
277
+ selected: ids,
278
+ onToggle: toggle,
279
+ query,
280
+ onQuery: setQuery,
281
+ title: text("allTags"),
282
+ total,
283
+ clearText: text("clear"),
284
+ onClear: function() {
165
285
  onChange([]);
166
286
  setQuery("");
167
- } }, h2(Icon2, { name: "x", size: 12 }), text("clear"))
168
- ),
169
- h2(
170
- "div",
171
- {
172
- style: { maxHeight: 240, overflow: "auto" },
173
- onScroll: function(e) {
174
- var el = e.currentTarget;
175
- if (!hasMore || loading) return;
176
- if (el.scrollTop + el.clientHeight >= el.scrollHeight - 24) load(query, (page || 1) + 1, true);
177
- }
178
287
  },
179
- rows.length ? rows.map(function(t) {
180
- var on = ids.indexOf(String(t.id)) >= 0;
181
- return h2(
182
- "label",
183
- { key: t.id, className: "wbs-tagopt" },
184
- h2("input", { type: "checkbox", checked: on, onChange: function() {
185
- toggle(t.id);
186
- } }),
187
- h2("span", null, t.name)
188
- );
189
- }) : h2("div", { className: "wbs-note", style: { padding: 6 } }, loading ? text("loadingMore") : query ? text("tagNoMatch") : text("allTags")),
190
- rows.length ? h2("div", { className: "wbs-note", style: { padding: 6, textAlign: "center" } }, loading ? text("loadingMore") : hasMore ? "" : text("noMore")) : null
191
- )
288
+ searchPlaceholder: text("tagSearchPlaceholder"),
289
+ loading,
290
+ hasMore,
291
+ onLoadMore: function() {
292
+ load(query, (page || 1) + 1, true);
293
+ },
294
+ emptyText: text("noTags"),
295
+ noMatchText: text("tagNoMatch"),
296
+ loadingText: text("loadingMore"),
297
+ noMoreText: text("noMore")
298
+ })
192
299
  ) : null
193
300
  );
194
301
  };
@@ -2615,7 +2722,9 @@ var require_data_view = __commonJS({
2615
2722
  }
2616
2723
  function loadTables() {
2617
2724
  setLoadingTables(true);
2618
- Promise.resolve(api.call(DOMAIN + ".dataTables")).then(function(r) {
2725
+ Promise.resolve((options.tablesLoader || function(a) {
2726
+ return a.call(DOMAIN + ".dataTables");
2727
+ })(api)).then(function(r) {
2619
2728
  if (r && r.ok === false) throw new Error(r && r.error || t.loadFail);
2620
2729
  var body = unwrap(r);
2621
2730
  if (!body || !Array.isArray(body.tables)) throw new Error(t.loadFail);
@@ -2680,7 +2789,9 @@ var require_data_view = __commonJS({
2680
2789
  if (sort) args.sort = sort;
2681
2790
  if (search) args.search = search;
2682
2791
  if (Object.keys(filters).length) args.filters = filters;
2683
- Promise.resolve(api.call(DOMAIN + ".dataQuery", args)).then(function(r) {
2792
+ Promise.resolve((options.query || function(a, q) {
2793
+ return a.call(DOMAIN + ".dataQuery", q);
2794
+ })(api, args)).then(function(r) {
2684
2795
  if (req !== reqRef.current) return;
2685
2796
  if (r && r.ok === false) throw new Error(r && r.error || t.queryFail);
2686
2797
  var body = unwrap(r);
@@ -3062,7 +3173,7 @@ var require_data_view = __commonJS({
3062
3173
  }
3063
3174
  }
3064
3175
  }),
3065
- h2("span", null, fmt(t.queryTime, { n: data ? data.queryMs : 0 }))
3176
+ data && data.queryMs !== void 0 ? h2("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
3066
3177
  );
3067
3178
  }
3068
3179
  if (!tables && loadingTables && options.Skeleton) return h2(options.Skeleton, { lang, label: t.loading });
@@ -3098,7 +3209,7 @@ var require_data_view = __commonJS({
3098
3209
  "span",
3099
3210
  { className: P + "-stabname" },
3100
3211
  h2("span", null, tableLabel(tb)),
3101
- h2("span", { className: P + "-sidecount" }, String(tb.count))
3212
+ h2("span", { className: P + "-sidecount" }, tb.count === void 0 || tb.count === null ? "" : String(tb.count))
3102
3213
  ),
3103
3214
  h2("span", { className: P + "-sidetable" }, tb.name)
3104
3215
  );
@@ -3125,7 +3236,7 @@ var require_data_view = __commonJS({
3125
3236
  h2(
3126
3237
  "div",
3127
3238
  { className: P + "-sub" },
3128
- current ? fmt(t.rowCount, { n: current.count }) : "",
3239
+ current && data && data.total !== void 0 ? fmt(t.rowCount, { n: data.total }) : "",
3129
3240
  current && current.deletedCount ? " \xB7 " + fmt(t.deletedCount, { n: current.deletedCount }) : "",
3130
3241
  " \xB7 " + t.subtitle
3131
3242
  )
@@ -4068,6 +4179,7 @@ var require_copy = __commonJS({
4068
4179
  cancel: "\u53D6\u6D88",
4069
4180
  close: "\u5173\u95ED",
4070
4181
  sensitiveHint: "\u5BC6\u7801/\u624B\u673A\u53F7/\u8EAB\u4EFD\u8BC1\u5199\u5E93\u524D\u52A0\u5BC6\uFF0C\u4EC5\u5728\u754C\u9762\u89E3\u9501\u4FDD\u9669\u7BB1\u540E\u53EF\u67E5\u770B\u4E0E\u590D\u5236\u3002",
4182
+ vaultInvalid: "\u51ED\u636E\u96C6\u5408\u5DF2\u5931\u6548\uFF08\u96C6\u5408\u88AB\u5220\u9664\uFF09\uFF0C\u4FDD\u5B58\u4EFB\u4E00\u654F\u611F\u5B57\u6BB5\u5373\u53EF\u91CD\u5EFA\u3002",
4071
4183
  vaultNotSet: "\u8D26\u53F7\u4FDD\u9669\u7BB1\u5C1A\u672A\u8BBE\u7F6E\u53E3\u4EE4\uFF1A\u8BBE\u7F6E\u53E3\u4EE4\u540E\u624D\u80FD\u586B\u5199\u5BC6\u7801\u3001\u624B\u673A\u53F7\u4E0E\u8EAB\u4EFD\u8BC1\u3002",
4072
4184
  vaultLocked: "\u8D26\u53F7\u4FDD\u9669\u7BB1\u5DF2\u9501\u5B9A\uFF1A\u8F93\u5165\u53E3\u4EE4\u540E\u5373\u53EF\u67E5\u770B\u4E0E\u586B\u5199\u654F\u611F\u5B57\u6BB5\u3002",
4073
4185
  vaultUnlocked: "\u8D26\u53F7\u4FDD\u9669\u7BB1\u5DF2\u89E3\u9501\uFF0C\u7A7A\u95F2 {min} \u5206\u949F\u81EA\u52A8\u9501\u5B9A\u3002",
@@ -4179,6 +4291,7 @@ var require_copy = __commonJS({
4179
4291
  cancel: "Cancel",
4180
4292
  close: "Close",
4181
4293
  sensitiveHint: "Password / phone / ID card are encrypted before writing and can only be read after unlocking the vault.",
4294
+ vaultInvalid: "The credential set is gone (deleted); saving any sensitive field rebuilds it.",
4182
4295
  vaultNotSet: "Vault passphrase is not set yet: set one before filling in password, phone or ID card.",
4183
4296
  vaultLocked: "Vault is locked: unlock to view or edit sensitive fields.",
4184
4297
  vaultUnlocked: "Vault unlocked; it locks after {min} idle minutes.",
@@ -4194,6 +4307,37 @@ var require_copy = __commonJS({
4194
4307
  }
4195
4308
  });
4196
4309
 
4310
+ // packages/addons/lib/filter-checklist-styles.cjs
4311
+ var require_filter_checklist_styles = __commonJS({
4312
+ "packages/addons/lib/filter-checklist-styles.cjs"(exports2, module2) {
4313
+ "use strict";
4314
+ module2.exports = [
4315
+ ".wbck{display:flex;flex-direction:column;min-width:0}",
4316
+ ".wbck-search{padding:0 0 6px}",
4317
+ ".wbck-input{width:100%;box-sizing:border-box;font:inherit;font-size:12.5px;padding:6px 9px;border:1px solid var(--wb-border);border-radius:8px;background:var(--wb-surface);color:inherit}",
4318
+ ".wbck-input:focus-visible{outline:2px solid var(--wb-accent);outline-offset:1px}",
4319
+ ".wbck-input:disabled{opacity:.6;cursor:not-allowed}",
4320
+ ".wbck-head{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--wb-muted);padding:2px 4px 7px}",
4321
+ ".wbck-grow{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
4322
+ ".wbck-sel{flex:none;color:var(--wb-accent)}",
4323
+ ".wbck-clear{appearance:none;flex:none;border:0;background:transparent;color:inherit;border-radius:4px;margin:0;padding:3px 5px;font:inherit;font-size:11.5px;line-height:1;cursor:pointer;opacity:.75}",
4324
+ ".wbck-clear:hover:enabled{opacity:1;background:color-mix(in srgb, currentColor 8%, transparent)}",
4325
+ ".wbck-clear:focus-visible{outline:2px solid var(--wb-accent);outline-offset:1px}",
4326
+ ".wbck-clear:disabled{opacity:.4;cursor:not-allowed}",
4327
+ ".wbck-list{max-height:220px;overflow:auto;overscroll-behavior:contain;border:1px solid var(--wb-border);border-radius:10px;padding:2px}",
4328
+ ".wbck-opt{display:flex;align-items:center;gap:7px;padding:6px;border-radius:6px;font-size:12.5px;cursor:pointer}",
4329
+ ".wbck-opt:hover{background:color-mix(in srgb, currentColor 7%, transparent)}",
4330
+ ".wbck-opt.is-on{background:color-mix(in srgb, var(--wb-accent) 10%, transparent)}",
4331
+ ".wbck-opt input{margin:0;flex:none;accent-color:var(--wb-accent)}",
4332
+ ".wbck-nm{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}",
4333
+ ".wbck-meta{margin-left:auto;flex:none;font-size:11.5px;color:var(--wb-muted)}",
4334
+ ".wbck-note{font-size:12px;color:var(--wb-muted);padding:8px 6px}",
4335
+ ".wbck-more{font-size:11px;color:var(--wb-muted);text-align:center;padding:6px 0 2px;opacity:.8}",
4336
+ "@media (max-width:760px){.wbck-list{max-height:200px}}"
4337
+ ];
4338
+ }
4339
+ });
4340
+
4197
4341
  // packages/addons/sites/client/ui/styles.cjs
4198
4342
  var require_styles = __commonJS({
4199
4343
  "packages/addons/sites/client/ui/styles.cjs"(exports2, module2) {
@@ -4350,7 +4494,423 @@ var require_styles = __commonJS({
4350
4494
  ".wbs-note{font-size:11px;color:var(--wbs-muted);line-height:1.6}",
4351
4495
  "@media(max-width:860px){.wbs-body{flex-direction:column}.wbs-tree{width:100%;max-height:220px}.wbs-table{min-width:760px}.wbs-root{min-height:0}}",
4352
4496
  "@media(max-width:600px){.wbs-head h2{font-size:18px}.wbs-linkrow{grid-template-columns:1fr 1fr}.wbs-modal{padding:14px}}"
4353
- ].join("\n");
4497
+ ].concat(require_filter_checklist_styles()).join("\n");
4498
+ }
4499
+ });
4500
+
4501
+ // packages/addons/sites/client/ui/accounts-modal.cjs
4502
+ var require_accounts_modal = __commonJS({
4503
+ "packages/addons/sites/client/ui/accounts-modal.cjs"(exports2, module2) {
4504
+ "use strict";
4505
+ module2.exports = function createAccountsModal(deps) {
4506
+ var h2 = deps.h;
4507
+ var React2 = deps.React;
4508
+ var useState = deps.useState;
4509
+ var useEffect = deps.useEffect;
4510
+ var Modal = deps.Modal;
4511
+ var Icon2 = deps.Icon;
4512
+ var text = deps.text;
4513
+ var callApi = deps.callApi;
4514
+ var errText = deps.errText;
4515
+ function AccountModal(props) {
4516
+ var api = props.api;
4517
+ var lang = props.lang || "zh";
4518
+ var site = props.site;
4519
+ var [accounts, setAccounts] = useState([]);
4520
+ var [vault, setVault] = useState({});
4521
+ var [loading, setLoading] = useState(true);
4522
+ var [error, setError] = useState("");
4523
+ var [busy, setBusy] = useState(false);
4524
+ var [draft, setDraft] = useState(null);
4525
+ var [pass, setPass] = useState("");
4526
+ var [pass2, setPass2] = useState("");
4527
+ var [cascade, setCascade] = useState([]);
4528
+ var [pickKey, setPickKey] = useState("");
4529
+ var [pendingDelete, setPendingDelete] = useState("");
4530
+ var [shown, setShown] = useState({});
4531
+ var [binding, setBinding] = useState(null);
4532
+ function mapVault(st) {
4533
+ var r = st || {};
4534
+ var idle = Number(r.idleTimeoutSec) > 0 ? Math.round(Number(r.idleTimeoutSec) / 60) : 15;
4535
+ return {
4536
+ installed: true,
4537
+ enabled: Boolean(r.initialized),
4538
+ unlocked: !r.locked,
4539
+ locked: Boolean(r.locked),
4540
+ unlockMode: r.unlockMode,
4541
+ idleMinutes: idle,
4542
+ remainingMs: r.locked ? 0 : idle * 60 * 1e3
4543
+ };
4544
+ }
4545
+ function reload() {
4546
+ setLoading(true);
4547
+ return Promise.all([
4548
+ callApi(api, "sites.accounts.list", { siteId: site.id }),
4549
+ callApi(api, "vault.status", {}),
4550
+ callApi(api, "vault.bindingsOf", { subjectType: "site", subjectId: site.id })
4551
+ ]).then(function(out) {
4552
+ setAccounts(out[0].accounts || []);
4553
+ setVault(mapVault(out[1]));
4554
+ setBinding(out[2] && out[2].items && out[2].items[0] || null);
4555
+ setError("");
4556
+ }).catch(function(e) {
4557
+ setError(errText(e));
4558
+ }).finally(function() {
4559
+ setLoading(false);
4560
+ });
4561
+ }
4562
+ function loadCascade() {
4563
+ callApi(api, "sites.accounts.cascade", { excludeSiteId: site.id }).then(function(r) {
4564
+ var list = [];
4565
+ (r.groups || []).forEach(function(g) {
4566
+ g.accounts.forEach(function(a) {
4567
+ list.push({ id: a.id, label: g.siteName + " \xB7 " + a.accountKey });
4568
+ });
4569
+ });
4570
+ setCascade(list);
4571
+ }).catch(function() {
4572
+ setCascade([]);
4573
+ });
4574
+ }
4575
+ useEffect(function() {
4576
+ reload();
4577
+ loadCascade();
4578
+ }, [site.id]);
4579
+ function guard(fn) {
4580
+ setBusy(true);
4581
+ setError("");
4582
+ return Promise.resolve().then(fn).catch(function(e) {
4583
+ setError(errText(e));
4584
+ }).finally(function() {
4585
+ setBusy(false);
4586
+ });
4587
+ }
4588
+ function submitVault() {
4589
+ if (!pass || pass.length < 12) {
4590
+ setError(text(lang, "passTooShort"));
4591
+ return;
4592
+ }
4593
+ if (!vault.enabled && pass !== pass2) {
4594
+ setError(text(lang, "passMismatch"));
4595
+ return;
4596
+ }
4597
+ guard(function() {
4598
+ var req = vault.enabled ? callApi(api, "vault.unlock", { passphrase: pass }) : callApi(api, "vault.setup", { passphrase: pass, mode: "A" });
4599
+ return req.then(function() {
4600
+ setPass("");
4601
+ setPass2("");
4602
+ return reload();
4603
+ });
4604
+ });
4605
+ }
4606
+ function lockVault() {
4607
+ guard(function() {
4608
+ return callApi(api, "vault.lock", {}).then(function() {
4609
+ setShown({});
4610
+ return reload();
4611
+ });
4612
+ });
4613
+ }
4614
+ function bindGroup() {
4615
+ guard(function() {
4616
+ return callApi(api, "vault.groupCreate", { name: "\u7AD9\u70B9\u8D26\u53F7 \xB7 " + (site.siteName || site.id) }).then(function(g) {
4617
+ return callApi(api, "vault.bind", { subjectType: "site", subjectId: site.id, groupId: g.id });
4618
+ }).then(function() {
4619
+ return reload();
4620
+ });
4621
+ });
4622
+ }
4623
+ function saveDraft() {
4624
+ var body = {
4625
+ accountKey: draft.accountKey,
4626
+ account: draft.account,
4627
+ remark: draft.remark
4628
+ };
4629
+ if (draft.password) body.password = draft.password;
4630
+ if (draft.phoneNumber) body.phoneNumber = draft.phoneNumber;
4631
+ if (draft.identityCard) body.identityCard = draft.identityCard;
4632
+ guard(function() {
4633
+ var req = draft.id ? callApi(api, "sites.accounts.update", Object.assign({ id: draft.id }, body)) : callApi(api, "sites.accounts.create", Object.assign({ siteId: site.id }, body));
4634
+ return req.then(function() {
4635
+ setDraft(null);
4636
+ props.onChanged && props.onChanged();
4637
+ return reload();
4638
+ });
4639
+ });
4640
+ }
4641
+ function removeAccount(id) {
4642
+ guard(function() {
4643
+ return callApi(api, "sites.accounts.delete", { id }).then(function() {
4644
+ setPendingDelete("");
4645
+ props.onChanged && props.onChanged();
4646
+ return reload();
4647
+ });
4648
+ });
4649
+ }
4650
+ function reveal(acc) {
4651
+ guard(function() {
4652
+ return callApi(api, "sites.accounts.get", { id: acc.id }).then(function(r) {
4653
+ var ids = r.secretIds || {};
4654
+ var jobs = [["password", "password"], ["phone", "phoneNumber"], ["identity", "identityCard"]].filter(function(pair) {
4655
+ return ids[pair[0]];
4656
+ }).map(function(pair) {
4657
+ return callApi(api, "vault.secretReveal", { id: ids[pair[0]] }).then(function(res) {
4658
+ var v = {};
4659
+ v[pair[1]] = res && res.secret !== void 0 ? res.secret : "";
4660
+ return v;
4661
+ }).catch(function() {
4662
+ return null;
4663
+ });
4664
+ });
4665
+ return Promise.all(jobs).then(function(list) {
4666
+ var out = {};
4667
+ list.forEach(function(v) {
4668
+ if (v) Object.assign(out, v);
4669
+ });
4670
+ setShown(function(prev) {
4671
+ var next = Object.assign({}, prev);
4672
+ next[acc.id] = out;
4673
+ return next;
4674
+ });
4675
+ });
4676
+ });
4677
+ });
4678
+ }
4679
+ function copyText(value) {
4680
+ if (!value) return;
4681
+ try {
4682
+ navigator.clipboard.writeText(value);
4683
+ if (typeof showToast === "function") showToast(text(lang, "copied"));
4684
+ } catch (e) {
4685
+ setError(String(e && e.message || e));
4686
+ }
4687
+ }
4688
+ function linkExternal(acc) {
4689
+ if (!pickKey) return;
4690
+ guard(function() {
4691
+ return callApi(api, "sites.accounts.link", { nativeAccountId: acc.id, externalAccountId: pickKey }).then(function() {
4692
+ setPickKey("");
4693
+ return reload();
4694
+ });
4695
+ });
4696
+ }
4697
+ function unlink(acc, rel) {
4698
+ guard(function() {
4699
+ return callApi(api, "sites.accounts.unlink", { nativeAccountId: acc.id, externalAccountId: rel.accountId }).then(function() {
4700
+ return reload();
4701
+ });
4702
+ });
4703
+ }
4704
+ function renderVaultBar() {
4705
+ if (!vault.enabled) {
4706
+ return h2(
4707
+ "div",
4708
+ { className: "wbs-vaultbar" },
4709
+ h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultNotSet")),
4710
+ h2(
4711
+ "div",
4712
+ { className: "wbs-vault-form" },
4713
+ h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphrase"), value: pass, onChange: function(e) {
4714
+ setPass(e.target.value);
4715
+ } }),
4716
+ h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphraseAgain"), value: pass2, onChange: function(e) {
4717
+ setPass2(e.target.value);
4718
+ } }),
4719
+ h2("button", { className: "wbs-btn", disabled: busy, onClick: submitVault }, text(lang, "vaultSetup"))
4720
+ )
4721
+ );
4722
+ }
4723
+ if (!vault.unlocked) {
4724
+ return h2(
4725
+ "div",
4726
+ { className: "wbs-vaultbar locked" },
4727
+ h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultLocked")),
4728
+ h2(
4729
+ "div",
4730
+ { className: "wbs-vault-form" },
4731
+ h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphrase"), value: pass, onChange: function(e) {
4732
+ setPass(e.target.value);
4733
+ } }),
4734
+ h2("button", { className: "wbs-btn", disabled: busy, onClick: submitVault }, text(lang, "vaultUnlock"))
4735
+ )
4736
+ );
4737
+ }
4738
+ return h2(
4739
+ "div",
4740
+ { className: "wbs-vaultbar unlocked" },
4741
+ h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultUnlocked", { min: vault.idleMinutes || 15 })),
4742
+ h2("div", { className: "wbs-grow" }),
4743
+ binding ? h2("span", { className: "wbs-chip" }, "\u51ED\u636E\u7EC4\uFF1A" + (binding.groupName || binding.groupId)) : h2(
4744
+ React2.Fragment,
4745
+ null,
4746
+ h2("span", { className: "wbs-vault-hint" }, "\u672C\u7AD9\u70B9\u5C1A\u672A\u5173\u8054\u51ED\u636E\u7EC4"),
4747
+ h2("button", { className: "wbs-btn sm", disabled: busy, onClick: bindGroup }, h2(Icon2, { name: "plus", size: 12 }), "\u521B\u5EFA\u5E76\u5173\u8054")
4748
+ ),
4749
+ h2("button", { className: "wbs-btn sm", disabled: busy, onClick: lockVault }, h2(Icon2, { name: "lock", size: 12 }), text(lang, "vaultLock"))
4750
+ );
4751
+ }
4752
+ function renderDraft() {
4753
+ var d = draft;
4754
+ function field(key, label, type, ph) {
4755
+ return h2(
4756
+ React2.Fragment,
4757
+ null,
4758
+ h2("label", { className: "wbs-label" }, label),
4759
+ h2("input", {
4760
+ className: "wbs-input",
4761
+ type: type || "text",
4762
+ placeholder: ph || "",
4763
+ value: d[key] || "",
4764
+ onChange: function(e) {
4765
+ var v = e.target.value;
4766
+ setDraft(function(prev) {
4767
+ var next = Object.assign({}, prev);
4768
+ next[key] = v;
4769
+ return next;
4770
+ });
4771
+ }
4772
+ })
4773
+ );
4774
+ }
4775
+ return h2(
4776
+ "div",
4777
+ { className: "wbs-accdraft" },
4778
+ h2("div", { className: "wbs-accdraft-title" }, d.id ? text(lang, "editAccount") : text(lang, "addAccount")),
4779
+ field("accountKey", text(lang, "accountKey") + " *", "text", "prod-admin"),
4780
+ field("account", text(lang, "loginName")),
4781
+ field("password", text(lang, "password"), "password"),
4782
+ field("phoneNumber", text(lang, "phone")),
4783
+ field("identityCard", text(lang, "identity")),
4784
+ field("remark", text(lang, "remark")),
4785
+ h2("div", { className: "wbs-vault-hint" }, text(lang, "sensitiveHint")),
4786
+ h2(
4787
+ "div",
4788
+ { className: "wbs-formfoot" },
4789
+ h2("div", { className: "wbs-grow" }),
4790
+ h2("button", { className: "wbs-btn", disabled: busy, onClick: function() {
4791
+ setDraft(null);
4792
+ } }, text(lang, "cancel")),
4793
+ h2("button", { className: "wbs-btn primary", disabled: busy, onClick: saveDraft }, text(lang, "save"))
4794
+ )
4795
+ );
4796
+ }
4797
+ return h2(
4798
+ Modal,
4799
+ { onClose: props.onClose },
4800
+ h2(
4801
+ "div",
4802
+ { className: "wbs-modal-title" },
4803
+ h2(Icon2, { name: "key", size: 15 }),
4804
+ text(lang, "accountsTitle", { name: site.siteName }),
4805
+ h2("button", { type: "button", className: "wbs-mini wbs-modal-x", title: text(lang, "cancel"), onClick: props.onClose }, h2(Icon2, { name: "x", size: 15 }))
4806
+ ),
4807
+ h2("div", { className: "wbs-modal-sub" }, text(lang, "accountsSub")),
4808
+ renderVaultBar(),
4809
+ error ? h2("div", { className: "wbs-error" }, error) : null,
4810
+ draft ? renderDraft() : h2(
4811
+ React2.Fragment,
4812
+ null,
4813
+ loading ? h2("div", { className: "wbs-loading" }, text(lang, "loading")) : null,
4814
+ !loading && !accounts.length ? h2("div", { className: "wbs-acc-empty" }, text(lang, "accountEmpty")) : null,
4815
+ !loading ? accounts.map(function(acc) {
4816
+ var plain = shown[acc.id] || null;
4817
+ return h2(
4818
+ "div",
4819
+ { className: "wbs-accrow", key: acc.id },
4820
+ h2(
4821
+ "div",
4822
+ { className: "wbs-accrow-head" },
4823
+ h2("b", null, acc.accountKey || "\u2014"),
4824
+ acc.account ? h2("span", { className: "wbs-acc-login" }, acc.account) : null,
4825
+ h2("div", { className: "wbs-grow" }),
4826
+ h2("button", { className: "wbs-btn sm icononly", title: text(lang, "edit"), onClick: function() {
4827
+ setDraft({ id: acc.id, accountKey: acc.accountKey, account: acc.account, remark: acc.remark, password: "", phoneNumber: "", identityCard: "" });
4828
+ } }, h2(Icon2, { name: "edit", size: 12 })),
4829
+ pendingDelete === acc.id ? h2(
4830
+ React2.Fragment,
4831
+ null,
4832
+ h2("button", { className: "wbs-btn sm danger", disabled: busy, onClick: function() {
4833
+ removeAccount(acc.id);
4834
+ } }, text(lang, "confirm")),
4835
+ h2("button", { className: "wbs-btn sm", onClick: function() {
4836
+ setPendingDelete("");
4837
+ } }, text(lang, "cancel"))
4838
+ ) : h2("button", { className: "wbs-btn sm danger icononly", title: text(lang, "del"), onClick: function() {
4839
+ setPendingDelete(acc.id);
4840
+ } }, h2(Icon2, { name: "trash", size: 12 }))
4841
+ ),
4842
+ acc.vaultInvalid ? h2("div", { className: "wbs-error" }, text(lang, "vaultInvalid")) : null,
4843
+ h2(
4844
+ "div",
4845
+ { className: "wbs-accrow-fields" },
4846
+ h2(
4847
+ "div",
4848
+ null,
4849
+ h2("i", null, text(lang, "password")),
4850
+ h2("span", null, plain ? plain.password || "\u2014" : acc.hasPassword ? "\u2022\u2022\u2022\u2022\u2022\u2022" : "\u2014"),
4851
+ acc.hasPassword ? h2("button", { className: "wbs-mini", title: text(lang, "reveal"), onClick: function() {
4852
+ if (plain) {
4853
+ setShown(function(prev) {
4854
+ var next = Object.assign({}, prev);
4855
+ delete next[acc.id];
4856
+ return next;
4857
+ });
4858
+ } else {
4859
+ reveal(acc);
4860
+ }
4861
+ } }, h2(Icon2, { name: plain ? "eye-off" : "eye", size: 11 })) : null,
4862
+ acc.hasPassword ? h2("button", { className: "wbs-mini", title: text(lang, "copy"), onClick: function() {
4863
+ if (plain) copyText(plain.password);
4864
+ else reveal(acc);
4865
+ } }, h2(Icon2, { name: "copy", size: 11 })) : null
4866
+ ),
4867
+ h2("div", null, h2("i", null, text(lang, "phone")), h2("span", null, plain ? plain.phoneNumber || "\u2014" : acc.phoneNumber || "\u2014")),
4868
+ h2("div", null, h2("i", null, text(lang, "identity")), h2("span", null, plain ? plain.identityCard || "\u2014" : acc.identityCard || "\u2014")),
4869
+ acc.remark ? h2("div", { className: "wbs-acc-remark" }, h2("i", null, text(lang, "remark")), h2("span", null, acc.remark)) : null
4870
+ ),
4871
+ h2(
4872
+ "div",
4873
+ { className: "wbs-accrow-ext" },
4874
+ (acc.externals || []).map(function(rel) {
4875
+ return h2(
4876
+ "span",
4877
+ { className: "wbs-chip", key: rel.relationId },
4878
+ rel.siteName + " \xB7 " + rel.accountKey,
4879
+ h2("button", { className: "wbs-mini", title: text(lang, "unlink"), onClick: function() {
4880
+ unlink(acc, rel);
4881
+ } }, h2(Icon2, { name: "x", size: 10 }))
4882
+ );
4883
+ }),
4884
+ h2(
4885
+ "select",
4886
+ { className: "wbs-select wbs-acc-extsel", value: pickKey, onChange: function(e) {
4887
+ setPickKey(e.target.value);
4888
+ } },
4889
+ h2("option", { value: "" }, text(lang, "externalPick")),
4890
+ cascade.map(function(o) {
4891
+ return h2("option", { key: o.id, value: o.id }, o.label);
4892
+ })
4893
+ ),
4894
+ h2("button", { className: "wbs-btn sm", disabled: !pickKey || busy, onClick: function() {
4895
+ linkExternal(acc);
4896
+ } }, text(lang, "externalAdd"))
4897
+ )
4898
+ );
4899
+ }) : null,
4900
+ !loading ? h2(
4901
+ "div",
4902
+ { className: "wbs-formfoot" },
4903
+ h2("button", { className: "wbs-btn primary", disabled: busy, onClick: function() {
4904
+ setDraft({ id: "", accountKey: "", account: "", password: "", phoneNumber: "", identityCard: "", remark: "" });
4905
+ } }, h2(Icon2, { name: "plus", size: 12 }), text(lang, "addAccount")),
4906
+ h2("div", { className: "wbs-grow" }),
4907
+ h2("button", { className: "wbs-btn", onClick: props.onClose }, text(lang, "close"))
4908
+ ) : null
4909
+ )
4910
+ );
4911
+ }
4912
+ return AccountModal;
4913
+ };
4354
4914
  }
4355
4915
  });
4356
4916
 
@@ -4781,7 +5341,7 @@ var require_action_schema_view = __commonJS({
4781
5341
  "div",
4782
5342
  { className: P + "-cardhead" },
4783
5343
  h2("code", { className: P + "-mono" }, Highlight.hit(action.name, kw)),
4784
- h2("span", { className: P + "-badge" }, action.domain),
5344
+ // 域名在页头已展示一次,卡片内不再重复(所有条目必然同域,见 visible 过滤)。
4785
5345
  h2("span", { className: P + "-badge" }, rows.length ? t.paramCount(rows.length) : t.noParams),
4786
5346
  rows.some(function(row) {
4787
5347
  return row.required;
@@ -5404,353 +5964,17 @@ var TagFilter = require_tagfilter();
5404
5964
  )
5405
5965
  );
5406
5966
  }
5407
- function AccountModal(props) {
5408
- var api = props.api;
5409
- var lang = props.lang || "zh";
5410
- var site = props.site;
5411
- var [accounts, setAccounts] = useState([]);
5412
- var [vault, setVault] = useState({});
5413
- var [loading, setLoading] = useState(true);
5414
- var [error, setError] = useState("");
5415
- var [busy, setBusy] = useState(false);
5416
- var [draft, setDraft] = useState(null);
5417
- var [pass, setPass] = useState("");
5418
- var [pass2, setPass2] = useState("");
5419
- var [cascade, setCascade] = useState([]);
5420
- var [pickKey, setPickKey] = useState("");
5421
- var [pendingDelete, setPendingDelete] = useState("");
5422
- var [shown, setShown] = useState({});
5423
- function reload() {
5424
- setLoading(true);
5425
- return Promise.all([
5426
- callApi(api, "sites.accounts.list", { siteId: site.id }),
5427
- callApi(api, "sites.vault.status", {})
5428
- ]).then(function(out) {
5429
- setAccounts(out[0].accounts || []);
5430
- setVault(out[1] || {});
5431
- setError("");
5432
- }).catch(function(e) {
5433
- setError(errText(e));
5434
- }).finally(function() {
5435
- setLoading(false);
5436
- });
5437
- }
5438
- function loadCascade() {
5439
- callApi(api, "sites.accounts.cascade", { excludeSiteId: site.id }).then(function(r) {
5440
- var list = [];
5441
- (r.groups || []).forEach(function(g) {
5442
- g.accounts.forEach(function(a) {
5443
- list.push({ id: a.id, label: g.siteName + " \xB7 " + a.accountKey });
5444
- });
5445
- });
5446
- setCascade(list);
5447
- }).catch(function() {
5448
- setCascade([]);
5449
- });
5450
- }
5451
- useEffect(function() {
5452
- reload();
5453
- loadCascade();
5454
- }, [site.id]);
5455
- function guard(fn) {
5456
- setBusy(true);
5457
- setError("");
5458
- return Promise.resolve().then(fn).catch(function(e) {
5459
- setError(errText(e));
5460
- }).finally(function() {
5461
- setBusy(false);
5462
- });
5463
- }
5464
- function submitVault() {
5465
- if (!pass || pass.length < 8) {
5466
- setError(text(lang, "passTooShort"));
5467
- return;
5468
- }
5469
- if (!vault.enabled && pass !== pass2) {
5470
- setError(text(lang, "passMismatch"));
5471
- return;
5472
- }
5473
- guard(function() {
5474
- var name = vault.enabled ? "sites.vault.unlock" : "sites.vault.setup";
5475
- var args = vault.enabled ? { passphrase: pass } : { passphrase: pass };
5476
- return callApi(api, name, args).then(function() {
5477
- setPass("");
5478
- setPass2("");
5479
- return reload();
5480
- });
5481
- });
5482
- }
5483
- function lockVault() {
5484
- guard(function() {
5485
- return callApi(api, "sites.vault.lock", {}).then(function() {
5486
- setShown({});
5487
- return reload();
5488
- });
5489
- });
5490
- }
5491
- function saveDraft() {
5492
- var body = {
5493
- accountKey: draft.accountKey,
5494
- account: draft.account,
5495
- remark: draft.remark
5496
- };
5497
- if (draft.password) body.password = draft.password;
5498
- if (draft.phoneNumber) body.phoneNumber = draft.phoneNumber;
5499
- if (draft.identityCard) body.identityCard = draft.identityCard;
5500
- guard(function() {
5501
- var req = draft.id ? callApi(api, "sites.accounts.update", Object.assign({ id: draft.id }, body)) : callApi(api, "sites.accounts.create", Object.assign({ siteId: site.id }, body));
5502
- return req.then(function() {
5503
- setDraft(null);
5504
- props.onChanged && props.onChanged();
5505
- return reload();
5506
- });
5507
- });
5508
- }
5509
- function removeAccount(id) {
5510
- guard(function() {
5511
- return callApi(api, "sites.accounts.delete", { id }).then(function() {
5512
- setPendingDelete("");
5513
- props.onChanged && props.onChanged();
5514
- return reload();
5515
- });
5516
- });
5517
- }
5518
- function reveal(acc) {
5519
- guard(function() {
5520
- return callApi(api, "sites.accounts.reveal", { id: acc.id }).then(function(r) {
5521
- setShown(function(prev) {
5522
- var next = Object.assign({}, prev);
5523
- next[acc.id] = r;
5524
- return next;
5525
- });
5526
- });
5527
- });
5528
- }
5529
- function copyText(value) {
5530
- if (!value) return;
5531
- try {
5532
- navigator.clipboard.writeText(value);
5533
- showToast(text(lang, "copied"));
5534
- } catch (e) {
5535
- setError(String(e && e.message || e));
5536
- }
5537
- }
5538
- function linkExternal(acc) {
5539
- if (!pickKey) return;
5540
- guard(function() {
5541
- return callApi(api, "sites.accounts.link", { nativeAccountId: acc.id, externalAccountId: pickKey }).then(function() {
5542
- setPickKey("");
5543
- return reload();
5544
- });
5545
- });
5546
- }
5547
- function unlink(acc, rel) {
5548
- guard(function() {
5549
- return callApi(api, "sites.accounts.unlink", { nativeAccountId: acc.id, externalAccountId: rel.accountId }).then(function() {
5550
- return reload();
5551
- });
5552
- });
5553
- }
5554
- function renderVaultBar() {
5555
- if (!vault.enabled) {
5556
- return h2(
5557
- "div",
5558
- { className: "wbs-vaultbar" },
5559
- h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultNotSet")),
5560
- h2(
5561
- "div",
5562
- { className: "wbs-vault-form" },
5563
- h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphrase"), value: pass, onChange: function(e) {
5564
- setPass(e.target.value);
5565
- } }),
5566
- h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphraseAgain"), value: pass2, onChange: function(e) {
5567
- setPass2(e.target.value);
5568
- } }),
5569
- h2("button", { className: "wbs-btn", disabled: busy, onClick: submitVault }, text(lang, "vaultSetup"))
5570
- )
5571
- );
5572
- }
5573
- if (!vault.unlocked) {
5574
- return h2(
5575
- "div",
5576
- { className: "wbs-vaultbar locked" },
5577
- h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultLocked")),
5578
- h2(
5579
- "div",
5580
- { className: "wbs-vault-form" },
5581
- h2("input", { className: "wbs-input", type: "password", placeholder: text(lang, "passphrase"), value: pass, onChange: function(e) {
5582
- setPass(e.target.value);
5583
- } }),
5584
- h2("button", { className: "wbs-btn", disabled: busy, onClick: submitVault }, text(lang, "vaultUnlock"))
5585
- )
5586
- );
5587
- }
5588
- return h2(
5589
- "div",
5590
- { className: "wbs-vaultbar unlocked" },
5591
- h2("div", { className: "wbs-vault-hint" }, text(lang, "vaultUnlocked", { min: vault.idleMinutes || 15 })),
5592
- h2("button", { className: "wbs-btn sm", disabled: busy, onClick: lockVault }, h2(Icon2, { name: "lock", size: 12 }), text(lang, "vaultLock"))
5593
- );
5594
- }
5595
- function renderDraft() {
5596
- var d = draft;
5597
- function field(key, label, type, ph) {
5598
- return h2(
5599
- React2.Fragment,
5600
- null,
5601
- h2("label", { className: "wbs-label" }, label),
5602
- h2("input", {
5603
- className: "wbs-input",
5604
- type: type || "text",
5605
- placeholder: ph || "",
5606
- value: d[key] || "",
5607
- onChange: function(e) {
5608
- var v = e.target.value;
5609
- setDraft(function(prev) {
5610
- var next = Object.assign({}, prev);
5611
- next[key] = v;
5612
- return next;
5613
- });
5614
- }
5615
- })
5616
- );
5617
- }
5618
- return h2(
5619
- "div",
5620
- { className: "wbs-accdraft" },
5621
- h2("div", { className: "wbs-accdraft-title" }, d.id ? text(lang, "editAccount") : text(lang, "addAccount")),
5622
- field("accountKey", text(lang, "accountKey") + " *", "text", "prod-admin"),
5623
- field("account", text(lang, "loginName")),
5624
- field("password", text(lang, "password"), "password"),
5625
- field("phoneNumber", text(lang, "phone")),
5626
- field("identityCard", text(lang, "identity")),
5627
- field("remark", text(lang, "remark")),
5628
- h2("div", { className: "wbs-vault-hint" }, text(lang, "sensitiveHint")),
5629
- h2(
5630
- "div",
5631
- { className: "wbs-formfoot" },
5632
- h2("div", { className: "wbs-grow" }),
5633
- h2("button", { className: "wbs-btn", disabled: busy, onClick: function() {
5634
- setDraft(null);
5635
- } }, text(lang, "cancel")),
5636
- h2("button", { className: "wbs-btn primary", disabled: busy, onClick: saveDraft }, text(lang, "save"))
5637
- )
5638
- );
5639
- }
5640
- return h2(
5641
- Modal,
5642
- { onClose: props.onClose },
5643
- h2(
5644
- "div",
5645
- { className: "wbs-modal-title" },
5646
- h2(Icon2, { name: "key", size: 15 }),
5647
- text(lang, "accountsTitle", { name: site.siteName }),
5648
- h2("button", { type: "button", className: "wbs-mini wbs-modal-x", title: text(lang, "cancel"), onClick: props.onClose }, h2(Icon2, { name: "x", size: 15 }))
5649
- ),
5650
- h2("div", { className: "wbs-modal-sub" }, text(lang, "accountsSub")),
5651
- renderVaultBar(),
5652
- error ? h2("div", { className: "wbs-error" }, error) : null,
5653
- draft ? renderDraft() : h2(
5654
- React2.Fragment,
5655
- null,
5656
- loading ? h2("div", { className: "wbs-loading" }, text(lang, "loading")) : null,
5657
- !loading && !accounts.length ? h2("div", { className: "wbs-acc-empty" }, text(lang, "accountEmpty")) : null,
5658
- !loading ? accounts.map(function(acc) {
5659
- var plain = shown[acc.id] || null;
5660
- return h2(
5661
- "div",
5662
- { className: "wbs-accrow", key: acc.id },
5663
- h2(
5664
- "div",
5665
- { className: "wbs-accrow-head" },
5666
- h2("b", null, acc.accountKey || "\u2014"),
5667
- acc.account ? h2("span", { className: "wbs-acc-login" }, acc.account) : null,
5668
- h2("div", { className: "wbs-grow" }),
5669
- h2("button", { className: "wbs-btn sm icononly", title: text(lang, "edit"), onClick: function() {
5670
- setDraft({ id: acc.id, accountKey: acc.accountKey, account: acc.account, remark: acc.remark, password: "", phoneNumber: "", identityCard: "" });
5671
- } }, h2(Icon2, { name: "edit", size: 12 })),
5672
- pendingDelete === acc.id ? h2(
5673
- React2.Fragment,
5674
- null,
5675
- h2("button", { className: "wbs-btn sm danger", disabled: busy, onClick: function() {
5676
- removeAccount(acc.id);
5677
- } }, text(lang, "confirm")),
5678
- h2("button", { className: "wbs-btn sm", onClick: function() {
5679
- setPendingDelete("");
5680
- } }, text(lang, "cancel"))
5681
- ) : h2("button", { className: "wbs-btn sm danger icononly", title: text(lang, "del"), onClick: function() {
5682
- setPendingDelete(acc.id);
5683
- } }, h2(Icon2, { name: "trash", size: 12 }))
5684
- ),
5685
- h2(
5686
- "div",
5687
- { className: "wbs-accrow-fields" },
5688
- h2(
5689
- "div",
5690
- null,
5691
- h2("i", null, text(lang, "password")),
5692
- h2("span", null, plain ? plain.password || "\u2014" : acc.hasPassword ? "\u2022\u2022\u2022\u2022\u2022\u2022" : "\u2014"),
5693
- acc.hasPassword ? h2("button", { className: "wbs-mini", title: text(lang, "reveal"), onClick: function() {
5694
- if (plain) {
5695
- setShown(function(prev) {
5696
- var next = Object.assign({}, prev);
5697
- delete next[acc.id];
5698
- return next;
5699
- });
5700
- } else {
5701
- reveal(acc);
5702
- }
5703
- } }, h2(Icon2, { name: plain ? "eye-off" : "eye", size: 11 })) : null,
5704
- acc.hasPassword ? h2("button", { className: "wbs-mini", title: text(lang, "copy"), onClick: function() {
5705
- if (plain) copyText(plain.password);
5706
- else reveal(acc);
5707
- } }, h2(Icon2, { name: "copy", size: 11 })) : null
5708
- ),
5709
- h2("div", null, h2("i", null, text(lang, "phone")), h2("span", null, plain ? plain.phoneNumber || "\u2014" : acc.phoneNumber || "\u2014")),
5710
- h2("div", null, h2("i", null, text(lang, "identity")), h2("span", null, plain ? plain.identityCard || "\u2014" : acc.identityCard || "\u2014")),
5711
- acc.remark ? h2("div", { className: "wbs-acc-remark" }, h2("i", null, text(lang, "remark")), h2("span", null, acc.remark)) : null
5712
- ),
5713
- h2(
5714
- "div",
5715
- { className: "wbs-accrow-ext" },
5716
- (acc.externals || []).map(function(rel) {
5717
- return h2(
5718
- "span",
5719
- { className: "wbs-chip", key: rel.relationId },
5720
- rel.siteName + " \xB7 " + rel.accountKey,
5721
- h2("button", { className: "wbs-mini", title: text(lang, "unlink"), onClick: function() {
5722
- unlink(acc, rel);
5723
- } }, h2(Icon2, { name: "x", size: 10 }))
5724
- );
5725
- }),
5726
- h2(
5727
- "select",
5728
- { className: "wbs-select wbs-acc-extsel", value: pickKey, onChange: function(e) {
5729
- setPickKey(e.target.value);
5730
- } },
5731
- h2("option", { value: "" }, text(lang, "externalPick")),
5732
- cascade.map(function(o) {
5733
- return h2("option", { key: o.id, value: o.id }, o.label);
5734
- })
5735
- ),
5736
- h2("button", { className: "wbs-btn sm", disabled: !pickKey || busy, onClick: function() {
5737
- linkExternal(acc);
5738
- } }, text(lang, "externalAdd"))
5739
- )
5740
- );
5741
- }) : null,
5742
- !loading ? h2(
5743
- "div",
5744
- { className: "wbs-formfoot" },
5745
- h2("button", { className: "wbs-btn primary", disabled: busy, onClick: function() {
5746
- setDraft({ id: "", accountKey: "", account: "", password: "", phoneNumber: "", identityCard: "", remark: "" });
5747
- } }, h2(Icon2, { name: "plus", size: 12 }), text(lang, "addAccount")),
5748
- h2("div", { className: "wbs-grow" }),
5749
- h2("button", { className: "wbs-btn", onClick: props.onClose }, text(lang, "close"))
5750
- ) : null
5751
- )
5752
- );
5753
- }
5967
+ var AccountModal = require_accounts_modal()({
5968
+ h: h2,
5969
+ React: React2,
5970
+ useState,
5971
+ useEffect,
5972
+ Modal,
5973
+ Icon: Icon2,
5974
+ text,
5975
+ callApi,
5976
+ errText
5977
+ });
5754
5978
  function DeleteSiteModal(props) {
5755
5979
  var api = props.api;
5756
5980
  var lang = props.lang || "zh";
@@ -6496,7 +6720,8 @@ var TagFilter = require_tagfilter();
6496
6720
  injectCss();
6497
6721
  host.registerAddon({
6498
6722
  id: "wb-addon-sites",
6499
- version: "1.10.0",
6723
+ version: "1.12.1",
6724
+ icon: (init_globe(), __toCommonJS(globe_exports)).default,
6500
6725
  views: [
6501
6726
  { id: "stats", icon: tabIcon("chart"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: statsView.SitesStatsView },
6502
6727
  { id: "sites", icon: tabIcon("globe"), title: { zh: "\u8BB0\u5F55", en: "Records" }, component: SitesView },