dsh-mishu 0.7.1 → 0.7.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 +2 -2
- package/lib/client.js +422 -383
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -33,7 +33,7 @@ __export(index_exports, {
|
|
|
33
33
|
module.exports = __toCommonJS(index_exports);
|
|
34
34
|
|
|
35
35
|
// src/client/Board.tsx
|
|
36
|
-
var
|
|
36
|
+
var import_react6 = require("react");
|
|
37
37
|
|
|
38
38
|
// src/client/api.ts
|
|
39
39
|
async function post(path, body) {
|
|
@@ -516,14 +516,52 @@ function AskAI({ topic, lang, locale, openChat: openChat2, compact = false }) {
|
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
// src/client/Settings.tsx
|
|
519
|
-
var
|
|
519
|
+
var import_react5 = require("react");
|
|
520
520
|
|
|
521
|
-
// src/client/
|
|
521
|
+
// src/client/Fold.tsx
|
|
522
522
|
var import_react2 = require("react");
|
|
523
|
-
var import_react_dom = require("react-dom");
|
|
524
523
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
524
|
+
var FoldCtx = (0, import_react2.createContext)({ open: void 0, toggle: () => {
|
|
525
|
+
} });
|
|
526
|
+
function FoldGroup({ children }) {
|
|
527
|
+
const [open, setOpen] = (0, import_react2.useState)();
|
|
528
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FoldCtx.Provider, { value: { open, toggle: (key) => setOpen((current) => current === key ? void 0 : key) }, children });
|
|
529
|
+
}
|
|
530
|
+
function Fold({ id, title, aside, className = "", children }) {
|
|
531
|
+
const parent = (0, import_react2.useContext)(FoldCtx);
|
|
532
|
+
const [inner, setInner] = (0, import_react2.useState)();
|
|
533
|
+
const open = parent.open === id;
|
|
534
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: `mishu-card mishu-fold${open ? " open" : ""}${className === "" ? "" : ` ${className}`}`, children: [
|
|
535
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
536
|
+
"div",
|
|
537
|
+
{
|
|
538
|
+
className: "mishu-card-head",
|
|
539
|
+
role: "button",
|
|
540
|
+
tabIndex: 0,
|
|
541
|
+
"aria-expanded": open,
|
|
542
|
+
onClick: () => parent.toggle(id),
|
|
543
|
+
onKeyDown: (event) => {
|
|
544
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
545
|
+
event.preventDefault();
|
|
546
|
+
parent.toggle(id);
|
|
547
|
+
},
|
|
548
|
+
children: [
|
|
549
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "mishu-caret", "aria-hidden": "true" }),
|
|
550
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "mishu-card-title", children: title }),
|
|
551
|
+
aside === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "mishu-card-aside", onClick: (event) => event.stopPropagation(), children: aside })
|
|
552
|
+
]
|
|
553
|
+
}
|
|
554
|
+
),
|
|
555
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "mishu-card-body", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FoldCtx.Provider, { value: { open: inner, toggle: (key) => setInner((current) => current === key ? void 0 : key) }, children }) }) : null
|
|
556
|
+
] });
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// src/client/Modal.tsx
|
|
560
|
+
var import_react3 = require("react");
|
|
561
|
+
var import_react_dom = require("react-dom");
|
|
562
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
525
563
|
function Modal({ title, onClose, children }) {
|
|
526
|
-
(0,
|
|
564
|
+
(0, import_react3.useEffect)(() => {
|
|
527
565
|
const key = (event) => {
|
|
528
566
|
if (event.key === "Escape") onClose();
|
|
529
567
|
};
|
|
@@ -531,12 +569,12 @@ function Modal({ title, onClose, children }) {
|
|
|
531
569
|
return () => window.removeEventListener("keydown", key);
|
|
532
570
|
}, [onClose]);
|
|
533
571
|
return (0, import_react_dom.createPortal)(
|
|
534
|
-
/* @__PURE__ */ (0,
|
|
572
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "mishu-modal-backdrop", onMouseDown: (event) => {
|
|
535
573
|
if (event.target === event.currentTarget) onClose();
|
|
536
|
-
}, children: /* @__PURE__ */ (0,
|
|
537
|
-
/* @__PURE__ */ (0,
|
|
538
|
-
/* @__PURE__ */ (0,
|
|
539
|
-
/* @__PURE__ */ (0,
|
|
574
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-modal", role: "dialog", "aria-modal": "true", "aria-label": title, children: [
|
|
575
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "mishu-modal-head", children: [
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h2", { children: title }),
|
|
577
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", "aria-label": "\xD7", onClick: onClose, children: "\xD7" })
|
|
540
578
|
] }),
|
|
541
579
|
children
|
|
542
580
|
] }) }),
|
|
@@ -545,8 +583,8 @@ function Modal({ title, onClose, children }) {
|
|
|
545
583
|
}
|
|
546
584
|
|
|
547
585
|
// src/client/Notify.tsx
|
|
548
|
-
var
|
|
549
|
-
var
|
|
586
|
+
var import_react4 = require("react");
|
|
587
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
550
588
|
var browserZone = () => {
|
|
551
589
|
try {
|
|
552
590
|
return Intl.DateTimeFormat().resolvedOptions().timeZone ?? "";
|
|
@@ -557,10 +595,10 @@ var browserZone = () => {
|
|
|
557
595
|
function NotifySection({ view, lang, locale, take }) {
|
|
558
596
|
const t = TEXT[lang];
|
|
559
597
|
const notify = view.notify.settings;
|
|
560
|
-
const [tested, setTested] = (0,
|
|
561
|
-
const [feishuOpen, setFeishuOpen] = (0,
|
|
598
|
+
const [tested, setTested] = (0, import_react4.useState)({});
|
|
599
|
+
const [feishuOpen, setFeishuOpen] = (0, import_react4.useState)(false);
|
|
562
600
|
const save = async (patch) => take(await settingsApi.saveNotify(locale(), patch), t.sSaved);
|
|
563
|
-
(0,
|
|
601
|
+
(0, import_react4.useEffect)(() => {
|
|
564
602
|
const zone = browserZone();
|
|
565
603
|
if (notify.timeZone === "" && zone !== "") void settingsApi.saveNotify(locale(), { timeZone: zone }).then((r) => take(r));
|
|
566
604
|
}, [notify.timeZone, locale]);
|
|
@@ -569,14 +607,14 @@ function NotifySection({ view, lang, locale, take }) {
|
|
|
569
607
|
const r = await settingsApi.testNotify(locale(), channel);
|
|
570
608
|
setTested({ ...tested, [channel]: r.ok ? { ok: true, text: t.nTestSent } : { ok: false, text: r.message } });
|
|
571
609
|
};
|
|
572
|
-
const time = (value, onChange) => /* @__PURE__ */ (0,
|
|
610
|
+
const time = (value, onChange) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "time", step: 60, value, onChange: (e) => {
|
|
573
611
|
if (e.target.value !== "") onChange(e.target.value);
|
|
574
612
|
} });
|
|
575
613
|
const last = view.notify.last;
|
|
576
|
-
return /* @__PURE__ */ (0,
|
|
577
|
-
/* @__PURE__ */ (0,
|
|
578
|
-
/* @__PURE__ */ (0,
|
|
579
|
-
/* @__PURE__ */ (0,
|
|
614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
615
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mishu-notify-row", children: [
|
|
616
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mishu-check", children: [
|
|
617
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", checked: notify.brief.enabled, onChange: (e) => {
|
|
580
618
|
void save({ brief: { ...notify.brief, enabled: e.target.checked } });
|
|
581
619
|
} }),
|
|
582
620
|
t.nBrief
|
|
@@ -585,15 +623,15 @@ function NotifySection({ view, lang, locale, take }) {
|
|
|
585
623
|
void save({ brief: { ...notify.brief, time: value } });
|
|
586
624
|
})
|
|
587
625
|
] }),
|
|
588
|
-
/* @__PURE__ */ (0,
|
|
589
|
-
/* @__PURE__ */ (0,
|
|
626
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mishu-notify-row", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mishu-check", children: [
|
|
627
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", checked: notify.urgent, onChange: (e) => {
|
|
590
628
|
void save({ urgent: e.target.checked });
|
|
591
629
|
} }),
|
|
592
630
|
t.nUrgent
|
|
593
631
|
] }) }),
|
|
594
|
-
/* @__PURE__ */ (0,
|
|
595
|
-
/* @__PURE__ */ (0,
|
|
596
|
-
/* @__PURE__ */ (0,
|
|
632
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mishu-notify-row", children: [
|
|
633
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mishu-check", children: [
|
|
634
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", checked: notify.quiet.enabled, onChange: (e) => {
|
|
597
635
|
void save({ quiet: { ...notify.quiet, enabled: e.target.checked } });
|
|
598
636
|
} }),
|
|
599
637
|
t.nQuiet
|
|
@@ -601,19 +639,22 @@ function NotifySection({ view, lang, locale, take }) {
|
|
|
601
639
|
time(notify.quiet.from, (value) => {
|
|
602
640
|
void save({ quiet: { ...notify.quiet, from: value } });
|
|
603
641
|
}),
|
|
604
|
-
/* @__PURE__ */ (0,
|
|
642
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "mishu-hint", children: t.nTo }),
|
|
605
643
|
time(notify.quiet.to, (value) => {
|
|
606
644
|
void save({ quiet: { ...notify.quiet, to: value } });
|
|
607
645
|
})
|
|
608
646
|
] }),
|
|
609
|
-
/* @__PURE__ */ (0,
|
|
610
|
-
/* @__PURE__ */ (0,
|
|
647
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "mishu-hint", children: t.nZone(notify.timeZone || browserZone()) }),
|
|
648
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h3", { children: t.nChannels }),
|
|
611
649
|
view.notify.channels.map((channel) => {
|
|
612
650
|
const result = tested[channel.id];
|
|
613
651
|
const feishu = channel.id === "feishu";
|
|
614
|
-
return /* @__PURE__ */ (0,
|
|
615
|
-
|
|
616
|
-
|
|
652
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
653
|
+
Fold,
|
|
654
|
+
{
|
|
655
|
+
id: `channel-${channel.id}`,
|
|
656
|
+
title: feishu ? t.nFeishu : t.nDesktop,
|
|
657
|
+
aside: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { className: "mishu-check mishu-check-inline", title: channel.available ? void 0 : channel.why, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
617
658
|
"input",
|
|
618
659
|
{
|
|
619
660
|
type: "checkbox",
|
|
@@ -623,24 +664,26 @@ function NotifySection({ view, lang, locale, take }) {
|
|
|
623
664
|
void save({ channels: { ...notify.channels, [channel.id]: e.target.checked } });
|
|
624
665
|
}
|
|
625
666
|
}
|
|
626
|
-
),
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
667
|
+
) }),
|
|
668
|
+
children: [
|
|
669
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: `mishu-card-note ${channel.available ? "" : "mishu-warn"}`, children: channel.available ? feishu ? t.nFeishuOn : t.nDesktopOn : channel.why }),
|
|
670
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mishu-actions", children: [
|
|
671
|
+
channel.available ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => {
|
|
672
|
+
void test(channel.id);
|
|
673
|
+
}, children: t.nTest }) : null,
|
|
674
|
+
feishu ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: view.notify.feishu.configured ? "mishu-btn" : "mishu-btn primary", onClick: () => setFeishuOpen(true), children: view.notify.feishu.configured ? t.nFeishuChange : t.nFeishuConnect }) : null,
|
|
675
|
+
feishu && view.notify.feishu.configured ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", onClick: () => {
|
|
676
|
+
if (window.confirm(t.nFeishuRemoveConfirm)) void settingsApi.deleteFeishu(locale()).then((r) => take(r));
|
|
677
|
+
}, children: t.nFeishuRemove }) : null,
|
|
678
|
+
result === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: result.ok ? "mishu-hint" : "mishu-hint mishu-danger", children: result.text })
|
|
679
|
+
] })
|
|
680
|
+
]
|
|
681
|
+
},
|
|
682
|
+
channel.id
|
|
683
|
+
);
|
|
641
684
|
}),
|
|
642
|
-
last === null ? null : /* @__PURE__ */ (0,
|
|
643
|
-
feishuOpen ? /* @__PURE__ */ (0,
|
|
685
|
+
last === null ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "mishu-hint", children: t.nLast(new Date(last.at).toLocaleString(), last.kind, last.results) }),
|
|
686
|
+
feishuOpen ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FeishuDialog, { lang, locale, onDone: (next) => {
|
|
644
687
|
setFeishuOpen(false);
|
|
645
688
|
if (next !== void 0) take({ ok: true, view: next }, t.nFeishuSaved);
|
|
646
689
|
} }) : null
|
|
@@ -648,10 +691,10 @@ function NotifySection({ view, lang, locale, take }) {
|
|
|
648
691
|
}
|
|
649
692
|
function FeishuDialog({ lang, locale, onDone }) {
|
|
650
693
|
const t = TEXT[lang];
|
|
651
|
-
const [webhook, setWebhook] = (0,
|
|
652
|
-
const [secret, setSecret] = (0,
|
|
653
|
-
const [busy, setBusy] = (0,
|
|
654
|
-
const [error, setError] = (0,
|
|
694
|
+
const [webhook, setWebhook] = (0, import_react4.useState)("");
|
|
695
|
+
const [secret, setSecret] = (0, import_react4.useState)("");
|
|
696
|
+
const [busy, setBusy] = (0, import_react4.useState)(false);
|
|
697
|
+
const [error, setError] = (0, import_react4.useState)();
|
|
655
698
|
const connect = async () => {
|
|
656
699
|
setBusy(true);
|
|
657
700
|
setError(void 0);
|
|
@@ -660,46 +703,46 @@ function FeishuDialog({ lang, locale, onDone }) {
|
|
|
660
703
|
if (r.ok) onDone(r.view);
|
|
661
704
|
else setError(r.message);
|
|
662
705
|
};
|
|
663
|
-
return /* @__PURE__ */ (0,
|
|
664
|
-
/* @__PURE__ */ (0,
|
|
665
|
-
/* @__PURE__ */ (0,
|
|
706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Modal, { title: t.nFeishuConnect, onClose: () => onDone(), children: [
|
|
707
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mishu-steps", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("ol", { children: t.nFeishuSteps.map((step, i) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", { children: step }, i)) }) }),
|
|
708
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mishu-field", children: [
|
|
666
709
|
t.nWebhook,
|
|
667
|
-
/* @__PURE__ */ (0,
|
|
710
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { value: webhook, autoComplete: "off", spellCheck: false, placeholder: "https://open.feishu.cn/open-apis/bot/v2/hook/\u2026", onChange: (e) => {
|
|
668
711
|
setWebhook(e.target.value);
|
|
669
712
|
setError(void 0);
|
|
670
713
|
} })
|
|
671
714
|
] }),
|
|
672
|
-
/* @__PURE__ */ (0,
|
|
715
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mishu-field", children: [
|
|
673
716
|
t.nSecret,
|
|
674
|
-
/* @__PURE__ */ (0,
|
|
717
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "password", value: secret, autoComplete: "off", spellCheck: false, onChange: (e) => {
|
|
675
718
|
setSecret(e.target.value);
|
|
676
719
|
setError(void 0);
|
|
677
720
|
} })
|
|
678
721
|
] }),
|
|
679
|
-
/* @__PURE__ */ (0,
|
|
680
|
-
error === void 0 ? null : /* @__PURE__ */ (0,
|
|
681
|
-
/* @__PURE__ */ (0,
|
|
682
|
-
/* @__PURE__ */ (0,
|
|
722
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "mishu-hint", children: t.nFeishuPrivacy }),
|
|
723
|
+
error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mishu-preview mishu-danger", children: error }),
|
|
724
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mishu-actions", children: [
|
|
725
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "mishu-btn primary", disabled: busy || webhook.trim() === "", onClick: () => {
|
|
683
726
|
void connect();
|
|
684
727
|
}, children: busy ? t.sTesting : t.nFeishuTry }),
|
|
685
|
-
/* @__PURE__ */ (0,
|
|
728
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => onDone(), children: t.sCancel })
|
|
686
729
|
] })
|
|
687
730
|
] });
|
|
688
731
|
}
|
|
689
732
|
|
|
690
733
|
// src/client/Settings.tsx
|
|
691
|
-
var
|
|
734
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
692
735
|
var CATEGORIES = ["document", "bill", "birthday", "renewal", "other"];
|
|
693
736
|
function MishuSettings({ lang, locale, openChat: openChat2 }) {
|
|
694
737
|
const t = TEXT[lang];
|
|
695
|
-
const [view, setView] = (0,
|
|
696
|
-
const [error, setError] = (0,
|
|
697
|
-
const [note, setNote] = (0,
|
|
698
|
-
const [lead, setLead] = (0,
|
|
699
|
-
const [githubTest, setGithubTest] = (0,
|
|
700
|
-
const [confirmOn, setConfirmOn] = (0,
|
|
701
|
-
const [pasting, setPasting] = (0,
|
|
702
|
-
const [editing, setEditing] = (0,
|
|
738
|
+
const [view, setView] = (0, import_react5.useState)();
|
|
739
|
+
const [error, setError] = (0, import_react5.useState)();
|
|
740
|
+
const [note, setNote] = (0, import_react5.useState)();
|
|
741
|
+
const [lead, setLead] = (0, import_react5.useState)({});
|
|
742
|
+
const [githubTest, setGithubTest] = (0, import_react5.useState)();
|
|
743
|
+
const [confirmOn, setConfirmOn] = (0, import_react5.useState)(false);
|
|
744
|
+
const [pasting, setPasting] = (0, import_react5.useState)(false);
|
|
745
|
+
const [editing, setEditing] = (0, import_react5.useState)();
|
|
703
746
|
const take = (result, saved) => {
|
|
704
747
|
if (result.ok) {
|
|
705
748
|
setView(result.view);
|
|
@@ -710,11 +753,11 @@ function MishuSettings({ lang, locale, openChat: openChat2 }) {
|
|
|
710
753
|
setError(result.message);
|
|
711
754
|
}
|
|
712
755
|
};
|
|
713
|
-
(0,
|
|
756
|
+
(0, import_react5.useEffect)(() => {
|
|
714
757
|
void settingsApi.load(locale()).then((r) => take(r));
|
|
715
758
|
}, [locale]);
|
|
716
759
|
if (view === void 0) {
|
|
717
|
-
return /* @__PURE__ */ (0,
|
|
760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-settings", children: error === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-empty", children: t.loading }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-error", children: [
|
|
718
761
|
t.failed,
|
|
719
762
|
error
|
|
720
763
|
] }) });
|
|
@@ -722,72 +765,71 @@ function MishuSettings({ lang, locale, openChat: openChat2 }) {
|
|
|
722
765
|
const save = async (settings) => take(await settingsApi.save(locale(), settings), t.sSaved);
|
|
723
766
|
const token = view.github.token;
|
|
724
767
|
const secretKind = t.secretKinds[view.secrets.kind] ?? view.secrets.kind;
|
|
725
|
-
const markRead = /* @__PURE__ */ (0,
|
|
726
|
-
/* @__PURE__ */ (0,
|
|
768
|
+
const markRead = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
769
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
727
770
|
t.sMarkRead,
|
|
728
|
-
/* @__PURE__ */ (0,
|
|
771
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("select", { value: view.settings.markRead, onChange: (e) => {
|
|
729
772
|
const value = e.target.value;
|
|
730
773
|
if (value === "on") setConfirmOn(true);
|
|
731
774
|
else void save({ markRead: value });
|
|
732
775
|
}, children: [
|
|
733
|
-
/* @__PURE__ */ (0,
|
|
734
|
-
/* @__PURE__ */ (0,
|
|
735
|
-
/* @__PURE__ */ (0,
|
|
776
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "off", children: t.sMarkOff }),
|
|
777
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "shadow", children: t.sMarkShadow }),
|
|
778
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "on", children: t.sMarkOn })
|
|
736
779
|
] })
|
|
737
780
|
] }),
|
|
738
|
-
confirmOn ? /* @__PURE__ */ (0,
|
|
739
|
-
/* @__PURE__ */ (0,
|
|
740
|
-
/* @__PURE__ */ (0,
|
|
741
|
-
/* @__PURE__ */ (0,
|
|
781
|
+
confirmOn ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-banner", children: [
|
|
782
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { children: t.sMarkConfirm }),
|
|
783
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-actions", children: [
|
|
784
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn primary", onClick: () => {
|
|
742
785
|
setConfirmOn(false);
|
|
743
786
|
void save({ markRead: "on" });
|
|
744
787
|
}, children: t.sConfirm }),
|
|
745
|
-
/* @__PURE__ */ (0,
|
|
788
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => setConfirmOn(false), children: t.sCancel })
|
|
746
789
|
] })
|
|
747
790
|
] }) : null
|
|
748
791
|
] });
|
|
749
|
-
return /* @__PURE__ */ (0,
|
|
750
|
-
error === void 0 ? null : /* @__PURE__ */ (0,
|
|
792
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FoldGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-settings", children: [
|
|
793
|
+
error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-error", children: [
|
|
751
794
|
t.failed,
|
|
752
795
|
error
|
|
753
796
|
] }),
|
|
754
|
-
note === void 0 ? null : /* @__PURE__ */ (0,
|
|
755
|
-
/* @__PURE__ */ (0,
|
|
756
|
-
/* @__PURE__ */ (0,
|
|
757
|
-
/* @__PURE__ */ (0,
|
|
758
|
-
/* @__PURE__ */ (0,
|
|
759
|
-
|
|
760
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("input", { type: "checkbox", checked: view.settings.githubEnabled, onChange: (e) => {
|
|
797
|
+
note === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-ok", children: note }),
|
|
798
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Fold, { id: "sources", className: "mishu-panel", title: t.bSources, children: [
|
|
799
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint", children: t.bSourcesHint }),
|
|
800
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t.sGithub }),
|
|
801
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-check", children: [
|
|
802
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "checkbox", checked: view.settings.githubEnabled, onChange: (e) => {
|
|
761
803
|
void save({ githubEnabled: e.target.checked });
|
|
762
804
|
} }),
|
|
763
805
|
t.sGithubOn
|
|
764
806
|
] }),
|
|
765
|
-
/* @__PURE__ */ (0,
|
|
766
|
-
/* @__PURE__ */ (0,
|
|
767
|
-
/* @__PURE__ */ (0,
|
|
807
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-row-explain", children: [
|
|
808
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "mishu-row-label", children: t.sToken }),
|
|
809
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: token.found ? "" : "mishu-danger", children: token.found ? token.from === "env" ? t.sTokenEnv(view.github.tokenEnv) : token.from === "keychain" ? t.sTokenKeychain : t.sTokenGh : token.text })
|
|
768
810
|
] }),
|
|
769
|
-
token.found ? /* @__PURE__ */ (0,
|
|
770
|
-
/* @__PURE__ */ (0,
|
|
811
|
+
token.found ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-actions", children: [
|
|
812
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => {
|
|
771
813
|
setGithubTest(t.sTesting);
|
|
772
814
|
void settingsApi.testGithub(locale()).then((r) => setGithubTest(r.ok ? t.sGithubOk(r.login) : `${t.failed}${r.message}`));
|
|
773
815
|
}, children: t.sTest }),
|
|
774
|
-
token.from === "env" || pasting ? null : /* @__PURE__ */ (0,
|
|
775
|
-
token.from === "keychain" ? /* @__PURE__ */ (0,
|
|
816
|
+
token.from === "env" || pasting ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => setPasting(true), children: t.sTokenReplace }),
|
|
817
|
+
token.from === "keychain" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", onClick: () => {
|
|
776
818
|
if (window.confirm(t.sTokenRemoveConfirm)) void settingsApi.deleteToken(locale()).then((r) => {
|
|
777
819
|
setGithubTest(void 0);
|
|
778
820
|
take(r);
|
|
779
821
|
});
|
|
780
822
|
}, children: t.sTokenRemove }) : null,
|
|
781
|
-
githubTest === void 0 ? null : /* @__PURE__ */ (0,
|
|
823
|
+
githubTest === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "mishu-hint", children: githubTest })
|
|
782
824
|
] }) : null,
|
|
783
|
-
!token.found || pasting ? /* @__PURE__ */ (0,
|
|
825
|
+
!token.found || pasting ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GithubConnect, { view, lang, locale, onSaved: (next, login) => {
|
|
784
826
|
setPasting(false);
|
|
785
827
|
setGithubTest(t.sTokenSaved(login));
|
|
786
828
|
take({ ok: true, view: next });
|
|
787
829
|
}, onCancel: token.found ? () => setPasting(false) : void 0 }) : null,
|
|
788
|
-
/* @__PURE__ */ (0,
|
|
789
|
-
/* @__PURE__ */ (0,
|
|
790
|
-
view.accounts.length === 0 ? /* @__PURE__ */ (0,
|
|
830
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h3", { children: t.sMail }),
|
|
831
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint", children: t.sMailPrivacy }),
|
|
832
|
+
view.accounts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-empty", children: t.sNoAccounts }) : view.accounts.map((account) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
791
833
|
AccountRow,
|
|
792
834
|
{
|
|
793
835
|
account,
|
|
@@ -800,8 +842,8 @@ function MishuSettings({ lang, locale, openChat: openChat2 }) {
|
|
|
800
842
|
},
|
|
801
843
|
account.id
|
|
802
844
|
)),
|
|
803
|
-
/* @__PURE__ */ (0,
|
|
804
|
-
editing === void 0 ? null : /* @__PURE__ */ (0,
|
|
845
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn mishu-add-toggle", onClick: () => setEditing({ preset: "custom", sinceDays: 14, enabled: true }), children: t.sAddAccount }),
|
|
846
|
+
editing === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
805
847
|
MailDialog,
|
|
806
848
|
{
|
|
807
849
|
draft: editing,
|
|
@@ -816,56 +858,50 @@ function MishuSettings({ lang, locale, openChat: openChat2 }) {
|
|
|
816
858
|
}
|
|
817
859
|
)
|
|
818
860
|
] }),
|
|
819
|
-
/* @__PURE__ */ (0,
|
|
820
|
-
/* @__PURE__ */ (0,
|
|
821
|
-
/* @__PURE__ */ (0,
|
|
822
|
-
/* @__PURE__ */ (0,
|
|
823
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "mishu-grid5", children: CATEGORIES.map((c) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mishu-field", children: [
|
|
861
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Fold, { id: "what", className: "mishu-panel", title: t.bWhat, children: [
|
|
862
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint", children: t.bUrgentRule }),
|
|
863
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-field", children: t.sLead }),
|
|
864
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-grid5", children: CATEGORIES.map((c) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
824
865
|
t.categories[c],
|
|
825
|
-
/* @__PURE__ */ (0,
|
|
866
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "number", min: 0, max: 366, value: lead[c] ?? 0, onChange: (e) => setLead({ ...lead, [c]: Number(e.target.value) }) })
|
|
826
867
|
] }, c)) }),
|
|
827
|
-
/* @__PURE__ */ (0,
|
|
868
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn primary", onClick: () => {
|
|
828
869
|
void save({ leadDays: lead });
|
|
829
870
|
}, children: t.sSave })
|
|
830
871
|
] }),
|
|
831
|
-
/* @__PURE__ */ (0,
|
|
832
|
-
|
|
833
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(NotifySection, { view, lang, locale, take })
|
|
834
|
-
] }),
|
|
835
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("section", { className: "mishu-panel", children: [
|
|
836
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("h2", { children: t.bDo }),
|
|
872
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Fold, { id: "when", className: "mishu-panel", title: t.bWhen, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(NotifySection, { view, lang, locale, take }) }),
|
|
873
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Fold, { id: "do", className: "mishu-panel", title: t.bDo, children: [
|
|
837
874
|
markRead,
|
|
838
|
-
/* @__PURE__ */ (0,
|
|
875
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint", children: t.bMailReadOnly })
|
|
839
876
|
] }),
|
|
840
|
-
/* @__PURE__ */ (0,
|
|
841
|
-
/* @__PURE__ */ (0,
|
|
842
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("label", { className: "mishu-field", children: [
|
|
877
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Fold, { id: "general", className: "mishu-panel", title: t.sGeneral, children: [
|
|
878
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
843
879
|
t.sLanguage,
|
|
844
|
-
/* @__PURE__ */ (0,
|
|
880
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("select", { value: view.settings.language, onChange: (e) => {
|
|
845
881
|
void save({ language: e.target.value });
|
|
846
882
|
}, children: [
|
|
847
|
-
/* @__PURE__ */ (0,
|
|
848
|
-
/* @__PURE__ */ (0,
|
|
849
|
-
/* @__PURE__ */ (0,
|
|
883
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "auto", children: t.sLanguageAuto }),
|
|
884
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "zh", children: "\u4E2D\u6587" }),
|
|
885
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "en", children: "English" })
|
|
850
886
|
] })
|
|
851
887
|
] }),
|
|
852
|
-
/* @__PURE__ */ (0,
|
|
888
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: view.secrets.available && view.secrets.file === void 0 ? "mishu-hint" : "mishu-hint mishu-warn", children: !view.secrets.available ? t.sSecretsNone(view.secrets.why ?? secretKind) : view.secrets.file !== void 0 ? t.sSecretsFile(view.secrets.file.path, view.secrets.file.why) : t.sSecretsAt(secretKind) })
|
|
853
889
|
] })
|
|
854
|
-
] });
|
|
890
|
+
] }) });
|
|
855
891
|
}
|
|
856
892
|
function GithubConnect({ view, lang, locale, onSaved, onCancel }) {
|
|
857
893
|
const t = TEXT[lang];
|
|
858
|
-
const [signingIn, setSigningIn] = (0,
|
|
859
|
-
const [paste, setPaste] = (0,
|
|
860
|
-
if (!view.github.deviceLogin) return /* @__PURE__ */ (0,
|
|
861
|
-
return /* @__PURE__ */ (0,
|
|
862
|
-
/* @__PURE__ */ (0,
|
|
863
|
-
/* @__PURE__ */ (0,
|
|
864
|
-
paste ? null : /* @__PURE__ */ (0,
|
|
865
|
-
onCancel === void 0 ? null : /* @__PURE__ */ (0,
|
|
894
|
+
const [signingIn, setSigningIn] = (0, import_react5.useState)(false);
|
|
895
|
+
const [paste, setPaste] = (0, import_react5.useState)(!view.github.deviceLogin);
|
|
896
|
+
if (!view.github.deviceLogin) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TokenForm, { view, lang, locale, onSaved, onCancel });
|
|
897
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
898
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-actions", children: [
|
|
899
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn primary", onClick: () => setSigningIn(true), children: t.gLogin }),
|
|
900
|
+
paste ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", onClick: () => setPaste(true), children: t.gPasteInstead }),
|
|
901
|
+
onCancel === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: onCancel, children: t.sCancel })
|
|
866
902
|
] }),
|
|
867
|
-
paste ? /* @__PURE__ */ (0,
|
|
868
|
-
signingIn ? /* @__PURE__ */ (0,
|
|
903
|
+
paste ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TokenForm, { view, lang, locale, onSaved, onCancel: void 0 }) : null,
|
|
904
|
+
signingIn ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(GithubLoginDialog, { lang, locale, onClose: () => setSigningIn(false), onSaved: (next, login) => {
|
|
869
905
|
setSigningIn(false);
|
|
870
906
|
onSaved(next, login);
|
|
871
907
|
} }) : null
|
|
@@ -873,12 +909,12 @@ function GithubConnect({ view, lang, locale, onSaved, onCancel }) {
|
|
|
873
909
|
}
|
|
874
910
|
function GithubLoginDialog({ lang, locale, onClose, onSaved }) {
|
|
875
911
|
const t = TEXT[lang];
|
|
876
|
-
const [login, setLogin] = (0,
|
|
877
|
-
const [error, setError] = (0,
|
|
878
|
-
const [copied, setCopied] = (0,
|
|
879
|
-
const [attempt, setAttempt] = (0,
|
|
880
|
-
const saved = (0,
|
|
881
|
-
(0,
|
|
912
|
+
const [login, setLogin] = (0, import_react5.useState)();
|
|
913
|
+
const [error, setError] = (0, import_react5.useState)();
|
|
914
|
+
const [copied, setCopied] = (0, import_react5.useState)(false);
|
|
915
|
+
const [attempt, setAttempt] = (0, import_react5.useState)(0);
|
|
916
|
+
const saved = (0, import_react5.useRef)(void 0);
|
|
917
|
+
(0, import_react5.useEffect)(() => {
|
|
882
918
|
let alive = true;
|
|
883
919
|
let timer;
|
|
884
920
|
setLogin(void 0);
|
|
@@ -922,42 +958,42 @@ function GithubLoginDialog({ lang, locale, onClose, onSaved }) {
|
|
|
922
958
|
const copy2 = (code) => {
|
|
923
959
|
void navigator.clipboard?.writeText(code).then(() => setCopied(true), () => setCopied(false));
|
|
924
960
|
};
|
|
925
|
-
return /* @__PURE__ */ (0,
|
|
926
|
-
/* @__PURE__ */ (0,
|
|
927
|
-
/* @__PURE__ */ (0,
|
|
928
|
-
] }) : login === void 0 || login.state === "idle" ? /* @__PURE__ */ (0,
|
|
929
|
-
/* @__PURE__ */ (0,
|
|
930
|
-
/* @__PURE__ */ (0,
|
|
931
|
-
/* @__PURE__ */ (0,
|
|
932
|
-
/* @__PURE__ */ (0,
|
|
961
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Modal, { title: t.gLogin, onClose: close, children: error !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
962
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-preview mishu-danger", children: error }),
|
|
963
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-actions", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: close, children: t.gClose }) })
|
|
964
|
+
] }) : login === void 0 || login.state === "idle" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint", children: t.gStarting }) : login.state === "waiting" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
965
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-field", children: t.gStep1 }),
|
|
966
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-code-row", children: [
|
|
967
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("code", { className: "mishu-code", children: login.userCode }),
|
|
968
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => copy2(login.userCode), children: copied ? t.gCopied : t.gCopy })
|
|
933
969
|
] }),
|
|
934
|
-
/* @__PURE__ */ (0,
|
|
935
|
-
/* @__PURE__ */ (0,
|
|
936
|
-
/* @__PURE__ */ (0,
|
|
937
|
-
/* @__PURE__ */ (0,
|
|
970
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-field", children: t.gStep2 }),
|
|
971
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-actions", children: [
|
|
972
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn primary", onClick: () => window.open(login.verificationUri, "_blank", "noopener"), children: t.gOpen }),
|
|
973
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "mishu-hint", children: t.gWaiting })
|
|
938
974
|
] }),
|
|
939
|
-
/* @__PURE__ */ (0,
|
|
940
|
-
] }) : login.state === "done" ? /* @__PURE__ */ (0,
|
|
941
|
-
/* @__PURE__ */ (0,
|
|
942
|
-
/* @__PURE__ */ (0,
|
|
943
|
-
] }) : /* @__PURE__ */ (0,
|
|
944
|
-
/* @__PURE__ */ (0,
|
|
945
|
-
/* @__PURE__ */ (0,
|
|
946
|
-
/* @__PURE__ */ (0,
|
|
975
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint", children: t.gScopes })
|
|
976
|
+
] }) : login.state === "done" ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
977
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-ok", children: t.gDone(login.login) }),
|
|
978
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-actions", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn primary", onClick: close, children: t.gClose }) })
|
|
979
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
980
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-preview mishu-danger", children: login.message }),
|
|
981
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-actions", children: [
|
|
982
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn primary", onClick: () => {
|
|
947
983
|
setCopied(false);
|
|
948
984
|
setAttempt(attempt + 1);
|
|
949
985
|
}, children: t.gRetry }),
|
|
950
|
-
/* @__PURE__ */ (0,
|
|
986
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: close, children: t.gClose })
|
|
951
987
|
] })
|
|
952
988
|
] }) });
|
|
953
989
|
}
|
|
954
990
|
function TokenForm({ view, lang, locale, onSaved, onCancel }) {
|
|
955
991
|
const t = TEXT[lang];
|
|
956
|
-
const [token, setToken] = (0,
|
|
957
|
-
const [busy, setBusy] = (0,
|
|
958
|
-
const [message, setMessage] = (0,
|
|
992
|
+
const [token, setToken] = (0, import_react5.useState)("");
|
|
993
|
+
const [busy, setBusy] = (0, import_react5.useState)(false);
|
|
994
|
+
const [message, setMessage] = (0, import_react5.useState)();
|
|
959
995
|
if (!view.secrets.available) {
|
|
960
|
-
return /* @__PURE__ */ (0,
|
|
996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint mishu-warn", children: t.sTokenNoKeychain(view.github.tokenEnv, view.secrets.why ?? "") });
|
|
961
997
|
}
|
|
962
998
|
const save = async () => {
|
|
963
999
|
setBusy(true);
|
|
@@ -971,58 +1007,54 @@ function TokenForm({ view, lang, locale, onSaved, onCancel }) {
|
|
|
971
1007
|
setMessage(r.message);
|
|
972
1008
|
}
|
|
973
1009
|
};
|
|
974
|
-
return /* @__PURE__ */ (0,
|
|
975
|
-
/* @__PURE__ */ (0,
|
|
1010
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-add", children: [
|
|
1011
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
976
1012
|
t.sTokenPaste,
|
|
977
|
-
/* @__PURE__ */ (0,
|
|
1013
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "password", value: token, autoComplete: "off", spellCheck: false, placeholder: "ghp_\u2026", onChange: (e) => {
|
|
978
1014
|
setToken(e.target.value);
|
|
979
1015
|
setMessage(void 0);
|
|
980
1016
|
} })
|
|
981
1017
|
] }),
|
|
982
|
-
/* @__PURE__ */ (0,
|
|
983
|
-
message === void 0 ? null : /* @__PURE__ */ (0,
|
|
984
|
-
/* @__PURE__ */ (0,
|
|
985
|
-
/* @__PURE__ */ (0,
|
|
986
|
-
/* @__PURE__ */ (0,
|
|
1018
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint", children: t.sTokenHow }),
|
|
1019
|
+
message === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-preview mishu-danger", children: message }),
|
|
1020
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-actions", children: [
|
|
1021
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => window.open(view.github.newTokenUrl, "_blank", "noopener"), children: t.sTokenNew }),
|
|
1022
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn primary", disabled: busy || token.trim() === "", onClick: () => {
|
|
987
1023
|
void save();
|
|
988
1024
|
}, children: busy ? t.sTesting : t.sTokenSave }),
|
|
989
|
-
onCancel === void 0 ? null : /* @__PURE__ */ (0,
|
|
1025
|
+
onCancel === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: onCancel, children: t.sCancel })
|
|
990
1026
|
] })
|
|
991
1027
|
] });
|
|
992
1028
|
}
|
|
993
1029
|
function AccountRow({ account, secretsOk, lang, locale, openChat: openChat2, onEdit, onView }) {
|
|
994
1030
|
const t = TEXT[lang];
|
|
995
|
-
const [busy, setBusy] = (0,
|
|
1031
|
+
const [busy, setBusy] = (0, import_react5.useState)(false);
|
|
996
1032
|
const report = account.report;
|
|
997
1033
|
const status = !account.hasPassword ? secretsOk ? t.sNoPassword : t.sEnvHint(account.envName) : report === null ? t.sNeverChecked : report.error !== void 0 ? report.error[lang] : lang === "zh" ? `${new Date(report.at).toLocaleString()} \u6536\u4FE1\uFF0C${report.messages} \u5C01\u672A\u8BFB` : `checked ${new Date(report.at).toLocaleString()}, ${report.messages} unread`;
|
|
998
1034
|
const failed = !account.hasPassword || report?.error !== void 0;
|
|
999
|
-
return /* @__PURE__ */ (0,
|
|
1000
|
-
/* @__PURE__ */ (0,
|
|
1001
|
-
account.label,
|
|
1002
|
-
account.enabled ? "" : ` (${lang === "zh" ? "\u5DF2\u505C\u7528" : "disabled"})`
|
|
1003
|
-
] }),
|
|
1004
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "mishu-card-meta", children: [
|
|
1035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Fold, { id: `account-${account.id}`, title: `${account.label}${account.enabled ? "" : ` (${lang === "zh" ? "\u5DF2\u505C\u7528" : "disabled"})`}`, children: [
|
|
1036
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-card-meta", children: [
|
|
1005
1037
|
account.address,
|
|
1006
1038
|
" \xB7 ",
|
|
1007
1039
|
account.host,
|
|
1008
1040
|
":",
|
|
1009
1041
|
account.port
|
|
1010
1042
|
] }),
|
|
1011
|
-
account.mismatch === null ? null : /* @__PURE__ */ (0,
|
|
1012
|
-
/* @__PURE__ */ (0,
|
|
1043
|
+
account.mismatch === null ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "mishu-card-note mishu-warn", children: account.mismatch }),
|
|
1044
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `mishu-card-note ${failed ? "mishu-danger" : ""}`, children: [
|
|
1013
1045
|
status,
|
|
1014
|
-
account.hasPassword && report?.error !== void 0 ? /* @__PURE__ */ (0,
|
|
1046
|
+
account.hasPassword && report?.error !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AskAI, { topic: { kind: "mail-error", accountId: account.id }, lang, locale, openChat: openChat2, compact: true }) : null
|
|
1015
1047
|
] }),
|
|
1016
|
-
/* @__PURE__ */ (0,
|
|
1017
|
-
/* @__PURE__ */ (0,
|
|
1048
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-actions", children: [
|
|
1049
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", disabled: busy || !account.hasPassword, onClick: () => {
|
|
1018
1050
|
setBusy(true);
|
|
1019
1051
|
void settingsApi.syncMail(locale(), account.id).then((r) => {
|
|
1020
1052
|
setBusy(false);
|
|
1021
1053
|
onView(r);
|
|
1022
1054
|
});
|
|
1023
1055
|
}, children: busy ? t.sTesting : t.sCheckNow }),
|
|
1024
|
-
/* @__PURE__ */ (0,
|
|
1025
|
-
/* @__PURE__ */ (0,
|
|
1056
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: account.hasPassword && account.mismatch === null ? "mishu-btn" : "mishu-btn primary", onClick: onEdit, children: t.sEdit }),
|
|
1057
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", onClick: () => {
|
|
1026
1058
|
if (window.confirm(t.sDeleteConfirm)) void settingsApi.deleteMail(locale(), account.id).then(onView);
|
|
1027
1059
|
}, children: t.sDelete })
|
|
1028
1060
|
] })
|
|
@@ -1031,12 +1063,12 @@ function AccountRow({ account, secretsOk, lang, locale, openChat: openChat2, onE
|
|
|
1031
1063
|
function MailDialog({ draft, view, lang, locale, openChat: openChat2, onDone }) {
|
|
1032
1064
|
const t = TEXT[lang];
|
|
1033
1065
|
const existing = draft.id !== void 0;
|
|
1034
|
-
const [account, setAccount] = (0,
|
|
1035
|
-
const [picked, setPicked] = (0,
|
|
1036
|
-
const [password, setPassword] = (0,
|
|
1037
|
-
const [message, setMessage] = (0,
|
|
1038
|
-
const [failedTest, setFailedTest] = (0,
|
|
1039
|
-
const [busy, setBusy] = (0,
|
|
1066
|
+
const [account, setAccount] = (0, import_react5.useState)(draft);
|
|
1067
|
+
const [picked, setPicked] = (0, import_react5.useState)(existing);
|
|
1068
|
+
const [password, setPassword] = (0, import_react5.useState)("");
|
|
1069
|
+
const [message, setMessage] = (0, import_react5.useState)();
|
|
1070
|
+
const [failedTest, setFailedTest] = (0, import_react5.useState)(false);
|
|
1071
|
+
const [busy, setBusy] = (0, import_react5.useState)(false);
|
|
1040
1072
|
const preset = view.presets.find((p) => p.id === account.preset) ?? view.presets[view.presets.length - 1];
|
|
1041
1073
|
const custom = preset.id === "custom";
|
|
1042
1074
|
const set = (patch) => {
|
|
@@ -1069,93 +1101,93 @@ function MailDialog({ draft, view, lang, locale, openChat: openChat2, onDone })
|
|
|
1069
1101
|
setMessage({ ok: false, text: r.message });
|
|
1070
1102
|
}
|
|
1071
1103
|
};
|
|
1072
|
-
return /* @__PURE__ */ (0,
|
|
1073
|
-
/* @__PURE__ */ (0,
|
|
1104
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(Modal, { title: existing ? t.mTitleEdit : t.mTitleAdd, onClose: () => onDone(), children: [
|
|
1105
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
1074
1106
|
t.sAddress,
|
|
1075
|
-
/* @__PURE__ */ (0,
|
|
1107
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "email", value: account.address ?? "", autoComplete: "off", autoFocus: !existing, onChange: (e) => setAddress(e.target.value) })
|
|
1076
1108
|
] }),
|
|
1077
|
-
/* @__PURE__ */ (0,
|
|
1109
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
1078
1110
|
t.sProvider,
|
|
1079
|
-
/* @__PURE__ */ (0,
|
|
1111
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("select", { value: account.preset, onChange: (e) => {
|
|
1080
1112
|
setPicked(true);
|
|
1081
1113
|
set({ preset: e.target.value });
|
|
1082
|
-
}, children: view.presets.map((p) => /* @__PURE__ */ (0,
|
|
1114
|
+
}, children: view.presets.map((p) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: p.id, children: p.label }, p.id)) })
|
|
1083
1115
|
] }),
|
|
1084
|
-
/* @__PURE__ */ (0,
|
|
1085
|
-
preset.steps.length === 0 ? preset.howTo : /* @__PURE__ */ (0,
|
|
1116
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `mishu-steps${preset.supported ? "" : " mishu-danger"}${failedTest ? " attention" : ""}`, children: [
|
|
1117
|
+
preset.steps.length === 0 ? preset.howTo : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("ol", { children: preset.steps.map((step, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("li", { children: [
|
|
1086
1118
|
step.text,
|
|
1087
|
-
step.link === void 0 ? null : /* @__PURE__ */ (0,
|
|
1119
|
+
step.link === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
|
|
1088
1120
|
" ",
|
|
1089
|
-
/* @__PURE__ */ (0,
|
|
1121
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => window.open(step.link.url, "_blank", "noopener"), children: step.link.label })
|
|
1090
1122
|
] })
|
|
1091
1123
|
] }, i)) }),
|
|
1092
|
-
preset.supported ? /* @__PURE__ */ (0,
|
|
1124
|
+
preset.supported ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-steps-help", children: [
|
|
1093
1125
|
t.mStepsHelp,
|
|
1094
|
-
/* @__PURE__ */ (0,
|
|
1126
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AskAI, { topic: { kind: "mail-setup", preset: preset.id }, lang, locale, openChat: openChat2, compact: true })
|
|
1095
1127
|
] }) : null
|
|
1096
1128
|
] }),
|
|
1097
|
-
/* @__PURE__ */ (0,
|
|
1129
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
1098
1130
|
t.sPassword,
|
|
1099
|
-
/* @__PURE__ */ (0,
|
|
1131
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "password", value: password, autoComplete: "new-password", placeholder: existing && view.secrets.available ? t.sPasswordKeep : "", onChange: (e) => {
|
|
1100
1132
|
setPassword(e.target.value);
|
|
1101
1133
|
setMessage(void 0);
|
|
1102
1134
|
setFailedTest(false);
|
|
1103
1135
|
} })
|
|
1104
1136
|
] }),
|
|
1105
|
-
lengthOff ? /* @__PURE__ */ (0,
|
|
1106
|
-
view.secrets.available ? null : /* @__PURE__ */ (0,
|
|
1107
|
-
custom ? /* @__PURE__ */ (0,
|
|
1108
|
-
/* @__PURE__ */ (0,
|
|
1137
|
+
lengthOff ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint mishu-warn", children: t.mLength(preset.label, preset.passwordLength, typed.length) }) : null,
|
|
1138
|
+
view.secrets.available ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "mishu-hint mishu-warn", children: t.sPasswordTestOnly }),
|
|
1139
|
+
custom ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-row", children: [
|
|
1140
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
1109
1141
|
t.sHost,
|
|
1110
|
-
/* @__PURE__ */ (0,
|
|
1142
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { value: account.host ?? "", placeholder: "imap.example.com", onChange: (e) => set({ host: e.target.value }) })
|
|
1111
1143
|
] }),
|
|
1112
|
-
/* @__PURE__ */ (0,
|
|
1144
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
1113
1145
|
t.sPort,
|
|
1114
|
-
/* @__PURE__ */ (0,
|
|
1146
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "number", value: account.port ?? 993, onChange: (e) => set({ port: Number(e.target.value) }) })
|
|
1115
1147
|
] })
|
|
1116
1148
|
] }) : null,
|
|
1117
|
-
/* @__PURE__ */ (0,
|
|
1118
|
-
/* @__PURE__ */ (0,
|
|
1119
|
-
/* @__PURE__ */ (0,
|
|
1120
|
-
/* @__PURE__ */ (0,
|
|
1149
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("details", { className: "mishu-more", children: [
|
|
1150
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("summary", { children: t.mMore }),
|
|
1151
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-row", children: [
|
|
1152
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
1121
1153
|
t.sLabel,
|
|
1122
|
-
/* @__PURE__ */ (0,
|
|
1154
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { value: account.label ?? "", placeholder: account.address ?? "", onChange: (e) => set({ label: e.target.value }) })
|
|
1123
1155
|
] }),
|
|
1124
|
-
/* @__PURE__ */ (0,
|
|
1156
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
1125
1157
|
t.sUser,
|
|
1126
|
-
/* @__PURE__ */ (0,
|
|
1158
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { value: account.user ?? "", placeholder: account.address ?? "", autoComplete: "off", onChange: (e) => set({ user: e.target.value }) })
|
|
1127
1159
|
] })
|
|
1128
1160
|
] }),
|
|
1129
|
-
/* @__PURE__ */ (0,
|
|
1130
|
-
/* @__PURE__ */ (0,
|
|
1161
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-row", children: [
|
|
1162
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-field", children: [
|
|
1131
1163
|
t.sSince,
|
|
1132
|
-
/* @__PURE__ */ (0,
|
|
1164
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "number", min: 1, max: 90, value: account.sinceDays ?? 14, onChange: (e) => set({ sinceDays: Number(e.target.value) }) })
|
|
1133
1165
|
] }),
|
|
1134
|
-
/* @__PURE__ */ (0,
|
|
1135
|
-
/* @__PURE__ */ (0,
|
|
1166
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { className: "mishu-check", children: [
|
|
1167
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("input", { type: "checkbox", checked: account.enabled !== false, onChange: (e) => set({ enabled: e.target.checked }) }),
|
|
1136
1168
|
t.sEnabled
|
|
1137
1169
|
] })
|
|
1138
1170
|
] })
|
|
1139
1171
|
] }),
|
|
1140
|
-
message === void 0 ? null : /* @__PURE__ */ (0,
|
|
1172
|
+
message === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `mishu-preview ${message.ok ? "" : "mishu-danger"}`, children: [
|
|
1141
1173
|
message.text,
|
|
1142
|
-
message.ok || !preset.supported ? null : /* @__PURE__ */ (0,
|
|
1174
|
+
message.ok || !preset.supported ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AskAI, { topic: { kind: "mail-setup", preset: preset.id, error: message.text }, lang, locale, openChat: openChat2, compact: true })
|
|
1143
1175
|
] }),
|
|
1144
|
-
/* @__PURE__ */ (0,
|
|
1145
|
-
/* @__PURE__ */ (0,
|
|
1176
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "mishu-actions", children: [
|
|
1177
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn primary", disabled: busy || !preset.supported || (account.address ?? "") === "", onClick: () => {
|
|
1146
1178
|
void testAndSave();
|
|
1147
1179
|
}, children: busy ? t.sTesting : t.mTestSave }),
|
|
1148
|
-
failedTest ? /* @__PURE__ */ (0,
|
|
1180
|
+
failedTest ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn mishu-btn-quiet", disabled: busy, onClick: () => {
|
|
1149
1181
|
setBusy(true);
|
|
1150
1182
|
void save();
|
|
1151
1183
|
}, children: t.mSaveAnyway }) : null,
|
|
1152
|
-
/* @__PURE__ */ (0,
|
|
1184
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => onDone(), children: t.sCancel })
|
|
1153
1185
|
] })
|
|
1154
1186
|
] });
|
|
1155
1187
|
}
|
|
1156
1188
|
|
|
1157
1189
|
// src/client/Board.tsx
|
|
1158
|
-
var
|
|
1190
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
1159
1191
|
var SOURCE_KEY = "dsh-mishu.source";
|
|
1160
1192
|
function loadSource() {
|
|
1161
1193
|
try {
|
|
@@ -1191,15 +1223,15 @@ function saveWidths(widths) {
|
|
|
1191
1223
|
}
|
|
1192
1224
|
}
|
|
1193
1225
|
function MishuBoard({ locale, openChat: openChat2 }) {
|
|
1194
|
-
const [board, setBoard] = (0,
|
|
1195
|
-
const [error, setError] = (0,
|
|
1196
|
-
const [busy, setBusy] = (0,
|
|
1197
|
-
const [syncing, setSyncing] = (0,
|
|
1198
|
-
const [dropOn, setDropOn] = (0,
|
|
1199
|
-
const [widths, setWidths] = (0,
|
|
1200
|
-
const [tab, setTab] = (0,
|
|
1201
|
-
const [openCard, setOpenCard] = (0,
|
|
1202
|
-
const [source, setSourceState] = (0,
|
|
1226
|
+
const [board, setBoard] = (0, import_react6.useState)();
|
|
1227
|
+
const [error, setError] = (0, import_react6.useState)();
|
|
1228
|
+
const [busy, setBusy] = (0, import_react6.useState)(false);
|
|
1229
|
+
const [syncing, setSyncing] = (0, import_react6.useState)(false);
|
|
1230
|
+
const [dropOn, setDropOn] = (0, import_react6.useState)();
|
|
1231
|
+
const [widths, setWidths] = (0, import_react6.useState)(loadWidths);
|
|
1232
|
+
const [tab, setTab] = (0, import_react6.useState)("board");
|
|
1233
|
+
const [openCard, setOpenCard] = (0, import_react6.useState)();
|
|
1234
|
+
const [source, setSourceState] = (0, import_react6.useState)(loadSource);
|
|
1203
1235
|
const setSource = (next) => {
|
|
1204
1236
|
setSourceState(next);
|
|
1205
1237
|
try {
|
|
@@ -1207,11 +1239,11 @@ function MishuBoard({ locale, openChat: openChat2 }) {
|
|
|
1207
1239
|
} catch {
|
|
1208
1240
|
}
|
|
1209
1241
|
};
|
|
1210
|
-
const dragged = (0,
|
|
1211
|
-
const columnsRef = (0,
|
|
1242
|
+
const dragged = (0, import_react6.useRef)(void 0);
|
|
1243
|
+
const columnsRef = (0, import_react6.useRef)(null);
|
|
1212
1244
|
const lang = board?.lang ?? uiLang(locale());
|
|
1213
1245
|
const t = TEXT[lang];
|
|
1214
|
-
const take = (0,
|
|
1246
|
+
const take = (0, import_react6.useCallback)((result) => {
|
|
1215
1247
|
if (result.ok) {
|
|
1216
1248
|
setBoard(result.board);
|
|
1217
1249
|
setError(void 0);
|
|
@@ -1219,8 +1251,8 @@ function MishuBoard({ locale, openChat: openChat2 }) {
|
|
|
1219
1251
|
setError(result.message);
|
|
1220
1252
|
}
|
|
1221
1253
|
}, []);
|
|
1222
|
-
const load = (0,
|
|
1223
|
-
(0,
|
|
1254
|
+
const load = (0, import_react6.useCallback)(() => mishuApi.board(locale()).then(take), [locale, take]);
|
|
1255
|
+
(0, import_react6.useEffect)(() => {
|
|
1224
1256
|
void load();
|
|
1225
1257
|
const timer = setInterval(() => {
|
|
1226
1258
|
void load();
|
|
@@ -1315,7 +1347,7 @@ function MishuBoard({ locale, openChat: openChat2 }) {
|
|
|
1315
1347
|
const key = cardKey(item);
|
|
1316
1348
|
setOpenCard((current) => current === key ? void 0 : key);
|
|
1317
1349
|
};
|
|
1318
|
-
const card = (item, column) => /* @__PURE__ */ (0,
|
|
1350
|
+
const card = (item, column) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1319
1351
|
Card,
|
|
1320
1352
|
{
|
|
1321
1353
|
item,
|
|
@@ -1341,12 +1373,12 @@ function MishuBoard({ locale, openChat: openChat2 }) {
|
|
|
1341
1373
|
cardKey(item)
|
|
1342
1374
|
);
|
|
1343
1375
|
if (board === void 0) {
|
|
1344
|
-
return /* @__PURE__ */ (0,
|
|
1345
|
-
/* @__PURE__ */ (0,
|
|
1346
|
-
/* @__PURE__ */ (0,
|
|
1347
|
-
/* @__PURE__ */ (0,
|
|
1376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-page", children: [
|
|
1377
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-head", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-title", children: [
|
|
1378
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: t.title }),
|
|
1379
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RestartButton, { lang, locale })
|
|
1348
1380
|
] }) }),
|
|
1349
|
-
error === void 0 ? /* @__PURE__ */ (0,
|
|
1381
|
+
error === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mishu-empty", children: t.loading }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-error", children: [
|
|
1350
1382
|
t.failed,
|
|
1351
1383
|
error
|
|
1352
1384
|
] })
|
|
@@ -1371,7 +1403,7 @@ function MishuBoard({ locale, openChat: openChat2 }) {
|
|
|
1371
1403
|
{ id: "manual", label: t.sourceManual }
|
|
1372
1404
|
];
|
|
1373
1405
|
const template = `minmax(0, ${widths[0]}fr) 10px minmax(0, ${widths[1]}fr) 10px minmax(0, ${widths[2]}fr)`;
|
|
1374
|
-
const divider = (index) => /* @__PURE__ */ (0,
|
|
1406
|
+
const divider = (index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1375
1407
|
"div",
|
|
1376
1408
|
{
|
|
1377
1409
|
className: "mishu-divider",
|
|
@@ -1382,107 +1414,107 @@ function MishuBoard({ locale, openChat: openChat2 }) {
|
|
|
1382
1414
|
onDoubleClick: resetWidths
|
|
1383
1415
|
}
|
|
1384
1416
|
);
|
|
1385
|
-
return /* @__PURE__ */ (0,
|
|
1386
|
-
/* @__PURE__ */ (0,
|
|
1387
|
-
/* @__PURE__ */ (0,
|
|
1388
|
-
/* @__PURE__ */ (0,
|
|
1389
|
-
/* @__PURE__ */ (0,
|
|
1390
|
-
/* @__PURE__ */ (0,
|
|
1391
|
-
/* @__PURE__ */ (0,
|
|
1417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-page", "data-mishu-board": "", children: [
|
|
1418
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-head", children: [
|
|
1419
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-title", children: [
|
|
1420
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: t.title }),
|
|
1421
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-tabs", role: "tablist", children: [
|
|
1422
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === "board", className: tab === "board" ? "active" : "", onClick: () => setTab("board"), children: t.tabBoard }),
|
|
1423
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", role: "tab", "aria-selected": tab === "settings", className: tab === "settings" ? "active" : "", onClick: () => setTab("settings"), children: t.tabSettings })
|
|
1392
1424
|
] }),
|
|
1393
|
-
/* @__PURE__ */ (0,
|
|
1425
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(RestartButton, { lang, locale })
|
|
1394
1426
|
] }),
|
|
1395
|
-
/* @__PURE__ */ (0,
|
|
1396
|
-
/* @__PURE__ */ (0,
|
|
1397
|
-
/* @__PURE__ */ (0,
|
|
1427
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-sources", children: [
|
|
1428
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1429
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: `mishu-dot ${board.sources.github.state}` }),
|
|
1398
1430
|
board.sources.github.text,
|
|
1399
|
-
board.sources.github.state === "error" ? /* @__PURE__ */ (0,
|
|
1431
|
+
board.sources.github.state === "error" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AskAI, { topic: { kind: "github-error" }, lang, locale, openChat: openChat2, compact: true }) : null
|
|
1400
1432
|
] }),
|
|
1401
|
-
board.sources.mail.map((m) => /* @__PURE__ */ (0,
|
|
1402
|
-
/* @__PURE__ */ (0,
|
|
1433
|
+
board.sources.mail.map((m) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("span", { children: [
|
|
1434
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("i", { className: `mishu-dot ${m.state}` }),
|
|
1403
1435
|
m.text,
|
|
1404
|
-
m.state === "error" ? /* @__PURE__ */ (0,
|
|
1436
|
+
m.state === "error" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AskAI, { topic: { kind: "mail-error", accountId: m.id }, lang, locale, openChat: openChat2, compact: true }) : null
|
|
1405
1437
|
] }, m.id)),
|
|
1406
|
-
/* @__PURE__ */ (0,
|
|
1438
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "mishu-btn", disabled: syncing, onClick: () => {
|
|
1407
1439
|
void sync();
|
|
1408
1440
|
}, children: syncing ? t.syncing : t.sync })
|
|
1409
1441
|
] })
|
|
1410
1442
|
] }),
|
|
1411
|
-
tab === "settings" ? /* @__PURE__ */ (0,
|
|
1412
|
-
tab === "settings" ? null : /* @__PURE__ */ (0,
|
|
1413
|
-
error === void 0 ? null : /* @__PURE__ */ (0,
|
|
1443
|
+
tab === "settings" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MishuSettings, { lang, locale, openChat: openChat2 }) : null,
|
|
1444
|
+
tab === "settings" ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1445
|
+
error === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-error", children: [
|
|
1414
1446
|
t.failed,
|
|
1415
1447
|
error
|
|
1416
1448
|
] }),
|
|
1417
|
-
/* @__PURE__ */ (0,
|
|
1449
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "mishu-summary", children: [
|
|
1418
1450
|
board.summary,
|
|
1419
1451
|
" ",
|
|
1420
|
-
/* @__PURE__ */ (0,
|
|
1452
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AskAI, { topic: { kind: "summary" }, lang, locale, openChat: openChat2, compact: true })
|
|
1421
1453
|
] }),
|
|
1422
|
-
/* @__PURE__ */ (0,
|
|
1423
|
-
/* @__PURE__ */ (0,
|
|
1424
|
-
/* @__PURE__ */ (0,
|
|
1425
|
-
/* @__PURE__ */ (0,
|
|
1454
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-metrics", children: [
|
|
1455
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-metric", children: [
|
|
1456
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-metric-label", children: t.metricHandle }),
|
|
1457
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-metric-value", children: [
|
|
1426
1458
|
metrics.handle,
|
|
1427
|
-
metrics.overdue > 0 ? /* @__PURE__ */ (0,
|
|
1459
|
+
metrics.overdue > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("small", { className: "mishu-danger", children: [
|
|
1428
1460
|
metrics.overdue,
|
|
1429
1461
|
" ",
|
|
1430
1462
|
t.metricOverdue
|
|
1431
1463
|
] }) : null
|
|
1432
1464
|
] })
|
|
1433
1465
|
] }),
|
|
1434
|
-
/* @__PURE__ */ (0,
|
|
1435
|
-
/* @__PURE__ */ (0,
|
|
1436
|
-
/* @__PURE__ */ (0,
|
|
1466
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-metric", children: [
|
|
1467
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-metric-label", children: t.metricSoon }),
|
|
1468
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-metric-value", children: metrics.dueSoon })
|
|
1437
1469
|
] }),
|
|
1438
|
-
/* @__PURE__ */ (0,
|
|
1439
|
-
/* @__PURE__ */ (0,
|
|
1440
|
-
/* @__PURE__ */ (0,
|
|
1470
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-metric", children: [
|
|
1471
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-metric-label", children: t.metricClosed }),
|
|
1472
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-metric-value", children: metrics.closedToday })
|
|
1441
1473
|
] }),
|
|
1442
|
-
/* @__PURE__ */ (0,
|
|
1443
|
-
/* @__PURE__ */ (0,
|
|
1444
|
-
/* @__PURE__ */ (0,
|
|
1474
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-metric", children: [
|
|
1475
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-metric-label", children: t.metricShadow }),
|
|
1476
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-metric-value", children: [
|
|
1445
1477
|
metrics.shadow,
|
|
1446
|
-
board.markRead === "shadow" ? /* @__PURE__ */ (0,
|
|
1478
|
+
board.markRead === "shadow" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("small", { className: "mishu-warn", children: t.shadowTag }) : null
|
|
1447
1479
|
] })
|
|
1448
1480
|
] })
|
|
1449
1481
|
] }),
|
|
1450
|
-
/* @__PURE__ */ (0,
|
|
1482
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-filters", role: "group", children: sources.map((s) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", "aria-pressed": source === s.id, className: `mishu-chip ${source === s.id ? "active" : ""}`, onClick: () => setSource(s.id), children: [
|
|
1451
1483
|
s.label,
|
|
1452
|
-
/* @__PURE__ */ (0,
|
|
1484
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: count(s.id) })
|
|
1453
1485
|
] }, s.id)) }),
|
|
1454
|
-
/* @__PURE__ */ (0,
|
|
1455
|
-
/* @__PURE__ */ (0,
|
|
1456
|
-
/* @__PURE__ */ (0,
|
|
1486
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-columns", ref: columnsRef, style: { ["--mishu-cols"]: template }, children: [
|
|
1487
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: `mishu-col ${dropOn === "handle" ? "drop" : ""}`, ...dropProps("handle"), "aria-label": t.handle, children: [
|
|
1488
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-col-head", children: [
|
|
1457
1489
|
t.handle,
|
|
1458
|
-
/* @__PURE__ */ (0,
|
|
1490
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: columns.handle.length })
|
|
1459
1491
|
] }),
|
|
1460
|
-
columns.handle.length === 0 ? /* @__PURE__ */ (0,
|
|
1492
|
+
columns.handle.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-empty", children: t.emptyHandle }) : columns.handle.map((item) => card(item, "handle"))
|
|
1461
1493
|
] }),
|
|
1462
1494
|
divider(0),
|
|
1463
|
-
/* @__PURE__ */ (0,
|
|
1464
|
-
/* @__PURE__ */ (0,
|
|
1495
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: `mishu-col ${dropOn === "remember" ? "drop" : ""}`, ...dropProps("remember"), "aria-label": t.remember, title: t.dropRemember, children: [
|
|
1496
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-col-head", children: [
|
|
1465
1497
|
t.remember,
|
|
1466
|
-
/* @__PURE__ */ (0,
|
|
1498
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: columns.remember.length })
|
|
1467
1499
|
] }),
|
|
1468
|
-
columns.remember.length === 0 ? /* @__PURE__ */ (0,
|
|
1469
|
-
/* @__PURE__ */ (0,
|
|
1500
|
+
columns.remember.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-empty", children: t.emptyRemember }) : columns.remember.map((item) => card(item, "remember")),
|
|
1501
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AddForm, { lang, locale, onAdded: (next) => setBoard(next) })
|
|
1470
1502
|
] }),
|
|
1471
1503
|
divider(1),
|
|
1472
|
-
/* @__PURE__ */ (0,
|
|
1473
|
-
/* @__PURE__ */ (0,
|
|
1504
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: `mishu-col ${dropOn === "done" ? "drop" : ""}`, ...dropProps("done"), "aria-label": t.done, title: t.dropDone, children: [
|
|
1505
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-col-head", children: [
|
|
1474
1506
|
t.done,
|
|
1475
|
-
/* @__PURE__ */ (0,
|
|
1507
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: columns.done.total })
|
|
1476
1508
|
] }),
|
|
1477
|
-
columns.done.groups.length === 0 ? /* @__PURE__ */ (0,
|
|
1478
|
-
/* @__PURE__ */ (0,
|
|
1509
|
+
columns.done.groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-empty", children: t.emptyDone }) : columns.done.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("details", { className: "mishu-group", children: [
|
|
1510
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("summary", { children: [
|
|
1479
1511
|
group.label,
|
|
1480
|
-
/* @__PURE__ */ (0,
|
|
1512
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: group.items.length })
|
|
1481
1513
|
] }),
|
|
1482
1514
|
group.items.map((item) => card(item, "done"))
|
|
1483
1515
|
] }, group.reason)),
|
|
1484
|
-
columns.done.total > 0 ? /* @__PURE__ */ (0,
|
|
1485
|
-
metrics.shadow > 0 ? /* @__PURE__ */ (0,
|
|
1516
|
+
columns.done.total > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mishu-hint", children: t.doneHint }) : null,
|
|
1517
|
+
metrics.shadow > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-banner", children: t.shadow(metrics.shadow) }) : null
|
|
1486
1518
|
] })
|
|
1487
1519
|
] })
|
|
1488
1520
|
] })
|
|
@@ -1490,10 +1522,10 @@ function MishuBoard({ locale, openChat: openChat2 }) {
|
|
|
1490
1522
|
}
|
|
1491
1523
|
function Card({ item, column, lang, locale, busy, label, openChat: openChat2, open, onToggle, onAct, onDragStart, onDragEnd }) {
|
|
1492
1524
|
const t = TEXT[lang];
|
|
1493
|
-
const [detail, setDetail] = (0,
|
|
1525
|
+
const [detail, setDetail] = (0, import_react6.useState)();
|
|
1494
1526
|
const explain = item.explain;
|
|
1495
1527
|
const compact = column === "done";
|
|
1496
|
-
(0,
|
|
1528
|
+
(0, import_react6.useEffect)(() => {
|
|
1497
1529
|
if (!open || item.target !== "matter" || detail !== void 0) return;
|
|
1498
1530
|
let alive = true;
|
|
1499
1531
|
void mishuApi.detail(locale(), item.id).then((r) => {
|
|
@@ -1503,11 +1535,11 @@ function Card({ item, column, lang, locale, busy, label, openChat: openChat2, op
|
|
|
1503
1535
|
alive = false;
|
|
1504
1536
|
};
|
|
1505
1537
|
}, [open, item.target, item.id, detail, locale]);
|
|
1506
|
-
const row = (name, text, className = "") => text === null || text === void 0 || text === "" ? null : /* @__PURE__ */ (0,
|
|
1507
|
-
/* @__PURE__ */ (0,
|
|
1508
|
-
/* @__PURE__ */ (0,
|
|
1538
|
+
const row = (name, text, className = "") => text === null || text === void 0 || text === "" ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: `mishu-row-explain ${className}`, children: [
|
|
1539
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "mishu-row-label", children: name }),
|
|
1540
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: text })
|
|
1509
1541
|
] });
|
|
1510
|
-
return /* @__PURE__ */ (0,
|
|
1542
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1511
1543
|
"div",
|
|
1512
1544
|
{
|
|
1513
1545
|
className: `mishu-card ${open ? "open" : ""} ${item.tone === "normal" ? "" : item.tone}`,
|
|
@@ -1518,7 +1550,7 @@ function Card({ item, column, lang, locale, busy, label, openChat: openChat2, op
|
|
|
1518
1550
|
},
|
|
1519
1551
|
onDragEnd,
|
|
1520
1552
|
children: [
|
|
1521
|
-
/* @__PURE__ */ (0,
|
|
1553
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
1522
1554
|
"div",
|
|
1523
1555
|
{
|
|
1524
1556
|
className: "mishu-card-head",
|
|
@@ -1533,40 +1565,40 @@ function Card({ item, column, lang, locale, busy, label, openChat: openChat2, op
|
|
|
1533
1565
|
onToggle();
|
|
1534
1566
|
},
|
|
1535
1567
|
children: [
|
|
1536
|
-
/* @__PURE__ */ (0,
|
|
1537
|
-
/* @__PURE__ */ (0,
|
|
1568
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "mishu-caret", "aria-hidden": "true" }),
|
|
1569
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "mishu-card-title", children: item.title })
|
|
1538
1570
|
]
|
|
1539
1571
|
}
|
|
1540
1572
|
),
|
|
1541
|
-
open ? /* @__PURE__ */ (0,
|
|
1542
|
-
/* @__PURE__ */ (0,
|
|
1543
|
-
!compact && explain !== null ? /* @__PURE__ */ (0,
|
|
1573
|
+
open ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-card-body", children: [
|
|
1574
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-card-meta", children: item.meta }),
|
|
1575
|
+
!compact && explain !== null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-explain", children: [
|
|
1544
1576
|
row(t.what, explain.what),
|
|
1545
1577
|
row(column === "remember" ? t.whyKeep : t.why, explain.why),
|
|
1546
1578
|
row(t.fix, explain.fix, "mishu-fix")
|
|
1547
1579
|
] }) : null,
|
|
1548
|
-
!compact && explain === null && item.note !== null ? /* @__PURE__ */ (0,
|
|
1549
|
-
item.target === "matter" ? /* @__PURE__ */ (0,
|
|
1550
|
-
compact && detail.explain !== null ? /* @__PURE__ */ (0,
|
|
1580
|
+
!compact && explain === null && item.note !== null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-card-note", children: item.note }) : null,
|
|
1581
|
+
item.target === "matter" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-detail", children: detail === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-empty", children: t.loading }) : "error" in detail ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-danger", children: detail.error }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1582
|
+
compact && detail.explain !== null ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1551
1583
|
row(t.what, detail.explain.what),
|
|
1552
1584
|
row(t.whyDone, detail.explain.why)
|
|
1553
1585
|
] }) : null,
|
|
1554
|
-
detail.did.length > 0 ? /* @__PURE__ */ (0,
|
|
1555
|
-
/* @__PURE__ */ (0,
|
|
1556
|
-
/* @__PURE__ */ (0,
|
|
1586
|
+
detail.did.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-row-explain", children: [
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "mishu-row-label", children: t.did }),
|
|
1588
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: detail.did.map((line, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { children: line }, i)) })
|
|
1557
1589
|
] }) : null,
|
|
1558
|
-
detail.messages.length > 0 ? /* @__PURE__ */ (0,
|
|
1559
|
-
/* @__PURE__ */ (0,
|
|
1560
|
-
/* @__PURE__ */ (0,
|
|
1561
|
-
/* @__PURE__ */ (0,
|
|
1590
|
+
detail.messages.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-messages", children: [
|
|
1591
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "mishu-row-label", children: t.messages(detail.messages.length) }),
|
|
1592
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("ul", { children: detail.messages.map((m, i) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("li", { children: [
|
|
1593
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: m.at }),
|
|
1562
1594
|
" ",
|
|
1563
1595
|
m.title
|
|
1564
1596
|
] }, i)) })
|
|
1565
1597
|
] }) : null
|
|
1566
1598
|
] }) }) : null,
|
|
1567
|
-
/* @__PURE__ */ (0,
|
|
1568
|
-
column === "handle" ? /* @__PURE__ */ (0,
|
|
1569
|
-
item.actions.map((action, index) => /* @__PURE__ */ (0,
|
|
1599
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-actions", children: [
|
|
1600
|
+
column === "handle" ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AskAI, { topic: item.target === "series" ? { kind: "series", id: item.id } : { kind: "matter", id: item.id }, lang, locale, openChat: openChat2 }) : null,
|
|
1601
|
+
item.actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
1570
1602
|
"button",
|
|
1571
1603
|
{
|
|
1572
1604
|
type: "button",
|
|
@@ -1577,7 +1609,7 @@ function Card({ item, column, lang, locale, busy, label, openChat: openChat2, op
|
|
|
1577
1609
|
},
|
|
1578
1610
|
action
|
|
1579
1611
|
)),
|
|
1580
|
-
column === "handle" ? null : /* @__PURE__ */ (0,
|
|
1612
|
+
column === "handle" ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AskAI, { topic: item.target === "series" ? { kind: "series", id: item.id } : { kind: "matter", id: item.id }, lang, locale, openChat: openChat2, compact: true })
|
|
1581
1613
|
] })
|
|
1582
1614
|
] }) : null
|
|
1583
1615
|
]
|
|
@@ -1587,11 +1619,11 @@ function Card({ item, column, lang, locale, busy, label, openChat: openChat2, op
|
|
|
1587
1619
|
var EMPTY = { title: "", due: "", repeat: "none", category: "other", note: "" };
|
|
1588
1620
|
function AddForm({ lang, locale, onAdded }) {
|
|
1589
1621
|
const t = TEXT[lang];
|
|
1590
|
-
const [open, setOpen] = (0,
|
|
1591
|
-
const [item, setItem] = (0,
|
|
1592
|
-
const [preview, setPreview] = (0,
|
|
1593
|
-
const [saving, setSaving] = (0,
|
|
1594
|
-
(0,
|
|
1622
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
1623
|
+
const [item, setItem] = (0, import_react6.useState)(EMPTY);
|
|
1624
|
+
const [preview, setPreview] = (0, import_react6.useState)();
|
|
1625
|
+
const [saving, setSaving] = (0, import_react6.useState)(false);
|
|
1626
|
+
(0, import_react6.useEffect)(() => {
|
|
1595
1627
|
if (!open || item.title.trim() === "" || item.due === "") {
|
|
1596
1628
|
setPreview(void 0);
|
|
1597
1629
|
return;
|
|
@@ -1602,7 +1634,7 @@ function AddForm({ lang, locale, onAdded }) {
|
|
|
1602
1634
|
return () => clearTimeout(timer);
|
|
1603
1635
|
}, [open, item, locale]);
|
|
1604
1636
|
if (!open) {
|
|
1605
|
-
return /* @__PURE__ */ (0,
|
|
1637
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("button", { type: "button", className: "mishu-btn mishu-add-toggle", onClick: () => setOpen(true), children: [
|
|
1606
1638
|
"+ ",
|
|
1607
1639
|
t.add
|
|
1608
1640
|
] });
|
|
@@ -1620,49 +1652,49 @@ function AddForm({ lang, locale, onAdded }) {
|
|
|
1620
1652
|
setPreview({ ok: false, text: result.message });
|
|
1621
1653
|
}
|
|
1622
1654
|
};
|
|
1623
|
-
return /* @__PURE__ */ (0,
|
|
1624
|
-
/* @__PURE__ */ (0,
|
|
1655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-add", children: [
|
|
1656
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "mishu-field", children: [
|
|
1625
1657
|
t.addTitle,
|
|
1626
|
-
/* @__PURE__ */ (0,
|
|
1658
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { value: item.title, placeholder: t.addTitlePlaceholder, onChange: set("title") })
|
|
1627
1659
|
] }),
|
|
1628
|
-
/* @__PURE__ */ (0,
|
|
1629
|
-
/* @__PURE__ */ (0,
|
|
1660
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-row", children: [
|
|
1661
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "mishu-field", children: [
|
|
1630
1662
|
t.addDue,
|
|
1631
|
-
/* @__PURE__ */ (0,
|
|
1663
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "date", value: item.due, onChange: set("due") })
|
|
1632
1664
|
] }),
|
|
1633
|
-
/* @__PURE__ */ (0,
|
|
1665
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "mishu-field", children: [
|
|
1634
1666
|
t.addRepeat,
|
|
1635
|
-
/* @__PURE__ */ (0,
|
|
1667
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { value: item.repeat, onChange: set("repeat"), children: Object.entries(t.repeats).map(([value, text]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value, children: text }, value)) })
|
|
1636
1668
|
] })
|
|
1637
1669
|
] }),
|
|
1638
|
-
/* @__PURE__ */ (0,
|
|
1639
|
-
/* @__PURE__ */ (0,
|
|
1670
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-row", children: [
|
|
1671
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "mishu-field", children: [
|
|
1640
1672
|
t.addCategory,
|
|
1641
|
-
/* @__PURE__ */ (0,
|
|
1673
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("select", { value: item.category, onChange: set("category"), children: Object.entries(t.categories).map(([value, text]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value, children: text }, value)) })
|
|
1642
1674
|
] }),
|
|
1643
|
-
/* @__PURE__ */ (0,
|
|
1675
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("label", { className: "mishu-field", children: [
|
|
1644
1676
|
t.addNote,
|
|
1645
|
-
/* @__PURE__ */ (0,
|
|
1677
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { value: item.note, onChange: set("note") })
|
|
1646
1678
|
] })
|
|
1647
1679
|
] }),
|
|
1648
|
-
/* @__PURE__ */ (0,
|
|
1649
|
-
/* @__PURE__ */ (0,
|
|
1650
|
-
/* @__PURE__ */ (0,
|
|
1680
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `mishu-preview ${preview?.ok === false ? "mishu-danger" : ""}`, children: preview?.text ?? t.previewHint }),
|
|
1681
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "mishu-actions", children: [
|
|
1682
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "mishu-btn primary", disabled: saving || preview?.ok !== true, onClick: () => {
|
|
1651
1683
|
void save();
|
|
1652
1684
|
}, children: t.save }),
|
|
1653
|
-
/* @__PURE__ */ (0,
|
|
1685
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "mishu-btn", onClick: () => {
|
|
1654
1686
|
setOpen(false);
|
|
1655
1687
|
setItem(EMPTY);
|
|
1656
1688
|
}, children: t.cancel })
|
|
1657
1689
|
] }),
|
|
1658
|
-
/* @__PURE__ */ (0,
|
|
1690
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "mishu-hint", children: t.chatHint })
|
|
1659
1691
|
] });
|
|
1660
1692
|
}
|
|
1661
1693
|
function RestartButton({ lang, locale }) {
|
|
1662
1694
|
const t = TEXT[lang];
|
|
1663
|
-
const [why, setWhy] = (0,
|
|
1664
|
-
const [status, setStatus] = (0,
|
|
1665
|
-
(0,
|
|
1695
|
+
const [why, setWhy] = (0, import_react6.useState)();
|
|
1696
|
+
const [status, setStatus] = (0, import_react6.useState)();
|
|
1697
|
+
(0, import_react6.useEffect)(() => {
|
|
1666
1698
|
void restartApi.info(locale()).then((r) => {
|
|
1667
1699
|
if (r.ok && !r.supported) setWhy(r.why);
|
|
1668
1700
|
});
|
|
@@ -1682,12 +1714,12 @@ function RestartButton({ lang, locale }) {
|
|
|
1682
1714
|
setStatus({ ok: true, text: await reconnect(locale) ? t.restartReloading : t.restartSlow });
|
|
1683
1715
|
}
|
|
1684
1716
|
};
|
|
1685
|
-
return /* @__PURE__ */ (0,
|
|
1686
|
-
/* @__PURE__ */ (0,
|
|
1717
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
1718
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "mishu-btn", title: why === void 0 ? t.restartTip : `${t.restartTip}
|
|
1687
1719
|
${why}`, disabled: status?.ok === true, onClick: () => {
|
|
1688
1720
|
void restart();
|
|
1689
1721
|
}, children: t.restart }),
|
|
1690
|
-
status === void 0 ? null : /* @__PURE__ */ (0,
|
|
1722
|
+
status === void 0 ? null : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: status.ok ? "mishu-hint" : "mishu-hint mishu-warn", children: status.text })
|
|
1691
1723
|
] });
|
|
1692
1724
|
}
|
|
1693
1725
|
async function reconnect(locale) {
|
|
@@ -1813,10 +1845,17 @@ var STYLES = `
|
|
|
1813
1845
|
.mishu-chip span{color:${FAINT}}
|
|
1814
1846
|
.mishu-chip.active{border-color:${ACCENT};color:${ACCENT}}
|
|
1815
1847
|
.mishu-chip.active span{color:${ACCENT}}
|
|
1816
|
-
.mishu-settings{display:flex;flex-direction:column;gap:
|
|
1817
|
-
.mishu-panel{background:${LAYER1};border-radius:12px;padding:
|
|
1818
|
-
.mishu-panel
|
|
1848
|
+
.mishu-settings{display:flex;flex-direction:column;gap:8px;max-width:760px}
|
|
1849
|
+
.mishu-panel{background:${LAYER1};border:1px solid transparent;border-radius:12px;padding:6px 10px}
|
|
1850
|
+
.mishu-panel.open{border-color:${LINE}}
|
|
1851
|
+
.mishu-panel .mishu-card-head{font-size:14px;padding:6px 4px}
|
|
1852
|
+
.mishu-panel .mishu-card-body{padding:2px 6px 8px}
|
|
1819
1853
|
.mishu-panel h3{font-size:13px;font-weight:600;margin:14px 0 6px}
|
|
1854
|
+
.mishu-fold+.mishu-fold{margin-top:6px}
|
|
1855
|
+
.mishu-fold .mishu-fold{background:${LAYER2}}
|
|
1856
|
+
.mishu-card-aside{flex:0 0 auto;display:inline-flex;align-items:center;margin-left:auto}
|
|
1857
|
+
.mishu-check-inline{margin:0}
|
|
1858
|
+
.mishu-check-inline input{cursor:pointer}
|
|
1820
1859
|
.mishu-notify-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:6px}
|
|
1821
1860
|
.mishu-notify-row input[type=time]{font:inherit;font-size:13px;color:${TEXT2};background:${LAYER2};border:1px solid ${LINE_STRONG};border-radius:6px;padding:2px 6px}
|
|
1822
1861
|
.mishu-grid5{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px;margin-bottom:8px}
|
|
@@ -1834,18 +1873,18 @@ var STYLES = `
|
|
|
1834
1873
|
`;
|
|
1835
1874
|
|
|
1836
1875
|
// src/client/index.tsx
|
|
1837
|
-
var
|
|
1876
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1838
1877
|
var PACKAGE_NAME = "dsh-mishu";
|
|
1839
1878
|
var inject = ["slots", "locale"];
|
|
1840
1879
|
var PANEL_ID = "dsh-mishu";
|
|
1841
1880
|
var NS = "dsh-mishu";
|
|
1842
1881
|
var openChat;
|
|
1843
1882
|
function MishuIcon({ size }) {
|
|
1844
|
-
return /* @__PURE__ */ (0,
|
|
1845
|
-
/* @__PURE__ */ (0,
|
|
1846
|
-
/* @__PURE__ */ (0,
|
|
1847
|
-
/* @__PURE__ */ (0,
|
|
1848
|
-
/* @__PURE__ */ (0,
|
|
1883
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 1.8, strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [
|
|
1884
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("rect", { x: "5", y: "4", width: "14", height: "17", rx: "2" }),
|
|
1885
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M9 4h6v3H9z" }),
|
|
1886
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M9 12l2 2 4-4" }),
|
|
1887
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M9 17h6" })
|
|
1849
1888
|
] });
|
|
1850
1889
|
}
|
|
1851
1890
|
function apply(ctx) {
|