desktop: add more basic menu bar items
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import { Menu, MenuItem, PredefinedMenuItem, Submenu } from "@tauri-apps/api/menu"
|
||||
import { type as ostype } from "@tauri-apps/plugin-os"
|
||||
import { relaunch } from "@tauri-apps/plugin-process"
|
||||
import { openUrl } from "@tauri-apps/plugin-opener"
|
||||
|
||||
import { runUpdater, UPDATER_ENABLED } from "./updater"
|
||||
import { installCli } from "./cli"
|
||||
import { initI18n, t } from "./i18n"
|
||||
import { commands } from "./bindings"
|
||||
|
||||
export async function createMenu() {
|
||||
export async function createMenu(trigger: (id: string) => void) {
|
||||
if (ostype() !== "macos") return
|
||||
|
||||
await initI18n()
|
||||
@@ -60,29 +61,25 @@ export async function createMenu() {
|
||||
}),
|
||||
].filter(Boolean),
|
||||
}),
|
||||
// await Submenu.new({
|
||||
// text: "File",
|
||||
// items: [
|
||||
// await MenuItem.new({
|
||||
// enabled: false,
|
||||
// text: "Open Project...",
|
||||
// }),
|
||||
// await PredefinedMenuItem.new({
|
||||
// item: "Separator"
|
||||
// }),
|
||||
// await MenuItem.new({
|
||||
// enabled: false,
|
||||
// text: "New Session",
|
||||
// }),
|
||||
// await PredefinedMenuItem.new({
|
||||
// item: "Separator"
|
||||
// }),
|
||||
// await MenuItem.new({
|
||||
// enabled: false,
|
||||
// text: "Close Project",
|
||||
// })
|
||||
// ]
|
||||
// }),
|
||||
await Submenu.new({
|
||||
text: "File",
|
||||
items: [
|
||||
await MenuItem.new({
|
||||
text: "New Session",
|
||||
action: () => trigger("session.new"),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: "Open Project...",
|
||||
action: () => trigger("project.open"),
|
||||
}),
|
||||
await PredefinedMenuItem.new({
|
||||
item: "Separator",
|
||||
}),
|
||||
await PredefinedMenuItem.new({
|
||||
item: "CloseWindow",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
await Submenu.new({
|
||||
text: "Edit",
|
||||
items: [
|
||||
@@ -109,6 +106,79 @@ export async function createMenu() {
|
||||
}),
|
||||
],
|
||||
}),
|
||||
await Submenu.new({
|
||||
text: "View",
|
||||
items: [
|
||||
await MenuItem.new({
|
||||
action: () => trigger("sidebar.toggle"),
|
||||
text: "Toggle Sidebar",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => trigger("terminal.toggle"),
|
||||
text: "Toggle Terminal",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => trigger("fileTree.toggle"),
|
||||
text: "Toggle File Tree",
|
||||
}),
|
||||
await PredefinedMenuItem.new({
|
||||
item: "Separator",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => trigger("common.goBack"),
|
||||
text: "Back",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => trigger("common.goForward"),
|
||||
text: "Forward",
|
||||
}),
|
||||
await PredefinedMenuItem.new({
|
||||
item: "Separator",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => trigger("session.next"),
|
||||
text: "Previous Session",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => trigger("session.previous"),
|
||||
text: "Next Session",
|
||||
}),
|
||||
await PredefinedMenuItem.new({
|
||||
item: "Separator",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
await Submenu.new({
|
||||
text: "Help",
|
||||
items: [
|
||||
// missing native macos search
|
||||
await MenuItem.new({
|
||||
action: () => openUrl("https://opencode.ai/docs"),
|
||||
text: "OpenCode Documentation",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => openUrl("https://discord.com/invite/opencode"),
|
||||
text: "Support Forum",
|
||||
}),
|
||||
await PredefinedMenuItem.new({
|
||||
item: "Separator",
|
||||
}),
|
||||
// await MenuItem.new({
|
||||
// text: "Release Notes",
|
||||
// }),
|
||||
await PredefinedMenuItem.new({
|
||||
item: "Separator",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => openUrl("https://github.com/anomalyco/opencode/issues/new?template=feature_request.yml"),
|
||||
text: "Share Feedback",
|
||||
}),
|
||||
await MenuItem.new({
|
||||
action: () => openUrl("https://github.com/anomalyco/opencode/issues/new?template=bug_report.yml"),
|
||||
text: "Report a Bug",
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
})
|
||||
menu.setAsAppMenu()
|
||||
|
||||
Reference in New Issue
Block a user