From 271b9ad348f1649faa794be382a7db14e78a7e2d Mon Sep 17 00:00:00 2001 From: Frost-ZX Date: Wed, 11 Jun 2025 09:37:04 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8B=86=E5=88=86=20TRAY=5FITEMS?= =?UTF-8?q?=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/tray-items.js | 19 +++++++++++++++++++ src/main/tray.js | 24 ++++-------------------- 2 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 src/main/tray-items.js 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);