1
0

refactor: 拆分 TRAY_ITEMS 配置

This commit is contained in:
2025-06-11 09:37:04 +08:00
parent cb3e2cc0ce
commit 271b9ad348
2 changed files with 23 additions and 20 deletions

19
src/main/tray-items.js Normal file
View File

@@ -0,0 +1,19 @@
/**
* @typedef MenuItem
* @type {Electron.MenuItem | Electron.MenuItemConstructorOptions}
*/
/**
* @typedef TrayItem
* @property {string} iconPath
* @property {MenuItem[]} menus
* @property {string} title
* @property {string} tooltip
*/
/**
* @desc 托盘项列表
* @type {TrayItem[]}
*/
export const TRAY_ITEMS = [
];

View File

@@ -2,32 +2,16 @@ import {
Tray, Menu, nativeImage, Tray, Menu, nativeImage,
} from 'electron'; } from 'electron';
/** import {
* @typedef MenuItem TRAY_ITEMS,
* @type {Electron.MenuItem | Electron.MenuItemConstructorOptions} } from './tray-items';
*/
/**
* @typedef TrayItem
* @property {string} iconPath
* @property {MenuItem[]} menus
* @property {string} title
* @property {string} tooltip
*/
/**
* @desc 托盘项列表
* @type {TrayItem[]}
*/
const TRAY_ITEMS = [
];
/** 初始化托盘项 */ /** 初始化托盘项 */
export function initTrayItems() { export function initTrayItems() {
TRAY_ITEMS.forEach((item) => { TRAY_ITEMS.forEach((item) => {
let { iconPath, menus } = item; let { iconPath, menus } = item;
let icon = nativeImage.createFromPath(iconPath); let icon = nativeImage.createFromPath(iconPath);
let tray = new Tray(icon); let tray = new Tray(icon);