mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 04:31:27 +08:00
- Update all TipTap packages from v3.2.0 to v3.7.2 including core extensions and dependencies - Add new highlight extension with Markdown support using ==text== syntax - Replace custom markdown converter with TipTap's built-in Markdown extension - Simplify link handling by using standard TipTap link extension instead of enhancedLink - Add view menu to app menu service for better Electron app navigation
55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import { isMac } from '@main/constant'
|
|
import { windowService } from '@main/services/WindowService'
|
|
import { locales } from '@main/utils/locales'
|
|
import { IpcChannel } from '@shared/IpcChannel'
|
|
import { app, Menu, MenuItemConstructorOptions } from 'electron'
|
|
|
|
import { configManager } from './ConfigManager'
|
|
export class AppMenuService {
|
|
public setupApplicationMenu(): void {
|
|
const locale = locales[configManager.getLanguage()]
|
|
const { common } = locale.translation
|
|
|
|
const template: MenuItemConstructorOptions[] = [
|
|
{
|
|
label: app.name,
|
|
submenu: [
|
|
{
|
|
label: common.about + ' ' + app.name,
|
|
click: () => {
|
|
// Emit event to navigate to About page
|
|
const mainWindow = windowService.getMainWindow()
|
|
if (mainWindow && !mainWindow.isDestroyed()) {
|
|
mainWindow.webContents.send(IpcChannel.Windows_NavigateToAbout)
|
|
windowService.showMainWindow()
|
|
}
|
|
}
|
|
},
|
|
{ type: 'separator' },
|
|
{ role: 'services' },
|
|
{ type: 'separator' },
|
|
{ role: 'hide' },
|
|
{ role: 'hideOthers' },
|
|
{ role: 'unhide' },
|
|
{ type: 'separator' },
|
|
{ role: 'quit' }
|
|
]
|
|
},
|
|
{
|
|
role: 'editMenu'
|
|
},
|
|
{
|
|
role: 'viewMenu'
|
|
},
|
|
{
|
|
role: 'windowMenu'
|
|
}
|
|
]
|
|
|
|
const menu = Menu.buildFromTemplate(template)
|
|
Menu.setApplicationMenu(menu)
|
|
}
|
|
}
|
|
|
|
export const appMenuService = isMac ? new AppMenuService() : null
|