From 39febe759e04077ddf6ce9130ffd1fba466d149e Mon Sep 17 00:00:00 2001 From: lencx Date: Tue, 27 Dec 2022 14:41:50 +0800 Subject: [PATCH 1/6] feat: use the keyboard to select the slash command --- src-tauri/src/app/cmd.rs | 18 +++++-- src-tauri/src/app/setup.rs | 23 ++++++++- src-tauri/src/app/window.rs | 3 -- src-tauri/src/assets/cmd.js | 89 ++++++++++++++++++++++++++-------- src-tauri/src/assets/core.js | 2 - src-tauri/src/assets/export.js | 23 +++++++-- 6 files changed, 124 insertions(+), 34 deletions(-) diff --git a/src-tauri/src/app/cmd.rs b/src-tauri/src/app/cmd.rs index 1da751b..45d077a 100644 --- a/src-tauri/src/app/cmd.rs +++ b/src-tauri/src/app/cmd.rs @@ -1,4 +1,7 @@ -use crate::{conf::ChatConfJson, utils::{self, exists}}; +use crate::{ + conf::ChatConfJson, + utils::{self, exists}, +}; use std::{collections::HashMap, fs, path::PathBuf}; use tauri::{api, command, AppHandle, Manager}; @@ -152,10 +155,15 @@ pub fn sync_prompts(app: AppHandle, data: String, time: u64) { let chatgpt_prompts = chat_root().join("cache_model").join("chatgpt_prompts.json"); if !exists(&model) { - fs::write(&model, serde_json::json!({ - "name": "ChatGPT Model", - "link": "https://github.com/lencx/ChatGPT" - }).to_string()).unwrap(); + fs::write( + &model, + serde_json::json!({ + "name": "ChatGPT Model", + "link": "https://github.com/lencx/ChatGPT" + }) + .to_string(), + ) + .unwrap(); } // chatgpt_prompts.json diff --git a/src-tauri/src/app/setup.rs b/src-tauri/src/app/setup.rs index 7d342a4..8c3eae6 100644 --- a/src-tauri/src/app/setup.rs +++ b/src-tauri/src/app/setup.rs @@ -1,5 +1,5 @@ use crate::{app::window, conf::ChatConfJson, utils}; -use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, Manager}; +use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, GlobalShortcutManager, Manager}; pub fn init(app: &mut App) -> std::result::Result<(), Box> { let chat_conf = ChatConfJson::get_chat_conf(); @@ -11,6 +11,27 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box window::tray_window(&handle); }); + { + let handle = app.app_handle(); + let mut shortcut = app.global_shortcut_manager(); + let is_mini_key = shortcut.is_registered("CmdOrCtrl+Shift+O"); + + if !is_mini_key.unwrap() { + shortcut + .register("CmdOrCtrl+Shift+O", move || { + if let Some(w) = handle.get_window("core") { + if w.is_visible().unwrap() { + w.hide().unwrap(); + } else { + w.show().unwrap(); + w.set_focus().unwrap(); + } + } + }) + .unwrap(); + }; + } + if chat_conf.hide_dock_icon { #[cfg(target_os = "macos")] app.set_activation_policy(tauri::ActivationPolicy::Accessory); diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs index 0ec5a81..64e90cc 100644 --- a/src-tauri/src/app/window.rs +++ b/src-tauri/src/app/window.rs @@ -16,10 +16,7 @@ pub fn tray_window(handle: &tauri::AppHandle) { .always_on_top(true) .theme(theme) .initialization_script(&utils::user_script()) - .initialization_script(include_str!("../assets/html2canvas.js")) - .initialization_script(include_str!("../assets/jspdf.js")) .initialization_script(include_str!("../assets/core.js")) - .initialization_script(include_str!("../assets/export.js")) .initialization_script(include_str!("../assets/cmd.js")) .user_agent(&chat_conf.ua_tray) .build() diff --git a/src-tauri/src/assets/cmd.js b/src-tauri/src/assets/cmd.js index 97164d7..bd7dd14 100644 --- a/src-tauri/src/assets/cmd.js +++ b/src-tauri/src/assets/cmd.js @@ -28,6 +28,9 @@ function init() { .chat-model-cmd-list .cmd-item:last-child { border-bottom: none; } + .chat-model-cmd-list .cmd-item.selected { + background: #fea; + } .chat-model-cmd-list .cmd-item b { display: inline-block; width: 100px; @@ -46,7 +49,16 @@ function init() { white-space: nowrap; text-align: right; color: #888; - }`; + } + .chatappico { + width: 20px; + height: 20px; + } + .chatappico.pdf { + width: 2px; + height: 24px; + } + `; document.head.append(styleDom); if (window.formInterval) { @@ -70,11 +82,24 @@ async function cmdTip() { // fix: tray window if (__TAURI_METADATA__.__currentWindow.label === 'tray') { - modelDom.style.bottom = '40px'; + modelDom.style.bottom = '54px'; } document.querySelector('form').appendChild(modelDom); - const itemDom = (v) => `
/${v.cmd}${v.act}
`; + const itemDom = (v) => `
/${v.cmd}${v.act}
`; + const renderList = (v) => { + modelDom.innerHTML = `
${v.map(itemDom).join('')}
`; + window.__CHAT_MODEL_CMD_PROMPT__ = v[0]?.prompt.trim(); + window.__CHAT_MODEL_CMD__ = v[0]?.cmd.trim(); + window.__list = modelDom.querySelectorAll('.cmd-item'); + window.__index = 0; + window.__list[window.__index].classList.add('selected'); + }; + const setPrompt = (v = '') => { + if (v.trim()) { + window.__CHAT_MODEL_CMD_PROMPT__ = window.__CHAT_MODEL_CMD_PROMPT__?.replace(/\{([^{}]*)\}/, `{${v.trim()}}`); + } + } const searchInput = document.querySelector('form textarea'); // Enter a command starting with `/` and press a space to automatically fill `chatgpt prompt`. @@ -84,6 +109,35 @@ async function cmdTip() { return; } + // ------------------ Keyboard scrolling (ArrowUp | ArrowDown) -------------------------- + if (event.keyCode === 38 && window.__index > 0) { // ArrowUp + window.__list[window.__index].classList.remove('selected'); + window.__index = window.__index - 1; + window.__list[window.__index].classList.add('selected'); + window.__CHAT_MODEL_CMD_PROMPT__ = decodeURIComponent(window.__list[window.__index].getAttribute('data-prompt')); + searchInput.value = `/${window.__list[window.__index].getAttribute('data-cmd')}`; + event.preventDefault(); + } + + if (event.keyCode === 40 && window.__index < window.__list.length - 1) { // ArrowDown + window.__list[window.__index].classList.remove('selected'); + window.__index = window.__index + 1; + window.__list[window.__index].classList.add('selected'); + window.__CHAT_MODEL_CMD_PROMPT__ = decodeURIComponent(window.__list[window.__index].getAttribute('data-prompt')); + searchInput.value = `/${window.__list[window.__index].getAttribute('data-cmd')}`; + event.preventDefault(); + } + + const containerHeight = modelDom.offsetHeight; + const itemHeight = window.__list[0].offsetHeight + 1; + + const itemTop = window.__list[window.__index].offsetTop; + const itemBottom = itemTop + itemHeight; + if (itemTop < modelDom.scrollTop || itemBottom > modelDom.scrollTop + containerHeight) { + modelDom.scrollTop = itemTop; + } + + // ------------------ TAB key replaces `{q}` tag content ------------------------------- // feat: https://github.com/lencx/ChatGPT/issues/54 if (event.keyCode === 9 && !window.__CHAT_MODEL_STATUS__) { const strGroup = window.__CHAT_MODEL_CMD_PROMPT__.match(/\{([^{}]*)\}/) || []; @@ -95,36 +149,37 @@ async function cmdTip() { event.preventDefault(); } - if (window.__CHAT_MODEL_STATUS__ === 1 && event.keyCode === 9) { + if (window.__CHAT_MODEL_STATUS__ === 1 && event.keyCode === 9) { // TAB const data = searchInput.value.split('|->'); if (data[1]?.trim()) { - window.__CHAT_MODEL_CMD_PROMPT__ = window.__CHAT_MODEL_CMD_PROMPT__?.replace(/\{([^{}]*)\}/, `{${data[1]?.trim()}}`); + setPrompt(data[1]); window.__CHAT_MODEL_STATUS__ = 2; } event.preventDefault(); } // input text - if (window.__CHAT_MODEL_STATUS__ === 2 && event.keyCode === 9) { + if (window.__CHAT_MODEL_STATUS__ === 2 && event.keyCode === 9) { // TAB searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__; modelDom.innerHTML = ''; delete window.__CHAT_MODEL_STATUS__; event.preventDefault(); } - // type in a space to complete the fill + // ------------------ type in a space to complete the fill ------------------------------------ if (event.keyCode === 32) { searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__; modelDom.innerHTML = ''; delete window.__CHAT_MODEL_CMD_PROMPT__; } - // send - if (event.keyCode === 13 && window.__CHAT_MODEL_CMD_PROMPT__) { + console.log('«174» /src/assets/cmd.js ~> ', window.__CHAT_MODEL_CMD_PROMPT__); + + + // ------------------ send -------------------------------------------------------------------- + if (event.keyCode === 13 && window.__CHAT_MODEL_CMD_PROMPT__) { // Enter const data = searchInput.value.split('|->'); - if (data[1]?.trim()) { - window.__CHAT_MODEL_CMD_PROMPT__ = window.__CHAT_MODEL_CMD_PROMPT__?.replace(/\{([^{}]*)\}/, `{${data[1]?.trim()}}`); - } + setPrompt(data[1]); searchInput.value = window.__CHAT_MODEL_CMD_PROMPT__; modelDom.innerHTML = ''; @@ -135,7 +190,7 @@ async function cmdTip() { } }); - searchInput.addEventListener('input', (event) => { + searchInput.addEventListener('input', () => { if (searchInput.value === '') { delete window.__CHAT_MODEL_CMD_PROMPT__; delete window.__CHAT_MODEL_CMD__; @@ -152,17 +207,13 @@ async function cmdTip() { // all cmd result if (query === '/') { - modelDom.innerHTML = `
${data.map(itemDom).join('')}
`; - window.__CHAT_MODEL_CMD_PROMPT__ = data[0]?.prompt.trim(); - window.__CHAT_MODEL_CMD__ = data[0]?.cmd.trim(); + renderList(data); return; } const result = data.filter(i => new RegExp(query.substring(1)).test(i.cmd)); if (result.length > 0) { - modelDom.innerHTML = `
${result.map(itemDom).join('')}
`; - window.__CHAT_MODEL_CMD_PROMPT__ = result[0]?.prompt.trim(); - window.__CHAT_MODEL_CMD__ = result[0]?.cmd.trim(); + renderList(result); } else { modelDom.innerHTML = ''; delete window.__CHAT_MODEL_CMD_PROMPT__; diff --git a/src-tauri/src/assets/core.js b/src-tauri/src/assets/core.js index 35715b6..a3b5d72 100644 --- a/src-tauri/src/assets/core.js +++ b/src-tauri/src/assets/core.js @@ -91,8 +91,6 @@ async function init() { const res = await fetch('https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv'); if (res.ok) { const data = await res.text(); - console.log('«94» /src/assets/core.js ~> ', data); - await invoke('sync_prompts', { data, time: Date.now() }); } else { invoke('messageDialog', { diff --git a/src-tauri/src/assets/export.js b/src-tauri/src/assets/export.js index f90a389..f2351e7 100644 --- a/src-tauri/src/assets/export.js +++ b/src-tauri/src/assets/export.js @@ -3,6 +3,7 @@ const buttonOuterHTMLFallback = ``; async function init() { + if (window.innerWidth < 767) return; const chatConf = await invoke('get_chat_conf') || {}; if (window.buttonsInterval) { clearInterval(window.buttonsInterval); @@ -88,7 +89,9 @@ function addActionsButtons(actionsArea, TryAgainButton) { const downloadButton = TryAgainButton.cloneNode(true); downloadButton.id = "download-png-button"; downloadButton.setAttribute("share-ext", "true"); - downloadButton.innerText = "Generate PNG"; + // downloadButton.innerText = "Generate PNG"; + downloadButton.title = "Generate PNG"; + downloadButton.innerHTML = setIcon('png'); downloadButton.onclick = () => { downloadThread(); }; @@ -96,7 +99,9 @@ function addActionsButtons(actionsArea, TryAgainButton) { const downloadPdfButton = TryAgainButton.cloneNode(true); downloadPdfButton.id = "download-pdf-button"; downloadButton.setAttribute("share-ext", "true"); - downloadPdfButton.innerText = "Download PDF"; + // downloadPdfButton.innerText = "Download PDF"; + downloadPdfButton.title = "Download PDF"; + downloadPdfButton.innerHTML = setIcon('pdf'); downloadPdfButton.onclick = () => { downloadThread({ as: Format.PDF }); }; @@ -104,7 +109,9 @@ function addActionsButtons(actionsArea, TryAgainButton) { const exportHtml = TryAgainButton.cloneNode(true); exportHtml.id = "download-html-button"; downloadButton.setAttribute("share-ext", "true"); - exportHtml.innerText = "Share Link"; + // exportHtml.innerText = "Share Link"; + exportHtml.title = "Share Link"; + exportHtml.innerHTML = setIcon('link'); exportHtml.onclick = () => { sendRequest(); }; @@ -269,4 +276,12 @@ if ( init(); } else { document.addEventListener("DOMContentLoaded", init); -} \ No newline at end of file +} + +function setIcon(type) { + return { + link: ``, + png: ``, + pdf: `` + }[type]; +} From ae31da0b29d3bce0115bf1ab2bbf03871775011e Mon Sep 17 00:00:00 2001 From: lencx Date: Tue, 27 Dec 2022 14:54:10 +0800 Subject: [PATCH 2/6] readme --- README-ZH_CN.md | 3 ++- README.md | 5 +++-- UPDATE_LOG.md | 10 ++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README-ZH_CN.md b/README-ZH_CN.md index 185ec87..09f74db 100644 --- a/README-ZH_CN.md +++ b/README-ZH_CN.md @@ -60,7 +60,7 @@ cask "popcorn-time", args: { "no-quarantine": true } 数据导入完成后,可以重新启动应用来使配置生效(`Menu -> Preferences -> Restart ChatGPT`)。 -在 ChatGPT 文本输入区域,键入 `/` 开头的字符,则会弹出指令提示,按下空格键,它会默认将命令关联的文本填充到输入区域(注意:如果包含多个指令提示,它只会选择第一个作为填充,你可以持续输入,直到第一个提示命令为你想要时,再按下空格键。或者使用鼠标来点击多条指令中的某一个)。填充完成后,你只需要按下回车键即可。斜杠命令下,使用 TAB 键修改 `{q}` 标签内容(仅支持单个修改 [#54](https://github.com/lencx/ChatGPT/issues/54))。 +在 ChatGPT 文本输入区域,键入 `/` 开头的字符,则会弹出指令提示,按下空格键,它会默认将命令关联的文本填充到输入区域(注意:如果包含多个指令提示,它只会选择第一个作为填充,你可以持续输入,直到第一个提示命令为你想要时,再按下空格键。或者使用鼠标来点击多条指令中的某一个)。填充完成后,你只需要按下回车键即可。斜杠命令下,使用 TAB 键修改 `{q}` 标签内容(仅支持单个修改 [#54](https://github.com/lencx/ChatGPT/issues/54))。使用键盘 `⇧` 和 `⇩`(上下键)来选择斜杠指令。 ![chatgpt](assets/chatgpt.gif) ![chatgpt-cmd](assets/chatgpt-cmd.gif) @@ -74,6 +74,7 @@ cask "popcorn-time", args: { "no-quarantine": true } - 系统托盘悬浮窗 - 应用菜单功能强大 - 支持斜杠命令及其配置(可手动配置或从文件同步 [#55](https://github.com/lencx/ChatGPT/issues/55)) +- 进入应用的全局快捷键 (mac: `command+shift+o`, windows: `ctrl+shift+o`) ### 菜单项 diff --git a/README.md b/README.md index 5fb48d4..76ae350 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ You can look at [awesome-chatgpt-prompts](https://github.com/f/awesome-chatgpt-p After the data import is done, you can restart the app to make the configuration take effect (`Menu -> Preferences -> Restart ChatGPT`). -In the chatgpt text input area, type a character starting with `/` to bring up the command prompt, press the spacebar, and it will fill the input area with the text associated with the command by default (note: if it contains multiple command prompts, it will only select the first one as the fill, you can keep typing until the first prompted command is the one you want, then press the spacebar. Or use the mouse to click on one of the multiple commands). When the fill is complete, you simply press the Enter key. Under the slash command, use the tab key to modify the contents of the `{q}` tag (only single changes are supported [#54](https://github.com/lencx/ChatGPT/issues/54)). +In the chatgpt text input area, type a character starting with `/` to bring up the command prompt, press the spacebar, and it will fill the input area with the text associated with the command by default (note: if it contains multiple command prompts, it will only select the first one as the fill, you can keep typing until the first prompted command is the one you want, then press the spacebar. Or use the mouse to click on one of the multiple commands). When the fill is complete, you simply press the Enter key. Under the slash command, use the tab key to modify the contents of the `{q}` tag (only single changes are supported [#54](https://github.com/lencx/ChatGPT/issues/54)). Use the keyboard `⇧` (arrow up) and `⇩` (arrow down) keys to select the slash command. ![chatgpt](assets/chatgpt.gif) ![chatgpt-cmd](assets/chatgpt-cmd.gif) @@ -76,6 +76,7 @@ In the chatgpt text input area, type a character starting with `/` to bring up t - System tray hover window - Powerful menu items - Support for slash commands and their configuration (can be configured manually or synchronized from a file [#55](https://github.com/lencx/ChatGPT/issues/55)) +- Global shortcuts to the chatgpt app (mac: `command+shift+o`, windows: `ctrl+shift+o`) ### MenuItem @@ -154,7 +155,7 @@ Currently, only json and csv are supported for synchronizing custom files, and t ## TODO -- Web access capability ([#20](https://github.com/lencx/ChatGPT/issues/20)) + - `Control Center` - Feature Enhancements - ... diff --git a/UPDATE_LOG.md b/UPDATE_LOG.md index 2c41c84..1391bd3 100644 --- a/UPDATE_LOG.md +++ b/UPDATE_LOG.md @@ -1,5 +1,15 @@ # UPDATE LOG +## v0.7.0 + +fix: +- mac m1 copy/paste does not work on some system versions +- optimize the save chat log button to a small icon, the tray window no longer provides a save chat log button (the buttons causes the input area to become larger and the content area to become smaller) + +feat: +- use the keyboard `⇧` (arrow up) and `⇩` (arrow down) keys to select the slash command +- global shortcuts to the chatgpt app (mac: command+shift+o, windows: ctrl+shift+o) + ## v0.6.10 fix: sync failure on windows From d78e2ad0b3ccd729012120fa0757bb1ca96a04cb Mon Sep 17 00:00:00 2001 From: lencx Date: Tue, 27 Dec 2022 15:14:24 +0800 Subject: [PATCH 3/6] chore: cmd --- src-tauri/src/assets/cmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/src/assets/cmd.js b/src-tauri/src/assets/cmd.js index bd7dd14..245454f 100644 --- a/src-tauri/src/assets/cmd.js +++ b/src-tauri/src/assets/cmd.js @@ -55,7 +55,7 @@ function init() { height: 20px; } .chatappico.pdf { - width: 2px; + width: 24px; height: 24px; } `; From 0e0771d0ecf0d7c635b3e7390a9aabbb533fc271 Mon Sep 17 00:00:00 2001 From: lencx Date: Tue, 27 Dec 2022 15:14:49 +0800 Subject: [PATCH 4/6] readme --- README-ZH_CN.md | 6 +++--- README.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README-ZH_CN.md b/README-ZH_CN.md index 09f74db..34c652b 100644 --- a/README-ZH_CN.md +++ b/README-ZH_CN.md @@ -22,9 +22,9 @@ **最新版:** -- `Mac`: [ChatGPT_0.6.10_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.6.10/ChatGPT_0.6.10_x64.dmg) -- `Linux`: [chat-gpt_0.6.10_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.6.10/chat-gpt_0.6.10_amd64.deb) -- `Windows`: [ChatGPT_0.6.10_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.6.10/ChatGPT_0.6.10_x64_en-US.msi) +- `Mac`: [ChatGPT_0.7.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.7.0/ChatGPT_0.7.0_x64.dmg) +- `Linux`: [chat-gpt_0.7.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.0/chat-gpt_0.7.0_amd64.deb) +- `Windows`: [ChatGPT_0.7.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.7.0/ChatGPT_0.7.0_x64_en-US.msi) [其他版本...](https://github.com/lencx/ChatGPT/releases) diff --git a/README.md b/README.md index 76ae350..640f43e 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ **Latest:** -- `Mac`: [ChatGPT_0.6.10_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.6.10/ChatGPT_0.6.10_x64.dmg) -- `Linux`: [chat-gpt_0.6.10_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.6.10/chat-gpt_0.6.10_amd64.deb) -- `Windows`: [ChatGPT_0.6.10_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.6.10/ChatGPT_0.6.10_x64_en-US.msi) +- `Mac`: [ChatGPT_0.7.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.7.0/ChatGPT_0.7.0_x64.dmg) +- `Linux`: [chat-gpt_0.7.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.0/chat-gpt_0.7.0_amd64.deb) +- `Windows`: [ChatGPT_0.7.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.7.0/ChatGPT_0.7.0_x64_en-US.msi) [Other version...](https://github.com/lencx/ChatGPT/releases) From 3428e11b85b29a64ffd5ecf44a322f26fa00417d Mon Sep 17 00:00:00 2001 From: lencx Date: Tue, 27 Dec 2022 15:15:47 +0800 Subject: [PATCH 5/6] v0.7.0 --- src-tauri/tauri.conf.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index bd26562..d2347f7 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -7,7 +7,7 @@ }, "package": { "productName": "ChatGPT", - "version": "0.6.10" + "version": "0.7.0" }, "tauri": { "allowlist": { From fb0319a977f320a56ea93986f55b87710226cbd4 Mon Sep 17 00:00:00 2001 From: xueweiwujxw Date: Tue, 27 Dec 2022 20:50:23 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=F0=9F=90=9E=20fix(src-tauri/src/app/menu.r?= =?UTF-8?q?s):=20fix=20warning=20on=20linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add `#[cfg(target_os = "macos")]` when declare titlebar and titlebar_menu --- src-tauri/src/app/menu.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src-tauri/src/app/menu.rs b/src-tauri/src/app/menu.rs index 8cf63eb..7b3454a 100644 --- a/src-tauri/src/app/menu.rs +++ b/src-tauri/src/app/menu.rs @@ -29,6 +29,7 @@ pub fn init() -> Menu { let stay_on_top = CustomMenuItem::new("stay_on_top".to_string(), "Stay On Top").accelerator("CmdOrCtrl+T"); + #[cfg(target_os = "macos")] let titlebar = CustomMenuItem::new("titlebar".to_string(), "Titlebar").accelerator("CmdOrCtrl+B"); let theme_light = CustomMenuItem::new("theme_light".to_string(), "Light"); @@ -40,6 +41,7 @@ pub fn init() -> Menu { } else { stay_on_top }; + #[cfg(target_os = "macos")] let titlebar_menu = if chat_conf.titlebar { titlebar.selected() } else {