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

@@ -3,6 +3,7 @@
import { use, useEffect, useMemo, useState } from "react";
import { Link } from "@/i18n/navigation";
import Footer from "@/app/components/Footer";
import NewsletterSubscribe from "@/app/components/NewsletterSubscribe";
import { apiFetch } from "@/app/lib/api-client";
interface CityGuide {
@@ -377,6 +378,8 @@ export default function CityGuidePage({ params }: { params: Promise<{ slug: stri
</ul>
</section>
<NewsletterSubscribe locale="zh" citySlug={slug} list="city" className="mb-6" />
<div className="flex flex-col sm:flex-row gap-3">
<Link
href="/join"

View File

@@ -2,6 +2,7 @@
import { useEffect, useMemo, useState, type ReactNode } from "react";
import { Link, useLocale, useTranslation } from "@/i18n/navigation";
import NewsletterSubscribe from "@/app/components/NewsletterSubscribe";
import { apiFetch } from "@/app/lib/api-client";
import {
buildMeetupChatUrl,
@@ -707,6 +708,16 @@ function MeetupDetailModal({ meetup, locale, viewer, onClose }: { meetup: Meetup
{canJoin && (
<p className="mt-2 text-xs text-emerald-700 dark:text-emerald-300">{c.chatHint}</p>
)}
{meetup.replayUrl ? (
<a
href={meetup.replayUrl}
target="_blank"
rel="noreferrer"
className="mt-3 inline-flex text-sm font-semibold text-emerald-700 underline dark:text-emerald-300"
>
{locale === "zh" ? "观看活动回放" : "Watch replay"}
</a>
) : null}
{embedOpen && canJoin && (
<iframe
title={`MiroTalk ${meetup.city}`}
@@ -903,6 +914,8 @@ export default function MeetupsPage() {
</div>
</div>
<NewsletterSubscribe locale={locale} list="meetup" className="mb-6" />
<p className="mb-6 text-sm text-gray-500 dark:text-gray-400">
{c.countPrefix}
<span className="mx-1 font-semibold text-gray-700 dark:text-gray-300">{displayedMeetups.length}</span>

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">