feat: 新增多插件 UI 支持及运行日志集中回传功能
本次提交包含多项功能更新: 1. 为多个插件(xq0002/0003/0004/0008/0010/0011/0020/0031_xq0032/0033/0035/0037/0045_xq0046/0047/0048)新增 UI 界面及配置支持 2. 新增运行日志集中回传功能,客户端自动上传运行日志到中心机集中存储 3. 新增插件分类字段支持,用于场景库分组管理 4. 优化 xq0034/0037/0048 等插件的功能及描述 5. 修复控制面响应兼容问题,支持新旧版本数据格式 6. 新增 xq0033 插件的状态存储模块,用于历史记录管理 7. 优化 CRM 登录窗口模式,支持全屏置顶
This commit is contained in:
@@ -2,10 +2,11 @@
|
||||
"use strict";
|
||||
|
||||
const fs = require("fs");
|
||||
const { app, BrowserWindow, Tray, Menu, nativeImage, dialog, screen } = require("electron");
|
||||
const { app, BrowserWindow, Tray, Menu, nativeImage, dialog, screen, ipcMain } = require("electron");
|
||||
const path = require("path");
|
||||
const config = require("./config");
|
||||
const { makeLogger } = require("./logger");
|
||||
const trayMenu = require("./tray-menu");
|
||||
|
||||
const logger = makeLogger("electron-main");
|
||||
|
||||
@@ -82,8 +83,10 @@ if (!app.requestSingleInstanceLock()) {
|
||||
y: st.y,
|
||||
minWidth: 1000,
|
||||
minHeight: 660,
|
||||
// 与启动页默认皮肤底色一致(style.css --bg #F9F7F2),避免冷启动色跳
|
||||
backgroundColor: "#F9F7F2",
|
||||
// 无边框窗口:顶栏由渲染层自绘(含窗口控制钮 / 面包屑 / 服务状态)
|
||||
frame: false,
|
||||
// 与启动页画布底色一致(style.css --canvas #F2F4F8),避免冷启动色跳
|
||||
backgroundColor: "#F2F4F8",
|
||||
title: "37du 自动化工作台",
|
||||
icon: trayIconImage(),
|
||||
webPreferences: {
|
||||
@@ -94,6 +97,14 @@ if (!app.requestSingleInstanceLock()) {
|
||||
},
|
||||
});
|
||||
mainWindow.loadURL(URL);
|
||||
// 推送最大化状态变化:渲染层顶栏切换最大化/还原图标
|
||||
const sendMaxState = () => {
|
||||
if (mainWindow && !mainWindow.isDestroyed()) {
|
||||
mainWindow.webContents.send("win:maximized", mainWindow.isMaximized());
|
||||
}
|
||||
};
|
||||
mainWindow.on("maximize", sendMaxState);
|
||||
mainWindow.on("unmaximize", sendMaxState);
|
||||
// 关闭时保存窗口状态;resize/move 防抖保存(异常退出也不丢太多)
|
||||
let stateTimer = null;
|
||||
const save = () => {
|
||||
@@ -119,6 +130,16 @@ if (!app.requestSingleInstanceLock()) {
|
||||
});
|
||||
}
|
||||
|
||||
// 无边框窗口控制 IPC:渲染层自绘顶栏的窗口控制钮走这里(fire-and-forget)
|
||||
ipcMain.on("win:min", () => { if (mainWindow && !mainWindow.isDestroyed()) mainWindow.minimize(); });
|
||||
ipcMain.on("win:max", () => {
|
||||
if (!mainWindow || mainWindow.isDestroyed()) return;
|
||||
if (mainWindow.isMaximized()) mainWindow.unmaximize();
|
||||
else mainWindow.maximize();
|
||||
});
|
||||
// 关闭 = 走 close 拦截逻辑(默认收托盘,托盘「退出」才真正退出)
|
||||
ipcMain.on("win:close", () => { if (mainWindow && !mainWindow.isDestroyed()) mainWindow.close(); });
|
||||
|
||||
function trayIconImage() {
|
||||
// 优先用官方图标(Windows 托盘/窗口均正常渲染);缺失时 SVG 兜底。
|
||||
// 打包态:resources/assets/icon.ico(extraResources 真实文件);开发态:本模块 assets/
|
||||
@@ -134,35 +155,21 @@ if (!app.requestSingleInstanceLock()) {
|
||||
return nativeImage.createFromDataURL(`data:image/svg+xml;base64,${Buffer.from(svg).toString("base64")}`);
|
||||
}
|
||||
|
||||
function openWorkbench() {
|
||||
// 关闭窗口只是收托盘(窗口仍存在),此处复用已有窗口而非重复新建
|
||||
if (!mainWindow) createWindow();
|
||||
else { mainWindow.show(); mainWindow.focus(); }
|
||||
}
|
||||
|
||||
function createTray() {
|
||||
tray = new Tray(trayIconImage());
|
||||
const ctx = Menu.buildFromTemplate([
|
||||
{
|
||||
label: "打开工作台",
|
||||
click: () => {
|
||||
// 关闭窗口只是收托盘(窗口仍存在),此处复用已有窗口而非重复新建
|
||||
if (!mainWindow) createWindow();
|
||||
else { mainWindow.show(); mainWindow.focus(); }
|
||||
},
|
||||
},
|
||||
{ type: "separator" },
|
||||
{
|
||||
label: "开机自启",
|
||||
type: "checkbox",
|
||||
checked: app.getLoginItemSettings().openAtLogin,
|
||||
click: (item) => {
|
||||
app.setLoginItemSettings({ openAtLogin: item.checked });
|
||||
},
|
||||
},
|
||||
{ type: "separator" },
|
||||
{ label: "退出", click: () => app.quit() },
|
||||
]);
|
||||
tray.setToolTip("37du 自动化工作台");
|
||||
tray.setContextMenu(ctx);
|
||||
tray.on("click", () => {
|
||||
if (!mainWindow) createWindow();
|
||||
else mainWindow.show();
|
||||
// 右键菜单用自绘卡片弹窗(系统原生菜单样式跟随系统、无法统一视觉)
|
||||
trayMenu.attach(tray, {
|
||||
onOpen: openWorkbench,
|
||||
onQuit: () => app.quit(),
|
||||
});
|
||||
tray.on("click", openWorkbench);
|
||||
}
|
||||
|
||||
app.whenReady().then(async () => {
|
||||
|
||||
Reference in New Issue
Block a user