- 基于 openim-electron-demo 改造:工号+密码登录(自研账号服务)、会话列表/聊天窗/通讯录界面重做
- 文字/语音/文件/图片消息、文件拖拽发送、表情面板、一对一语音通话(LiveKit)
- RTC 令牌对接账号服务带鉴权版 /api/rtc_token(Bearer imToken + {room,identity})
- account-service: CORS Allow-Headers 补 authorization(浏览器/渲染进程跨域调 rtc_token 需要)
- 附本地 mock 账号服务(scripts/mock-account-server.js)与截图联调脚本
50 lines
1.6 KiB
TypeScript
50 lines
1.6 KiB
TypeScript
import { useMount } from "ahooks";
|
|
import { Layout, Spin } from "antd";
|
|
import { t } from "i18next";
|
|
import { Outlet, useMatches, useNavigate } from "react-router-dom";
|
|
|
|
import WindowControlBar from "@/components/WindowControlBar";
|
|
import { useUserStore } from "@/store";
|
|
|
|
import GlobalModals from "./GlobalModals";
|
|
import LeftNavBar from "./LeftNavBar";
|
|
import { useGlobalEvent } from "./useGlobalEvents";
|
|
|
|
export const MainContentLayout = () => {
|
|
useGlobalEvent();
|
|
const matches = useMatches();
|
|
const navigate = useNavigate();
|
|
|
|
const progress = useUserStore((state) => state.progress);
|
|
const syncState = useUserStore((state) => state.syncState);
|
|
const reinstall = useUserStore((state) => state.reinstall);
|
|
const isLogining = useUserStore((state) => state.isLogining);
|
|
|
|
useMount(() => {
|
|
const isRoot = !matches.find((item) => item.pathname !== "/");
|
|
const inConversation = matches.some((item) => item.params.conversationID);
|
|
if (isRoot || inConversation) {
|
|
navigate("chat", {
|
|
replace: true,
|
|
});
|
|
}
|
|
});
|
|
|
|
const loadingTip = isLogining ? t("toast.loading") : `${progress}%`;
|
|
const showLockLoading = isLogining || (reinstall && syncState === "loading");
|
|
|
|
return (
|
|
<Spin className="!max-h-none" spinning={showLockLoading} tip={loadingTip}>
|
|
<Layout className="relative h-full flex-row">
|
|
<LeftNavBar />
|
|
<Outlet />
|
|
{/* 悬浮窗口控制条:无边框窗口的拖动区 + 最小化/关闭 */}
|
|
<div className="app-drag absolute right-0 top-0 z-[999] h-10 w-48">
|
|
<WindowControlBar />
|
|
</div>
|
|
<GlobalModals />
|
|
</Layout>
|
|
</Spin>
|
|
);
|
|
};
|