dsh-xrxs-lingting 0.4.0-dev.52 → 0.4.0-dev.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-xrxs-lingting",
3
- "version": "0.4.0-dev.52",
3
+ "version": "0.4.0-dev.53",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "dev": "vite --host 127.0.0.1",
@@ -1579,20 +1579,16 @@ var XinLingtingService = class {
1579
1579
  }
1580
1580
  };
1581
1581
  remove = async (id) => {
1582
- await this.http.send(this.requests.remove(id));
1583
- if (this.snapshot.active?.id === id) {
1584
- this.stopTicking();
1585
- this.closeWs();
1586
- const capture = this.capture;
1587
- this.capture = null;
1588
- if (capture) {
1589
- capture.pause();
1590
- void capture.stop().catch(() => {
1591
- });
1592
- }
1593
- this.emit({ active: null, catalogVersion: this.snapshot.catalogVersion + 1 });
1594
- } else {
1582
+ if (this.snapshot.operation) throw new Error("\u6B63\u5728\u5904\u7406\u5176\u4ED6\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002");
1583
+ if (this.snapshot.active?.id === id) throw new Error("\u8BF7\u5148\u7ED3\u675F\u8FD9\u573A\u7075\u542C\uFF0C\u518D\u5220\u9664\u8BB0\u5F55\u3002");
1584
+ this.emit({ operation: "deleting" });
1585
+ try {
1586
+ const record = await this.loadDetail(id);
1587
+ if (record.id !== id || !isSessionEnded(record.status)) throw new Error("\u8FD9\u573A\u7075\u542C\u5C1A\u672A\u7ED3\u675F\uFF0C\u8BF7\u5148\u7ED3\u675F\u540E\u518D\u5220\u9664\u3002");
1588
+ await this.http.send(this.requests.remove(id));
1595
1589
  this.emit({ catalogVersion: this.snapshot.catalogVersion + 1 });
1590
+ } finally {
1591
+ this.emit({ operation: null });
1596
1592
  }
1597
1593
  };
1598
1594
  dispose = () => {
@@ -4803,6 +4799,26 @@ function RecordList({ service, snapshot, state, onState, onOpen, onStart, onOpen
4803
4799
  const [renameError, setRenameError] = (0, import_react19.useState)("");
4804
4800
  const [shareLoadingId, setShareLoadingId] = (0, import_react19.useState)(null);
4805
4801
  const [shareTarget, setShareTarget] = (0, import_react19.useState)(null);
4802
+ const [deleting, setDeleting] = (0, import_react19.useState)(null);
4803
+ const [deleteBusy, setDeleteBusy] = (0, import_react19.useState)(false);
4804
+ const [deleteError, setDeleteError] = (0, import_react19.useState)("");
4805
+ const deleteLock = (0, import_react19.useRef)(false);
4806
+ const submitDelete = async () => {
4807
+ if (!deleting || deleteLock.current) return;
4808
+ deleteLock.current = true;
4809
+ setDeleteBusy(true);
4810
+ setDeleteError("");
4811
+ try {
4812
+ await service.remove(deleting.id);
4813
+ setDeleting(null);
4814
+ setToast("\u8BB0\u5F55\u5DF2\u5220\u9664");
4815
+ } catch (e) {
4816
+ setDeleteError(e instanceof Error ? e.message : "\u5220\u9664\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\u3002");
4817
+ } finally {
4818
+ deleteLock.current = false;
4819
+ setDeleteBusy(false);
4820
+ }
4821
+ };
4806
4822
  const [toast, setToast] = (0, import_react19.useState)("");
4807
4823
  const queryKey = `${state.search}\0${state.status}\0${state.page}`;
4808
4824
  const retainContent = !!result && queryKey === resultQuery;
@@ -4820,6 +4836,11 @@ function RecordList({ service, snapshot, state, onState, onOpen, onStart, onOpen
4820
4836
  setError("");
4821
4837
  service.list({ search: state.search, status: state.status, page: state.page, pageSize: PAGE_SIZE }).then((data) => {
4822
4838
  if (!stale) {
4839
+ const lastPage = Math.max(1, Math.ceil(data.total / PAGE_SIZE));
4840
+ if (state.page > lastPage) {
4841
+ onState({ page: lastPage, scroll: 0 });
4842
+ return;
4843
+ }
4823
4844
  setResult(data);
4824
4845
  setResultQuery(queryKey);
4825
4846
  setLoading(false);
@@ -5008,6 +5029,10 @@ function RecordList({ service, snapshot, state, onState, onOpen, onStart, onOpen
5008
5029
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("td", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "row-actions", children: [
5009
5030
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "row-open", disabled: detailsDisabled, "data-tip": detailsDisabled ? "\u5F55\u97F3\u4E2D\u6682\u4E0D\u53EF\u67E5\u770B\u8BE6\u60C5" : "\u53BB\u8BE6\u60C5", "aria-label": `\u67E5\u770B ${r.title}`, onClick: () => open(r.id), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ArrowUpRight, { size: 19 }) }),
5010
5031
  isSessionEnded(r.status) && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "row-open", "data-tip": "\u5206\u4EAB", "aria-label": `\u5206\u4EAB ${r.title}`, disabled: shareLoadingId === r.id, onClick: () => void openShare(r), children: shareLoadingId === r.id ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Spinner, { size: 16 }) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Share2, { size: 17 }) }),
5032
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "row-open", "data-tip": isSessionEnded(r.status) ? "\u5220\u9664" : "\u8BF7\u5148\u7ED3\u675F\u7075\u542C\u540E\u518D\u5220\u9664", "aria-label": `\u5220\u9664 ${r.title}`, disabled: !isSessionEnded(r.status) || !!snapshot.operation, onClick: () => {
5033
+ setDeleting(r);
5034
+ setDeleteError("");
5035
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Trash2, { size: 17 }) }),
5011
5036
  isSessionEnded(r.status) && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "row-open", "data-tip": "\u7F16\u8F91", "aria-label": `\u91CD\u547D\u540D ${r.title}`, onClick: () => openRename(r), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Pencil, { size: 17 }) })
5012
5037
  ] }) })
