mirror of
https://github.com/marktext/marktext.git
synced 2025-05-04 03:51:01 +08:00
use fallback menu (#1008)
This commit is contained in:
parent
68be52a87d
commit
f45ec9d525
@ -84,6 +84,12 @@ class WindowManager extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
add (window) {
|
add (window) {
|
||||||
this._windows.set(window.id, window)
|
this._windows.set(window.id, window)
|
||||||
|
|
||||||
|
if (!this._appMenu.has(window.id)) {
|
||||||
|
// TODO: Build a default menu for macOS.
|
||||||
|
this._appMenu.addMenu(window.id, null)
|
||||||
|
}
|
||||||
|
|
||||||
if (this.windowCount === 1) {
|
if (this.windowCount === 1) {
|
||||||
this.setActiveWindow(window.id)
|
this.setActiveWindow(window.id)
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,11 @@ class AppMenu {
|
|||||||
fs.writeFileSync(RECENTS_PATH, json, 'utf-8')
|
fs.writeFileSync(RECENTS_PATH, json, 'utf-8')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addMenu (windowId, menu=null) {
|
||||||
|
const { windowMenus } = this
|
||||||
|
windowMenus.set(windowId, { menu })
|
||||||
|
}
|
||||||
|
|
||||||
addEditorMenu (window) {
|
addEditorMenu (window) {
|
||||||
const { windowMenus } = this
|
const { windowMenus } = this
|
||||||
windowMenus.set(window.id, this.buildDefaultMenu(true))
|
windowMenus.set(window.id, this.buildDefaultMenu(true))
|
||||||
@ -126,12 +131,16 @@ class AppMenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getWindowMenuById (windowId) {
|
getWindowMenuById (windowId) {
|
||||||
const { menu } = this.windowMenus.get(windowId)
|
const menu = this.windowMenus.get(windowId)
|
||||||
if (!menu) {
|
if (!menu) {
|
||||||
log.error(`getWindowMenuById: Cannot find window menu for id ${windowId}.`)
|
log.error(`getWindowMenuById: Cannot find window menu for id ${windowId}.`)
|
||||||
throw new Error(`Cannot find window menu for id ${windowId}.`)
|
throw new Error(`Cannot find window menu for id ${windowId}.`)
|
||||||
}
|
}
|
||||||
return menu
|
return menu.menu
|
||||||
|
}
|
||||||
|
|
||||||
|
has (windowId) {
|
||||||
|
return this.windowMenus.has(windowId)
|
||||||
}
|
}
|
||||||
|
|
||||||
setActiveWindow (windowId) {
|
setActiveWindow (windowId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user