From f1fa859961452b77f040d0cc51d8e260a24c2ba0 Mon Sep 17 00:00:00 2001 From: lencx Date: Thu, 29 Dec 2022 19:29:33 +0800 Subject: [PATCH] chore: optim --- README-ZH_CN.md | 2 +- README.md | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/src/app/setup.rs | 4 ++-- src-tauri/src/app/window.rs | 4 ++-- src-tauri/src/main.rs | 3 ++- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README-ZH_CN.md b/README-ZH_CN.md index 2d26cc5..dad137f 100644 --- a/README-ZH_CN.md +++ b/README-ZH_CN.md @@ -58,7 +58,7 @@ cask "popcorn-time", args: { "no-quarantine": true } ![chat cmd](./assets/chat-cmd-1.png) ![chat cmd](./assets/chat-cmd-2.png) -数据导入完成后,可以重新启动应用来使配置生效(`Menu -> Preferences -> Restart ChatGPT`)。 + 在 ChatGPT 文本输入区域,键入 `/` 开头的字符,则会弹出指令提示,按下空格键,它会默认将命令关联的文本填充到输入区域(注意:如果包含多个指令提示,它只会选择第一个作为填充,你可以持续输入,直到第一个提示命令为你想要时,再按下空格键。或者使用鼠标来点击多条指令中的某一个)。填充完成后,你只需要按下回车键即可。斜杠命令下,使用 TAB 键修改 `{q}` 标签内容(仅支持单个修改 [#54](https://github.com/lencx/ChatGPT/issues/54))。使用键盘 `⇧` 和 `⇩`(上下键)来选择斜杠指令。 diff --git a/README.md b/README.md index f745a7b..369ea4f 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ You can look at [awesome-chatgpt-prompts](https://github.com/f/awesome-chatgpt-p ![chat cmd](./assets/chat-cmd-1.png) ![chat cmd](./assets/chat-cmd-2.png) -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)). Use the keyboard `⇧` (arrow up) and `⇩` (arrow down) keys to select the slash command. diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 47c3756..824bcdc 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -24,7 +24,7 @@ csv = "1.1.6" thiserror = "1.0.38" walkdir = "2.3.2" regex = "1.7.0" -# tokio = { version = "1.23.0", features = ["macros"] } +tokio = { version = "1.23.0", features = ["macros"] } # reqwest = "0.11.13" [dependencies.tauri-plugin-log] diff --git a/src-tauri/src/app/setup.rs b/src-tauri/src/app/setup.rs index 2ded0c6..5a77aaf 100644 --- a/src-tauri/src/app/setup.rs +++ b/src-tauri/src/app/setup.rs @@ -9,7 +9,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box let theme = ChatConfJson::theme(); let handle = app.app_handle(); - std::thread::spawn(move || { + tokio::spawn(async move { window::tray_window(&handle); }); @@ -43,7 +43,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box app.set_activation_policy(tauri::ActivationPolicy::Accessory); } else { let app = app.handle(); - std::thread::spawn(move || { + tokio::spawn(async move { #[cfg(target_os = "macos")] WindowBuilder::new(&app, "core", WindowUrl::App(url.into())) .title("ChatGPT") diff --git a/src-tauri/src/app/window.rs b/src-tauri/src/app/window.rs index 64e90cc..55c171e 100644 --- a/src-tauri/src/app/window.rs +++ b/src-tauri/src/app/window.rs @@ -6,7 +6,7 @@ pub fn tray_window(handle: &tauri::AppHandle) { let theme = conf::ChatConfJson::theme(); let app = handle.clone(); - std::thread::spawn(move || { + tokio::spawn(async move { WindowBuilder::new(&app, "tray", WindowUrl::App(chat_conf.origin.into())) .title("ChatGPT") .resizable(false) @@ -28,7 +28,7 @@ pub fn tray_window(handle: &tauri::AppHandle) { pub fn control_window(handle: &tauri::AppHandle) { let app = handle.clone(); - std::thread::spawn(move || { + tokio::spawn(async move { WindowBuilder::new(&app, "main", WindowUrl::App("index.html".into())) .title("ChatGPT") .resizable(true) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index c94338e..7c6d3f3 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -15,7 +15,8 @@ use tauri_plugin_log::{ LogTarget, LoggerBuilder, }; -fn main() { +#[tokio::main] +async fn main() { ChatConfJson::init(); // If the file does not exist, creating the file will block menu synchronization utils::create_chatgpt_prompts();