5013
5038
  ] }, r.id);
@@ -5056,6 +5081,23 @@ function RecordList({ service, snapshot, state, onState, onOpen, onStart, onOpen
5056
5081
  onCopied: setToast
5057
5082
  }
5058
5083
  ),
5084
+ deleting && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Modal, { title: "\u5220\u9664\u8FD9\u6761\u7075\u542C\u8BB0\u5F55\uFF1F", busy: deleteBusy, onClose: () => {
5085
+ if (!deleteLock.current) setDeleting(null);
5086
+ }, children: [
5087
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("p", { className: "modal-description", children: [
5088
+ "\u786E\u5B9A\u5220\u9664\u300C",
5089
+ deleting.title,
5090
+ "\u300D\uFF1F\u5220\u9664\u540E\u65E0\u6CD5\u5728\u7075\u542C\u5217\u8868\u4E2D\u6062\u590D\uFF0C\u8BF7\u786E\u8BA4\u4E0D\u518D\u9700\u8981\u8FD9\u6761\u8BB0\u5F55\u3002"
5091
+ ] }),
5092
+ deleteError && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ErrorNotice, { children: deleteError }),
5093
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "modal-actions", children: [
5094
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("button", { className: "button", disabled: deleteBusy, onClick: () => setDeleting(null), children: "\u53D6\u6D88" }),
5095
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("button", { className: "button danger", disabled: deleteBusy, onClick: () => void submitDelete(), children: [
5096
+ deleteBusy ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Spinner, {}) : null,
5097
+ deleteBusy ? "\u6B63\u5728\u5220\u9664\u2026" : "\u786E\u8BA4\u5220\u9664"
5098
+ ] })
5099
+ ] })
5100
+ ] }),
5059
5101
  renaming && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Modal, { title: "\u91CD\u547D\u540D\u8BB0\u5F55", onClose: () => setRenaming(null), busy: renameBusy, children: [
5060
5102
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("label", { className: "field-label", htmlFor: "lt-rename-input", children: "\u8BB0\u5F55\u540D\u79F0" }),
5061
5103
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("input", { id: "lt-rename-input", className: "text-input", value: renameInput, maxLength: TITLE_MAX_LENGTH, disabled: renameBusy, onChange: (e) => setRenameInput(e.target.value) }),