Add ntfy push and Listmonk newsletter with lightweight Docker deploy tooling.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
eric
2026-06-08 02:24:55 -05:00
parent 47b1ae8514
commit 22a960799c
24 changed files with 846 additions and 3 deletions

View File

@@ -15,7 +15,7 @@ interface PreferenceRecord {
}
const DEFAULT_PREFERENCES: PreferenceRecord = {
channels: { in_app: true, email: false, wechat: false },
channels: { in_app: true, push: false, email: false, wechat: false },
categories: {
system: true,
meetup: true,
@@ -33,6 +33,7 @@ const DEFAULT_PREFERENCES: PreferenceRecord = {
const CHANNELS = [
["in_app", "站内消息", "始终建议开启,所有业务通知都会进入消息中心。"],
["push", "手机推送 (ntfy)", "通过 ntfy 推送到手机;开启后请用下方订阅链接在 ntfy App 中订阅。"],
["email", "邮件摘要", "适合离线时收到每日/每周汇总。"],
["wechat", "微信提醒", "后续可接企业微信、公众号或机器人。"],
];
@@ -50,11 +51,15 @@ const CATEGORIES = [
export default function NotificationSettingsPage() {
const [prefs, setPrefs] = useState<PreferenceRecord>(DEFAULT_PREFERENCES);
const [saved, setSaved] = useState("");
const [pushSubscribeUrl, setPushSubscribeUrl] = useState("");
useEffect(() => {
apiFetch<{ record: PreferenceRecord }>("/api/notifications/preferences")
.then((data) => setPrefs({ ...DEFAULT_PREFERENCES, ...(data.record || {}) }))
.catch(() => setPrefs(DEFAULT_PREFERENCES));
apiFetch<{ subscribeUrl?: string }>("/api/notifications/push-config")
.then((data) => setPushSubscribeUrl(data.subscribeUrl || ""))
.catch(() => setPushSubscribeUrl(""));
}, []);
const save = async () => {
@@ -110,6 +115,22 @@ export default function NotificationSettingsPage() {
</label>
))}
</div>
{prefs.channels.push && pushSubscribeUrl ? (
<div className="mt-4 rounded-2xl border border-violet-200 bg-violet-50/80 p-4 dark:border-violet-900/50 dark:bg-violet-950/30">
<p className="text-sm font-semibold text-violet-900 dark:text-violet-200">ntfy 订阅链接</p>
<p className="mt-1 text-xs text-violet-800/80 dark:text-violet-300/80">
在 ntfy 手机 App 中添加此主题,或浏览器打开订阅。
</p>
<a
href={pushSubscribeUrl}
target="_blank"
rel="noreferrer"
className="mt-2 block break-all text-sm font-medium text-violet-700 underline dark:text-violet-300"
>
{pushSubscribeUrl}
</a>
</div>
) : null}
</div>
<div className="rounded-2xl bg-white p-5 shadow-sm ring-1 ring-gray-100 dark:bg-gray-900 dark:ring-gray-800">