Files
metona-ollama-desktop/src/main/tray.ts
T
thzxx 0ec6e902de feat: TypeScript + Electron v2.0.0 构建系统完善
- 添加 vite.config.ts 构建配置
- 添加 tsconfig.main.json(主进程单独编译)
- 修复主进程模块化(menu/tray 使用 setQuitting)
- 修复渲染进程导入路径
- 删除旧版 JS/Web 文件(js/、electron/、sw.js、manifest.json)
- 构建验证通过:NSIS 安装包 + 便携版
2026-04-06 03:21:05 +08:00

49 lines
1.0 KiB
TypeScript

/**
* Metona Ollama Desktop - 系统托盘
*/
import { Tray, Menu, nativeImage, app } from 'electron';
import { mainWindow, setQuitting, getIconPath } from './main.js';
let tray: Tray | null = null;
export function createTray(): void {
const icon = nativeImage.createFromPath(getIconPath());
tray = new Tray(icon.resize({ width: 16, height: 16 }));
const contextMenu = Menu.buildFromTemplate([
{
label: '打开 Metona',
click: () => {
mainWindow?.show();
mainWindow?.focus();
}
},
{ type: 'separator' },
{
label: '新建会话',
click: () => {
mainWindow?.show();
mainWindow?.focus();
mainWindow?.webContents.send('tray-action', 'new-chat');
}
},
{ type: 'separator' },
{
label: '退出',
click: () => {
setQuitting();
app.quit();
}
}
]);
tray.setToolTip('Metona Ollama');
tray.setContextMenu(contextMenu);
tray.on('double-click', () => {
mainWindow?.show();
mainWindow?.focus();
});
}