新增 pc-client:畅联 PC 端工程(Electron+React,按确认效果图改造,B-59)
- 基于 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)与截图联调脚本
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import { BrowserWindow, Menu, app, dialog, ipcMain } from "electron";
|
||||
import {
|
||||
clearCache,
|
||||
closeWindow,
|
||||
minimize,
|
||||
showWindow,
|
||||
splashEnd,
|
||||
updateMaximize,
|
||||
} from "./windowManage";
|
||||
import { t } from "i18next";
|
||||
import { IpcRenderToMain } from "../constants";
|
||||
import { getStore } from "./storeManage";
|
||||
import { changeLanguage } from "../i18n";
|
||||
|
||||
const store = getStore();
|
||||
|
||||
export const setIpcMainListener = () => {
|
||||
ipcMain.handle(IpcRenderToMain.clearSession, () => {
|
||||
clearCache();
|
||||
});
|
||||
|
||||
// window manage
|
||||
ipcMain.handle("changeLanguage", (_, locale) => {
|
||||
store.set("language", locale);
|
||||
changeLanguage(locale).then(() => {
|
||||
app.relaunch();
|
||||
app.exit(0);
|
||||
});
|
||||
});
|
||||
ipcMain.handle("main-win-ready", () => {
|
||||
splashEnd();
|
||||
});
|
||||
ipcMain.handle(IpcRenderToMain.showMainWindow, () => {
|
||||
showWindow();
|
||||
});
|
||||
ipcMain.handle(IpcRenderToMain.minimizeWindow, () => {
|
||||
minimize();
|
||||
});
|
||||
ipcMain.handle(IpcRenderToMain.maxmizeWindow, () => {
|
||||
updateMaximize();
|
||||
});
|
||||
ipcMain.handle(IpcRenderToMain.closeWindow, () => {
|
||||
closeWindow();
|
||||
});
|
||||
ipcMain.handle(IpcRenderToMain.showMessageBox, (_, options) => {
|
||||
return dialog
|
||||
.showMessageBox(BrowserWindow.getFocusedWindow(), options)
|
||||
.then((res) => res.response);
|
||||
});
|
||||
|
||||
// data transfer
|
||||
ipcMain.handle(IpcRenderToMain.setKeyStore, (_, { key, data }) => {
|
||||
store.set(key, data);
|
||||
});
|
||||
ipcMain.handle(IpcRenderToMain.getKeyStore, (_, { key }) => {
|
||||
return store.get(key);
|
||||
});
|
||||
ipcMain.on(IpcRenderToMain.getKeyStoreSync, (e, { key }) => {
|
||||
e.returnValue = store.get(key);
|
||||
});
|
||||
ipcMain.handle(IpcRenderToMain.showInputContextMenu, () => {
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: t("system.copy"),
|
||||
type: "normal",
|
||||
role: "copy",
|
||||
accelerator: "CommandOrControl+c",
|
||||
},
|
||||
{
|
||||
label: t("system.paste"),
|
||||
type: "normal",
|
||||
role: "paste",
|
||||
accelerator: "CommandOrControl+v",
|
||||
},
|
||||
{
|
||||
label: t("system.selectAll"),
|
||||
type: "normal",
|
||||
role: "selectAll",
|
||||
accelerator: "CommandOrControl+a",
|
||||
},
|
||||
]);
|
||||
menu.popup({
|
||||
window: BrowserWindow.getFocusedWindow()!,
|
||||
});
|
||||
});
|
||||
ipcMain.on(IpcRenderToMain.getDataPath, (e, key: string) => {
|
||||
switch (key) {
|
||||
case "public":
|
||||
e.returnValue = global.pathConfig.publicPath;
|
||||
break;
|
||||
case "sdkResources":
|
||||
e.returnValue = global.pathConfig.sdkResourcesPath;
|
||||
break;
|
||||
case "logsPath":
|
||||
e.returnValue = global.pathConfig.logsPath;
|
||||
break;
|
||||
default:
|
||||
e.returnValue = global.pathConfig.publicPath;
|
||||
break;
|
||||
}
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user