"use client"; import { useEffect, useState } from "react"; import { Link } from "@/i18n/navigation"; import Footer from "@/app/components/Footer"; import { apiFetch } from "@/app/lib/api-client"; interface PreferenceRecord { channels: Record; categories: Record; quietHoursStart: string; quietHoursEnd: string; digest: string; allowMarketing: boolean; } const DEFAULT_PREFERENCES: PreferenceRecord = { channels: { in_app: true, email: false, wechat: false }, categories: { system: true, meetup: true, gig: true, match: true, service: true, community: true, city: true, }, quietHoursStart: "22:00", quietHoursEnd: "08:00", digest: "daily", allowMarketing: false, }; const CHANNELS = [ ["in_app", "站内消息", "始终建议开启,所有业务通知都会进入消息中心。"], ["email", "邮件摘要", "适合离线时收到每日/每周汇总。"], ["wechat", "微信提醒", "后续可接企业微信、公众号或机器人。"], ]; const CATEGORIES = [ ["system", "系统公告"], ["meetup", "活动提醒"], ["gig", "赏金任务"], ["match", "社交匹配"], ["service", "服务咨询"], ["community", "社区讨论"], ["city", "城市更新"], ]; export default function NotificationSettingsPage() { const [prefs, setPrefs] = useState(DEFAULT_PREFERENCES); const [saved, setSaved] = useState(""); useEffect(() => { apiFetch<{ record: PreferenceRecord }>("/api/notifications/preferences") .then((data) => setPrefs({ ...DEFAULT_PREFERENCES, ...(data.record || {}) })) .catch(() => setPrefs(DEFAULT_PREFERENCES)); }, []); const save = async () => { await apiFetch("/api/notifications/preferences", { method: "PUT", body: JSON.stringify(prefs), }); setSaved("通知偏好已保存"); }; return (
← 返回消息中心

Notification Settings

通知偏好设置

控制接收渠道、消息类型、免打扰时间和摘要频率。设置会保存到 PocketBase。

{saved && (
{saved}
)}

接收渠道

{CHANNELS.map(([key, title, desc]) => ( ))}

消息类型

{CATEGORIES.map(([key, label]) => ( ))}
); }