diff --git a/src/main/tray-items.js b/src/main/tray-items.js new file mode 100644 index 0000000..c5bc8f6 --- /dev/null +++ b/src/main/tray-items.js @@ -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 = [ +]; diff --git a/src/main/tray.js b/src/main/tray.js index 04ecd60..420f365 100644 --- a/src/main/tray.js +++ b/src/main/tray.js @@ -2,32 +2,16 @@ import { Tray, Menu, nativeImage, } from 'electron'; -/** - * @typedef MenuItem - * @type {Electron.MenuItem | Electron.MenuItemConstructorOptions} - */ - -/** - * @typedef TrayItem - * @property {string} iconPath - * @property {MenuItem[]} menus - * @property {string} title - * @property {string} tooltip - */ - -/** - * @desc 托盘项列表 - * @type {TrayItem[]} - */ -const TRAY_ITEMS = [ -]; +import { + TRAY_ITEMS, +} from './tray-items'; /** 初始化托盘项 */ export function initTrayItems() { TRAY_ITEMS.forEach((item) => { let { iconPath, menus } = item; - + let icon = nativeImage.createFromPath(iconPath); let tray = new Tray(icon);