diff --git a/apps/web/src/pages/profile.tsx b/apps/web/src/pages/profile.tsx index f87d281..c6ffb97 100644 --- a/apps/web/src/pages/profile.tsx +++ b/apps/web/src/pages/profile.tsx @@ -369,7 +369,7 @@ export function ProfilePage() {
-
{renderTab()}
+
{renderTab()}
@@ -379,7 +379,7 @@ export function ProfilePage() {
-
{renderTab()}
+
{renderTab()}
@@ -2601,6 +2601,7 @@ type RuleCreatePayload = { type RuleConditionField = NonNullable type RuleConditionOperator = NonNullable const conditionFieldLabels: Record = { from: "发件人地址", to: "收件人地址", cc: "抄送地址", subject: "邮件主题", body: "邮件正文", attachment: "附件名称", size: "邮件大小", date: "收信日期" } +const conditionFieldShortLabels: Record = { from: "发件人", to: "收件人", cc: "抄送", subject: "邮件主题", body: "body", attachment: "附件", size: "邮件大小", date: "收信日期" } const conditionOperatorLabels: Record = { contains: "包含", "not-contains": "不包含", equals: "等于", "not-equals": "不等于", "starts-with": "开头是", "ends-with": "结尾是", gt: "大于", gte: "大于等于", lt: "小于", lte: "小于等于", before: "早于", after: "晚于", on: "当天" } const textConditionOperators: RuleConditionOperator[] = ["contains", "not-contains", "equals", "not-equals", "starts-with", "ends-with"] const sizeConditionOperators: RuleConditionOperator[] = ["gt", "gte", "lt", "lte", "equals", "not-equals"] @@ -2611,14 +2612,14 @@ const ruleActionLabels: Record = { archive: "移 function RulesSection({ items, mailboxes, labels, open, onOpenChange, onCreate, onDelete, pending }: { items: MailRule[]; mailboxes: Mailbox[]; labels: MailLabel[]; open: boolean; onOpenChange: (open: boolean) => void; onCreate: (payload: RuleCreatePayload) => void; onDelete: (id: string) => void; pending: boolean }) { return ( -
+
- + +
+
+ {items.map((item) => )} + {items.length === 0 && } text="暂无收件规则" description="新建规则后,可自动标记、移动或转发符合条件的邮件。" className="border-solid bg-card" />}
- - {items.map((item) => )} - {items.length === 0 && } text="暂无收件规则" description="新建规则后,可自动标记、移动或转发符合条件的邮件。" />} -
) @@ -2857,15 +2858,20 @@ function RuleCheckbox({ checked, onCheckedChange, label }: { checked: boolean; o function RuleListItem({ item, mailboxes, onDelete }: { item: MailRule; mailboxes: Mailbox[]; onDelete: (id: string) => void }) { const mailbox = item.mailboxId ? mailboxes.find((m) => m.id === item.mailboxId)?.address : "全部邮箱" const [confirmOpen, setConfirmOpen] = React.useState(false) + const conditionText = ruleConditionSummary(item.conditions, item.fromContains, item.subjectContains) + const actionText = item.actions.map(ruleActionSummary).filter(Boolean).join(";") || "无动作" return ( -
-
-
- {item.name} - {item.enabled ? "启用" : "停用"} - {item.actions.map((action, index) => {actionSummary(action)})} +
+
+
+ {item.name} + {item.enabled ? "已启用" : "已停用"}
-
{mailbox} · {item.matchMode === "any" ? "任一条件" : "所有条件"} · {conditionSummary(item.conditions, item.fromContains, item.subjectContains)}
+
+

条件:{conditionText}

+

动作:{actionText}

+
+
{mailbox} · {item.matchMode === "any" ? "任一条件" : "所有条件"}
{ onDelete(item.id); setConfirmOpen(false) }} /> @@ -2904,24 +2910,25 @@ function conditionPlaceholder(field?: MailRuleCondition["field"]) { return "输入值" } -function conditionSummary(conditions: MailRuleCondition[] = [], fromContains = "", subjectContains = "") { +function ruleConditionSummary(conditions: MailRuleCondition[] = [], fromContains = "", subjectContains = "") { const items = conditions.length > 0 ? conditions : [fromContains ? { field: "from", operator: "contains", value: fromContains } as MailRuleCondition : undefined, subjectContains ? { field: "subject", operator: "contains", value: subjectContains } as MailRuleCondition : undefined].filter(Boolean) as MailRuleCondition[] - return items.map(conditionItemSummary).join(";") || "无条件" + return items.map(ruleConditionItemSummary).join(";") || "无条件" } -function conditionItemSummary(item: MailRuleCondition): string { +function ruleConditionItemSummary(item: MailRuleCondition): string { if (item.conditions?.length) { const mode = item.matchMode === "any" ? "任一" : "全部" - return `${mode}(${item.conditions.map(conditionItemSummary).join(";")})` + return `${mode}(${item.conditions.map(ruleConditionItemSummary).join(";")})` } const field = item.field || "from" const operator = item.operator || defaultConditionOperator(field) - return `${conditionFieldLabels[field]} ${conditionOperatorLabels[operator]} ${item.value || ""}` + const value = item.value ? `"${item.value}"` : "" + return `${conditionFieldShortLabels[field]}${conditionOperatorLabels[operator]}${value}` } -function actionSummary(action: MailRuleAction) { - if (action.type === "label") return `${ruleActionLabels[action.type]}${action.value ? `:${action.value}` : ""}` - if (action.type === "move") return `${ruleActionLabels[action.type]}:${folderLabel(action.value || "Archive")}` +function ruleActionSummary(action: MailRuleAction) { + if (action.type === "label") return `${ruleActionLabels[action.type]}${action.value ? `:"${action.value}"` : ""}` + if (action.type === "move") return `${ruleActionLabels[action.type]}:"${folderLabel(action.value || "Archive")}"` if (action.type === "forward") return `${ruleActionLabels[action.type]}${action.value ? `:${action.value}` : ""}` return ruleActionLabels[action.type] }