@ytchuan/flowlink 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +176 -0
  2. package/app-ui/dist/assets/BaseCard-BquKu8iW.js +1 -0
  3. package/app-ui/dist/assets/BaseCard-vDGVmnfA.css +1 -0
  4. package/app-ui/dist/assets/ConsumptionView-Bv1BmzJZ.css +1 -0
  5. package/app-ui/dist/assets/ConsumptionView-CKpT-R7X.js +1 -0
  6. package/app-ui/dist/assets/HomeView-BXZYBUAv.js +1 -0
  7. package/app-ui/dist/assets/HomeView-C0c8S1Ss.css +1 -0
  8. package/app-ui/dist/assets/MetricCard-CIRjcKHO.css +1 -0
  9. package/app-ui/dist/assets/MetricCard-irffmzJu.js +1 -0
  10. package/app-ui/dist/assets/PackageView-C0KTgqoW.css +1 -0
  11. package/app-ui/dist/assets/PackageView-DzGcYqiI.js +1 -0
  12. package/app-ui/dist/assets/SettingsView-CKxlifru.js +2 -0
  13. package/app-ui/dist/assets/SettingsView-Co_5arPi.css +1 -0
  14. package/app-ui/dist/assets/StatusBadge-BeZad7-E.js +1 -0
  15. package/app-ui/dist/assets/StatusBadge-jZK8Ckfn.css +1 -0
  16. package/app-ui/dist/assets/index-C2wBeAgU.js +2269 -0
  17. package/app-ui/dist/assets/index-EXys6EPN.css +1 -0
  18. package/app-ui/dist/index.html +13 -0
  19. package/assets/icon.icns +0 -0
  20. package/assets/icon.ico +0 -0
  21. package/assets/logo256.png +0 -0
  22. package/assets/logo512.png +0 -0
  23. package/bin/flowlink.js +24 -0
  24. package/main.js +315 -0
  25. package/package.json +88 -0
  26. package/preload.js +103 -0
  27. package/resources/tray-icon.png +0 -0
  28. package/services/config-writer.js +415 -0
  29. package/services/device.js +104 -0
  30. package/services/scanner.js +254 -0
  31. package/services/scheduler.js +197 -0
  32. package/services/selfcheck.js +154 -0
  33. package/services/settings.js +58 -0
  34. package/services/tray.js +110 -0
  35. package/services/updater.js +26 -0
@@ -0,0 +1,110 @@
1
+ /**
2
+ * 系统托盘
3
+ * 创建托盘图标、右键菜单、通知
4
+ */
5
+ const { app, Tray, Menu, nativeImage, BrowserWindow, Notification, ipcMain } = require('electron')
6
+ const path = require('path')
7
+
8
+ let tray = null
9
+ let mainWindow = null
10
+
11
+ /** 创建托盘 */
12
+ function createTray(win) {
13
+ mainWindow = win
14
+
15
+ // 打包后图标在 extraResources 目录(app.asar 之外),开发模式在项目 resources 目录
16
+ const iconPath = app.isPackaged
17
+ ? path.join(process.resourcesPath, 'resources', 'tray-icon.png')
18
+ : path.join(__dirname, '..', 'resources', 'tray-icon.png')
19
+ let icon
20
+ try {
21
+ icon = nativeImage.createFromPath(iconPath)
22
+ if (icon.isEmpty()) {
23
+ // 降级:使用 16x16 空白图标
24
+ icon = nativeImage.createEmpty()
25
+ } else if (process.platform === 'win32') {
26
+ // Windows 托盘按 16x16(高 DPI 下 32x32)显示,原图过大需缩放,否则显示异常
27
+ icon = icon.resize({ width: 32, height: 32 })
28
+ }
29
+ } catch {
30
+ icon = nativeImage.createEmpty()
31
+ }
32
+
33
+ tray = new Tray(icon)
34
+ tray.setToolTip('FlowLink 调度服务')
35
+
36
+ // macOS: 点击托盘显示窗口
37
+ tray.on('click', () => {
38
+ if (mainWindow) {
39
+ if (mainWindow.isVisible()) {
40
+ mainWindow.focus()
41
+ } else {
42
+ mainWindow.show()
43
+ }
44
+ }
45
+ })
46
+
47
+ updateTrayMenu()
48
+
49
+ return tray
50
+ }
51
+
52
+ /** 更新托盘菜单 */
53
+ function updateTrayMenu(schedulerRunning = false) {
54
+ if (!tray) return
55
+
56
+ const contextMenu = Menu.buildFromTemplate([
57
+ {
58
+ label: 'FlowLink',
59
+ enabled: false,
60
+ },
61
+ { type: 'separator' },
62
+ {
63
+ label: schedulerRunning ? '服务运行中' : '服务未运行',
64
+ enabled: false,
65
+ },
66
+ { type: 'separator' },
67
+ {
68
+ label: '显示主窗口',
69
+ click: () => {
70
+ if (mainWindow) {
71
+ mainWindow.show()
72
+ mainWindow.focus()
73
+ }
74
+ },
75
+ },
76
+ {
77
+ label: '退出',
78
+ click: () => {
79
+ app.quit()
80
+ },
81
+ },
82
+ ])
83
+
84
+ tray.setContextMenu(contextMenu)
85
+ }
86
+
87
+ /**
88
+ * 显示系统通知
89
+ * @param {string} title
90
+ * @param {string} body
91
+ */
92
+ function showNotification(title, body) {
93
+ if (Notification.isSupported()) {
94
+ const notification = new Notification({ title, body })
95
+ notification.show()
96
+ }
97
+ }
98
+
99
+ /**
100
+ * 显示强提醒弹窗(通过 IPC 发送到渲染进程)
101
+ * @param {string} title
102
+ * @param {string} body
103
+ */
104
+ function showAlertModal(title, body) {
105
+ if (mainWindow && !mainWindow.isDestroyed()) {
106
+ mainWindow.webContents.send('tray:alert', { title, body })
107
+ }
108
+ }
109
+
110
+ module.exports = { createTray, updateTrayMenu, showNotification, showAlertModal }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * 应用更新检查
3
+ * 当前返回无更新(后续接入自动更新机制)
4
+ */
5
+ const { app } = require('electron')
6
+
7
+ /**
8
+ * 检查更新
9
+ * @returns {Promise<{ hasUpdate: boolean, latestVersion?: string, downloadUrl?: string, releaseNotes?: string }>}
10
+ */
11
+ async function checkForUpdate() {
12
+ const currentVersion = app.getVersion()
13
+
14
+ // TODO: 接入真实的更新检查逻辑
15
+ // 可选方案:
16
+ // 1. electron-updater (electron-builder)
17
+ // 2. 自定义 HTTP 请求检查版本
18
+ // 3. GitHub Releases API
19
+
20
+ return {
21
+ hasUpdate: false,
22
+ latestVersion: currentVersion,
23
+ }
24
+ }
25
+
26
+ module.exports = { checkForUpdate }