[feat] log
This commit is contained in:
14 files changed
+305
-210
No files matched your search
+89
-89
@@ -19915,7 +19915,8 @@ var snapshotSchema = () => external_exports.object({
|
||||
mailbox: mailboxSchema(),
|
||||
passwordSet: external_exports.boolean(),
|
||||
allowedAddresses: external_exports.array(external_exports.string()),
|
||||
status: statusSchema()
|
||||
status: statusSchema(),
|
||||
logs: external_exports.array(external_exports.string())
|
||||
});
|
||||
var patchSchema = () => external_exports.object({
|
||||
email: external_exports.string().optional(),
|
||||
@@ -20048,7 +20049,7 @@ var table = {
|
||||
};
|
||||
var cell = {
|
||||
borderBottom: "1px solid var(--dsh-border, #e5e7eb)",
|
||||
padding: "8px 10px",
|
||||
padding: "6px 8px",
|
||||
verticalAlign: "middle",
|
||||
textAlign: "left"
|
||||
};
|
||||
@@ -20078,8 +20079,22 @@ var primary = {
|
||||
color: "#fff"
|
||||
};
|
||||
var muted = { color: "#6b7280", fontSize: 12 };
|
||||
var section = { display: "grid", gap: 16, maxWidth: 760 };
|
||||
var section = { display: "grid", gap: 16, maxWidth: 640 };
|
||||
var row = { display: "flex", gap: 8, alignItems: "center" };
|
||||
var logBox = {
|
||||
margin: 0,
|
||||
padding: "8px 10px",
|
||||
maxHeight: 220,
|
||||
overflow: "auto",
|
||||
border: "1px solid var(--dsh-border, #e5e7eb)",
|
||||
borderRadius: 6,
|
||||
background: "var(--dsh-code-bg, rgba(127,127,127,0.08))",
|
||||
fontSize: 12,
|
||||
lineHeight: 1.6,
|
||||
fontFamily: "ui-monospace, SFMono-Regular, Consolas, monospace",
|
||||
whiteSpace: "pre-wrap",
|
||||
wordBreak: "break-all"
|
||||
};
|
||||
function MailGatewaySection({ api }) {
|
||||
const [snapshot, setSnapshot] = (0, import_react.useState)();
|
||||
const [mailbox, setMailbox] = (0, import_react.useState)();
|
||||
@@ -20089,6 +20104,34 @@ function MailGatewaySection({ api }) {
|
||||
const [test, setTest] = (0, import_react.useState)();
|
||||
const [busy, setBusy] = (0, import_react.useState)(null);
|
||||
const [notice, setNotice] = (0, import_react.useState)();
|
||||
const logRef = (0, import_react.useRef)(null);
|
||||
(0, import_react.useEffect)(() => {
|
||||
let alive = true;
|
||||
const load = async (initial) => {
|
||||
const result = await api.get();
|
||||
if (!alive) return;
|
||||
if (!result.ok) {
|
||||
if (initial) setNotice({ kind: "error", text: result.error.message });
|
||||
return;
|
||||
}
|
||||
setSnapshot(result.value);
|
||||
if (initial) {
|
||||
setMailbox({ ...result.value.mailbox });
|
||||
setAllowed([...result.value.allowedAddresses]);
|
||||
setPassword("");
|
||||
}
|
||||
};
|
||||
void load(true);
|
||||
const timer = setInterval(() => void load(false), 3e3);
|
||||
return () => {
|
||||
alive = false;
|
||||
clearInterval(timer);
|
||||
};
|
||||
}, [api]);
|
||||
(0, import_react.useEffect)(() => {
|
||||
const box = logRef.current;
|
||||
if (box) box.scrollTop = box.scrollHeight;
|
||||
}, [snapshot?.logs]);
|
||||
const applySnapshot = (next, resetMailbox) => {
|
||||
setSnapshot(next);
|
||||
setAllowed([...next.allowedAddresses]);
|
||||
@@ -20097,17 +20140,6 @@ function MailGatewaySection({ api }) {
|
||||
setPassword("");
|
||||
}
|
||||
};
|
||||
(0, import_react.useEffect)(() => {
|
||||
let alive = true;
|
||||
void api.get().then((result) => {
|
||||
if (!alive) return;
|
||||
if (result.ok) applySnapshot(result.value, true);
|
||||
else setNotice({ kind: "error", text: result.error.message });
|
||||
});
|
||||
return () => {
|
||||
alive = false;
|
||||
};
|
||||
}, [api]);
|
||||
const setField = (key, value) => {
|
||||
setMailbox((current) => current ? { ...current, [key]: value } : current);
|
||||
};
|
||||
@@ -20124,7 +20156,7 @@ function MailGatewaySection({ api }) {
|
||||
if (result.ok) {
|
||||
applySnapshot(result.value, true);
|
||||
setTest(void 0);
|
||||
setNotice({ kind: "ok", text: "\u90AE\u7BB1\u7ED1\u5B9A\u5DF2\u4FDD\u5B58\uFF0C\u8FDE\u63A5\u5DF2\u6309\u65B0\u914D\u7F6E\u91CD\u5EFA\u3002" });
|
||||
setNotice({ kind: "ok", text: "\u5DF2\u4FDD\u5B58\uFF0C\u6309\u65B0\u914D\u7F6E\u91CD\u8FDE\u3002" });
|
||||
} else {
|
||||
setNotice({ kind: "error", text: result.error.message });
|
||||
}
|
||||
@@ -20162,7 +20194,7 @@ function MailGatewaySection({ api }) {
|
||||
setBusy(null);
|
||||
if (result.ok) {
|
||||
applySnapshot(result.value, false);
|
||||
setNotice({ kind: "ok", text: "\u767D\u540D\u5355\u5DF2\u4FDD\u5B58\uFF0C\u6536\u4FE1\u7B56\u7565\u7ACB\u5373\u751F\u6548\uFF0C\u8FDE\u63A5\u4FDD\u6301\u4E0D\u53D8\u3002" });
|
||||
setNotice({ kind: "ok", text: "\u767D\u540D\u5355\u5DF2\u4FDD\u5B58\u3002" });
|
||||
} else {
|
||||
setNotice({ kind: "error", text: result.error.message });
|
||||
}
|
||||
@@ -20176,82 +20208,49 @@ function MailGatewaySection({ api }) {
|
||||
const boolField = (key) => (event) => {
|
||||
setField(key, event.target.checked);
|
||||
};
|
||||
const textRow = (label, key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, width: 110 }, children: label }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.[key] ?? "", onChange: textField(key) }) })
|
||||
] });
|
||||
const portRow = (label, key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, width: 110 }, children: label }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.[key] ?? 0, onChange: numberField(key) }) })
|
||||
] });
|
||||
const tlsRow = (label, key) => /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, width: 110 }, children: label }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: mailbox?.[key] ?? true, onChange: boolField(key) }) })
|
||||
] });
|
||||
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: section, children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(StatusCard, { status: snapshot?.status, allowedCount: allowed.length, test }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { style: { margin: "0 0 8px", fontSize: 15 }, children: "\u90AE\u7BB1\u7ED1\u5B9A" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("table", { style: table, children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { style: { ...cell, ...muted, width: 140 }, children: "\u5B57\u6BB5" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { style: { ...cell, ...muted }, children: "\u503C" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("th", { style: { ...cell, ...muted, width: 240 }, children: "\u8BF4\u660E" })
|
||||
] }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tbody", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "\u90AE\u7BB1\u5730\u5740" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.email ?? "", onChange: textField("email") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "\u63A5\u6536\u90AE\u4EF6\u4E0E\u56DE\u4FE1\u4F7F\u7528\u7684\u5730\u5740\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "\u663E\u793A\u540D" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.displayName ?? "", onChange: textField("displayName") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "\u56DE\u4FE1\u65F6\u7684\u53D1\u4EF6\u4EBA\u540D\u79F0\uFF0C\u53EF\u7559\u7A7A\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "IMAP \u4E3B\u673A" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.imapHost ?? "", onChange: textField("imapHost") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "\u6807\u51C6 IMAP \u670D\u52A1\u5668\u5730\u5740\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "IMAP \u7AEF\u53E3" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.imapPort ?? 993, onChange: numberField("imapPort") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "SSL \u4E00\u822C\u4E3A 993\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "IMAP TLS" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: mailbox?.imapSecure ?? true, onChange: boolField("imapSecure") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "\u52FE\u9009\u8868\u793A\u4F7F\u7528 SSL/TLS\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "SMTP \u4E3B\u673A" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.smtpHost ?? "", onChange: textField("smtpHost") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "\u6807\u51C6 SMTP \u670D\u52A1\u5668\u5730\u5740\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "SMTP \u7AEF\u53E3" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.smtpPort ?? 465, onChange: numberField("smtpPort") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "SSL \u4E00\u822C\u4E3A 465\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "SMTP TLS" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { type: "checkbox", checked: mailbox?.smtpSecure ?? true, onChange: boolField("smtpSecure") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "\u52FE\u9009\u8868\u793A\u4F7F\u7528 SSL/TLS\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "\u767B\u5F55\u7528\u6237\u540D" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("input", { style: input2, value: mailbox?.username ?? "", onChange: textField("username") }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "\u7559\u7A7A\u65F6\u4F7F\u7528\u90AE\u7BB1\u5730\u5740\u3002" })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: "\u5BC6\u7801" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
||||
"input",
|
||||
{
|
||||
style: input2,
|
||||
type: "password",
|
||||
value: password,
|
||||
placeholder: snapshot?.passwordSet ? "\u5DF2\u8BBE\u7F6E\uFF0C\u7559\u7A7A\u8868\u793A\u4E0D\u4FEE\u6539" : "\u672A\u8BBE\u7F6E",
|
||||
onChange: (event) => setPassword(event.target.value)
|
||||
}
|
||||
) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, ...muted }, children: "\u4FDD\u5B58\u540E\u53EA\u663E\u793A\u201C\u5DF2\u8BBE\u7F6E\u201D\uFF0C\u4E0D\u4F1A\u56DE\u663E\u660E\u6587\u3002" })
|
||||
] })
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("table", { style: table, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tbody", { children: [
|
||||
textRow("\u90AE\u7BB1\u5730\u5740", "email"),
|
||||
textRow("\u663E\u793A\u540D", "displayName"),
|
||||
textRow("IMAP \u4E3B\u673A", "imapHost"),
|
||||
portRow("IMAP \u7AEF\u53E3", "imapPort"),
|
||||
tlsRow("IMAP TLS", "imapSecure"),
|
||||
textRow("SMTP \u4E3B\u673A", "smtpHost"),
|
||||
portRow("SMTP \u7AEF\u53E3", "smtpPort"),
|
||||
tlsRow("SMTP TLS", "smtpSecure"),
|
||||
textRow("\u767B\u5F55\u7528\u6237\u540D", "username"),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("tr", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, width: 110 }, children: "\u5BC6\u7801" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
||||
"input",
|
||||
{
|
||||
style: input2,
|
||||
type: "password",
|
||||
value: password,
|
||||
placeholder: snapshot?.passwordSet ? "\u5DF2\u8BBE\u7F6E\uFF0C\u7559\u7A7A\u8868\u793A\u4E0D\u4FEE\u6539" : "\u672A\u8BBE\u7F6E",
|
||||
onChange: (event) => setPassword(event.target.value)
|
||||
}
|
||||
) })
|
||||
] })
|
||||
] }),
|
||||
] }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { ...row, marginTop: 10 }, children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { style: primary, disabled: busy !== null, onClick: () => void saveMailbox(), children: busy === "mailbox" ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58\u90AE\u7BB1\u7ED1\u5B9A" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { style: button, disabled: busy !== null, onClick: () => void testConnection(), children: busy === "test" ? "\u6D4B\u8BD5\u4E2D\u2026" : "\u6D4B\u8BD5\u8FDE\u63A5" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: muted, children: "\u4FDD\u5B58\u90AE\u7BB1\u7ED1\u5B9A\u65F6\u4F1A\u6309\u65B0\u914D\u7F6E\u91CD\u5EFA\u8FDE\u63A5\u3002" })
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { style: button, disabled: busy !== null, onClick: () => void testConnection(), children: busy === "test" ? "\u6D4B\u8BD5\u4E2D\u2026" : "\u6D4B\u8BD5\u8FDE\u63A5" })
|
||||
] })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
||||
@@ -20273,10 +20272,11 @@ function MailGatewaySection({ api }) {
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: cell, children: address }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("td", { style: { ...cell, width: 80, textAlign: "right" }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { style: button, onClick: () => removeAddress(address), children: "\u5220\u9664" }) })
|
||||
] }, address)) }) }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { ...row, marginTop: 10 }, children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { style: primary, disabled: busy !== null, onClick: () => void saveWhitelist(), children: busy === "whitelist" ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58\u767D\u540D\u5355" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: muted, children: "\u540C\u4E00\u4EFD\u767D\u540D\u5355\u540C\u65F6\u6821\u9A8C\u5165\u7AD9\u53D1\u4EF6\u5730\u5740\u4E0E\u51FA\u7AD9\u56DE\u590D\u5730\u5740\u3002" })
|
||||
] })
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { ...row, marginTop: 10 }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { style: primary, disabled: busy !== null, onClick: () => void saveWhitelist(), children: busy === "whitelist" ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58\u767D\u540D\u5355" }) })
|
||||
] }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { children: [
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h3", { style: { margin: "0 0 8px", fontSize: 15 }, children: "\u8FD0\u884C\u65E5\u5FD7" }),
|
||||
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { ref: logRef, style: logBox, children: snapshot?.logs?.length ? snapshot.logs.join("\n") : "\u6682\u65E0\u65E5\u5FD7" })
|
||||
] }),
|
||||
notice ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { color: notice.kind === "ok" ? "#047857" : "#b91c1c", fontSize: 13 }, children: notice.text }) : null
|
||||
] });
|
||||
|
||||
Reference in new issue
Block a user