File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,8 @@ import { fileURLToPath } from 'url'
33import path from 'path'
44import { readFile } from 'fs/promises'
55
6+ import { update } from './updater.js'
7+
68const __dirname = fileURLToPath ( new URL ( '.' , import . meta. url ) )
79
810const packagePath = path . join ( __dirname , 'package.json' )
@@ -37,8 +39,20 @@ app.whenReady().then(() => {
3739 // 克隆原有菜单结构(支持嵌套)
3840 const newTemplate = applicationMenu . items . map ( convertMenuItem )
3941
40- // 查找 Help 菜单:中英文适配
41- const helpMenu = newTemplate . find ( ( item ) => item . label === 'Help' || item . label === '帮助' )
42+ // 查找 appmenu 菜单
43+ const appmenuMenu = newTemplate . find ( ( item ) => item . role === 'appmenu' )
44+ const aboutIndex = appmenuMenu . submenu . findIndex ( ( item ) => item . role === 'about' )
45+ if ( aboutIndex !== - 1 ) {
46+ appmenuMenu . submenu . splice ( aboutIndex + 1 , 0 , {
47+ label : 'Check for Updates' ,
48+ click : function ( ) {
49+ update ( )
50+ } ,
51+ } )
52+ }
53+
54+ // 查找 help 菜单
55+ const helpMenu = newTemplate . find ( ( item ) => item . role === 'help' )
4256
4357 if ( helpMenu ) {
4458 // 初始化 submenu 数组(如果不存在)
Original file line number Diff line number Diff line change @@ -36,3 +36,9 @@ app.on('ready', function () {
3636 logUpdater . info ( 'UpdateCheckResult.updateInfo:\n' , updateCheckResult . updateInfo )
3737 } )
3838} )
39+
40+ export const update = function ( ) {
41+ electronUpdater . autoUpdater . checkForUpdates ( ) . then ( ( resp ) => {
42+ logUpdater . info ( '手动触发更新菜单结果' , resp )
43+ } )
44+ }
You can’t perform that action at this time.
0 commit comments