v0.6.0: beautifului 整合 + 会话/工作区/队列/权限/命令/附件全链路

- beautifului.dev 组件直连:Sidebar Nav、Tool Chips、Approval Card(抽屉化)、Streaming/Thinking、Code Block、Selection Actions、Prompt Bar、Search
This commit is contained in:
Rick Ye
2026-09-06 09:57:14 +08:00
parent 3c2e9e96c5
commit a5951849c8
96 changed files with 11828 additions and 4649 deletions
+50 -6
View File
@@ -1,14 +1,35 @@
import { app, BrowserWindow, shell } from 'electron'
import { app, BrowserWindow, ipcMain, Menu, shell } from 'electron'
import { existsSync } from 'node:fs'
import { join } from 'node:path'
import { registerIpc } from './ipc'
process.env.APP_ROOT = join(__dirname, '..')
export const VITE_DEV_SERVER_URL = process.env.VITE_DEV_SERVER_URL
export const VITE_DEV_SERVER_URL = process.env.ELECTRON_RENDERER_URL ?? process.env.VITE_DEV_SERVER_URL
export const RENDERER_DIST = join(process.env.APP_ROOT, 'renderer')
/** 应用图标(build/icon.ico,由 scripts/make-icons.cjs 从 build/icon.svg 生成) */
const APP_ICON = join(app.getAppPath(), 'build', 'icon.ico')
const agentService = registerIpc()
/** 窗口控制(自绘标题栏按钮走这三个 IPC;不使用系统 WCO,
* 否则 overlay 的原生白色背景会盖住标题栏分隔线) */
function registerWindowControls(): void {
ipcMain.handle('win:minimize', (event) => {
BrowserWindow.fromWebContents(event.sender)?.minimize()
})
ipcMain.handle('win:toggleMaximize', (event) => {
const win = BrowserWindow.fromWebContents(event.sender)
if (!win) return
if (win.isMaximized()) win.unmaximize()
else win.maximize()
})
ipcMain.handle('win:close', (event) => {
BrowserWindow.fromWebContents(event.sender)?.close()
})
}
async function createWindow(): Promise<void> {
const win = new BrowserWindow({
width: 1280,
@@ -16,8 +37,12 @@ async function createWindow(): Promise<void> {
minWidth: 960,
minHeight: 640,
show: false,
backgroundColor: '#09090b',
title: '店铺运营 Agent',
backgroundColor: '#ffffff',
title: 'Inkreach Agent',
// 窗口/任务栏图标(Windows/Linux;macOS 打包时由 build 配置提供 icns)
...(existsSync(APP_ICON) ? { icon: APP_ICON } : {}),
// 无原生标题栏/菜单栏,标题栏与窗口控制按钮全部由渲染层 TitleBar 自绘
titleBarStyle: 'hidden',
webPreferences: {
preload: join(__dirname, '../preload/index.cjs'),
sandbox: false,
@@ -26,6 +51,18 @@ async function createWindow(): Promise<void> {
}
})
// 最大化状态同步给渲染层(切换「最大化/还原」字形)
const sendWinState = (): void => win.webContents.send('win:state', win.isMaximized())
win.on('maximize', sendWinState)
win.on('unmaximize', sendWinState)
// 默认应用菜单已移除(File/Edit/View 不再显示),F12 补回 DevTools 开关
win.webContents.on('before-input-event', (_event, input) => {
if (input.type === 'keyDown' && input.key === 'F12') {
win.webContents.toggleDevTools()
}
})
win.on('ready-to-show', () => {
win.show()
// pi 会话初始化放在窗口就绪后,错误可以第一时间在 UI 上呈现
@@ -46,8 +83,8 @@ async function createWindow(): Promise<void> {
})
// 渲染层日志/加载失败转发到主进程 stdout,便于排查白屏/黑屏问题
win.webContents.on('console-message', (_e, level, message, line, sourceId) => {
console.log(`[renderer:${level}] ${message} (${sourceId}:${line})`)
win.webContents.on('console-message', (details) => {
console.log(`[renderer:${details.level}] ${details.message} (${details.sourceId}:${details.lineNumber})`)
})
win.webContents.on('did-fail-load', (_e, code, desc, url) => {
console.log(`[renderer:load-fail] ${code} ${desc} ${url}`)
@@ -79,6 +116,11 @@ if (!app.requestSingleInstanceLock()) {
})
void app.whenReady().then(() => {
// Windows 任务栏归组的 AppUserModelID
if (process.platform === 'win32') {
app.setAppUserModelId('com.inkreach.agent')
}
Menu.setApplicationMenu(null)
void createWindow()
app.on('activate', () => {
@@ -89,4 +131,6 @@ if (!app.requestSingleInstanceLock()) {
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})
registerWindowControls()
}