diff --git a/src/modules/social/components/MeetupLiveClient.tsx b/src/modules/social/components/MeetupLiveClient.tsx
index c90e997..0ba36a8 100644
--- a/src/modules/social/components/MeetupLiveClient.tsx
+++ b/src/modules/social/components/MeetupLiveClient.tsx
@@ -10,11 +10,12 @@ import { socialPath } from "@social/lib/socialPath";
type Layout = "split" | "video" | "chat";
-/** Origins currently listed in mirotalk.nomadro.com Caddy frame-ancestors. */
+/** Origins allowed by MiroTalk ALLOWED_EMBED_ORIGINS (82 本机 mirotalk.nomadro.cn). */
const EMBED_OK = new Set([
"https://nomadro.cn",
"https://www.nomadro.cn",
"https://nomadweb.nomadro.com",
+ "https://social.nomadro.cn",
"http://localhost:3000",
"http://127.0.0.1:3000",
"http://localhost:3001",
@@ -22,7 +23,16 @@ const EMBED_OK = new Set([
]);
function joinUrl(room: string, name: string) {
- const q = new URLSearchParams({ room, name });
+ // notify=0: never open MiroTalk "Share the room" popup
+ // chat=0: use portal side chat; keep A/V on for the live room
+ const q = new URLSearchParams({
+ room,
+ name,
+ notify: "0",
+ chat: "0",
+ audio: "1",
+ video: "1",
+ });
return `${MIROTALK_URL.replace(/\/$/, "")}/join?${q.toString()}`;
}
@@ -31,6 +41,28 @@ function canEmbedHere() {
return EMBED_OK.has(window.location.origin);
}
+function warmMirotalkOrigin() {
+ try {
+ const origin = new URL(MIROTALK_URL).origin;
+ for (const rel of ["dns-prefetch", "preconnect"] as const) {
+ if (document.querySelector(`link[rel="${rel}"][href="${origin}"]`)) continue;
+ const link = document.createElement("link");
+ link.rel = rel;
+ link.href = origin;
+ if (rel === "preconnect") link.crossOrigin = "anonymous";
+ document.head.appendChild(link);
+ }
+ // Warm HTML/JS edge cache (no media) so first iframe paint is faster
+ void fetch(`${origin}/js/nomadro-speed.js`, {
+ mode: "no-cors",
+ credentials: "omit",
+ cache: "force-cache",
+ }).catch(() => undefined);
+ } catch {
+ /* ignore */
+ }
+}
+
export default function MeetupLiveClient({ meetupId }: { meetupId: string }) {
const meetup = SEED_MEETUPS.find((m) => m.id === meetupId) || SEED_MEETUPS[0];
const channel =
@@ -43,12 +75,18 @@ export default function MeetupLiveClient({ meetupId }: { meetupId: string }) {
const [layout, setLayout] = useState
("split");
const [nick, setNick] = useState("游民");
+ /** Frozen at auto-join so nick edits don't remount the iframe. */
+ const [joinName, setJoinName] = useState("");
const [text, setText] = useState("");
const [messages, setMessages] = useState([]);
const [videoReady, setVideoReady] = useState(false);
const [embedBlocked, setEmbedBlocked] = useState(false);
+ const [iframeLoading, setIframeLoading] = useState(true);
const bottomRef = useRef(null);
- const videoSrc = joinUrl(meetup.mirotalkRoom, nick.trim() || "nomadro");
+ const videoSrc = useMemo(
+ () => joinUrl(meetup.mirotalkRoom, joinName || "游民"),
+ [meetup.mirotalkRoom, joinName],
+ );
const preferEmbed = canEmbedHere() && !embedBlocked;
const refresh = useCallback(async () => {
@@ -68,8 +106,16 @@ export default function MeetupLiveClient({ meetupId }: { meetupId: string }) {
}
}, [channel.id, seedForRoom, storageKey]);
+ // Instant join: hydrate nick → start iframe immediately (no "开始视频" gate)
useEffect(() => {
- setNick(loadJson("nick", "游民"));
+ warmMirotalkOrigin();
+ const name = (loadJson("nick", "游民") || "游民").trim() || "游民";
+ setNick(name);
+ setJoinName(name);
+ if (canEmbedHere()) {
+ setIframeLoading(true);
+ setVideoReady(true);
+ }
void refresh();
const id = window.setInterval(() => void refresh(), 4000);
return () => clearInterval(id);
@@ -105,6 +151,24 @@ export default function MeetupLiveClient({ meetupId }: { meetupId: string }) {
}
};
+ const startVideo = (forceReload = false) => {
+ const name = nick.trim() || "游民";
+ saveJson("nick", name);
+ setJoinName(name);
+ if (!preferEmbed) {
+ window.location.assign(joinUrl(meetup.mirotalkRoom, name));
+ return;
+ }
+ setIframeLoading(true);
+ if (forceReload && videoReady) {
+ // remount iframe with new name only when user asks
+ setVideoReady(false);
+ window.requestAnimationFrame(() => setVideoReady(true));
+ } else {
+ setVideoReady(true);
+ }
+ };
+
return (
@@ -119,19 +183,41 @@ export default function MeetupLiveClient({ meetupId }: { meetupId: string }) {
-
- {(["split", "video", "chat"] as const).map((m) => (
+
+
+ {videoReady && preferEmbed && nick.trim() && nick.trim() !== joinName ? (
- ))}
+ ) : null}
+
+ {(["split", "video", "chat"] as const).map((m) => (
+
+ ))}
+
@@ -143,53 +229,51 @@ export default function MeetupLiveClient({ meetupId }: { meetupId: string }) {
进入视频房间
{preferEmbed
- ? "在站内嵌打开,不新开标签页。请允许摄像头 / 麦克风。"
- : "当前域名未在视频 CSP 白名单,将在本页跳转进入(不新开标签)。浏览器返回即可回到社区。"}
+ ? "正在准备极速进房…"
+ : "当前域名未在视频 CSP 白名单,将在本页跳转进入(不新开标签)。"}
-
) : preferEmbed ? (
-