feat: menu optimization

This commit is contained in:
lencx 2022-12-12 19:19:10 +08:00
parent dea81eb3d9
commit 4bedb8b5c1
4 changed files with 29 additions and 15 deletions

View File

@ -56,23 +56,28 @@ cask "popcorn-time", args: { "no-quarantine": true }
### Menu
- **ChatGPT**
- `Restart ChatGPT`: After editing the injection script file, you can restart the application through this menu item to make the script take effect.
- **Preferences**
- `Theme` - `Light`, `Dark` (Only macOS and Windows are supported).
- `Always On Top`: Window is always on top of other windows.
- `Titlebar`: Only supports macOS.
- `User Agent` ([#17](https://github.com/lencx/ChatGPT/issues/17)): Customize `user agent` to prevent security detection interception.
- `User Agent` ([#17](https://github.com/lencx/ChatGPT/issues/17)): Customize `user agent` to prevent security detection interception. Default is empty string.
- `Inject Script`: User scripts that can modify web pages.
- `Switch Origin` ([#14](https://github.com/lencx/ChatGPT/issues/14)): Modify website address, the default is `https://chat.openai.com`. Please ensure that the mirror address is consistent with the UI of the original URL, otherwise the export function will fail.
- `Clear Config`: Clear all chatgpt configuration files (`path: ~/.chatgpt/*`), dangerous operation, please backup data.
- `Inject Script`: User scripts that can modify web pages.
- `Restart ChatGPT`: After editing the injection script file, you can restart the application through this menu item to make the script take effect.
- `Awesome ChatGPT`: Related resources recommended.
- **Edit** - `Undo`, `Redo`, `Cut`, `Copy`, `SelectAll`, ...
- **View** - `Go Back`, `Go Forward`, `Scroll to Top of Screen`, `Scroll to Bottom of Screen`, `Refresh the Screen`, ...
- **Help**
- `Update Log`: ChatGPT app changelog.
- `Report Bug`: Defects and Suggestions Feedback.
- `Toggle Developer Tools`: Developer tools for debugging web pages.
## TODO
- web access capability ([#20](https://github.com/lencx/ChatGPT/issues/20))
- ...
## 👀 Preview
<img width="320" src="./assets/install.png" alt="install"> <img width="320" src="./assets/chat.png" alt="chat">

View File

@ -1,5 +1,9 @@
# UPDATE LOG
## v0.2.1
feat: menu optimization
## v0.2.0
feat: menu enhancement

View File

@ -17,11 +17,6 @@ pub fn init(context: &Context<EmbeddedAssets>) -> Menu {
name,
Menu::new()
.add_native_item(MenuItem::About(name.into(), AboutMetadata::default()))
.add_native_item(MenuItem::Separator)
.add_item(
CustomMenuItem::new("restart".to_string(), "Restart ChatGPT")
.accelerator("CmdOrCtrl+Shift+R"),
)
.add_native_item(MenuItem::Services)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Hide)
@ -71,6 +66,7 @@ pub fn init(context: &Context<EmbeddedAssets>) -> Menu {
always_on_top_menu.into(),
#[cfg(target_os = "macos")]
titlebar_menu.into(),
MenuItem::Separator.into(),
// fix: Checking if the site connection is secure
// @link: https://github.com/lencx/ChatGPT/issues/17
CustomMenuItem::new("user_agent".to_string(), "User Agent")
@ -82,9 +78,13 @@ pub fn init(context: &Context<EmbeddedAssets>) -> Menu {
CustomMenuItem::new("inject_script".to_string(), "Inject Script")
.accelerator("CmdOrCtrl+J")
.into(),
MenuItem::Separator.into(),
CustomMenuItem::new("clear_conf".to_string(), "Clear Config")
.accelerator("CmdOrCtrl+D")
.into(),
CustomMenuItem::new("restart".to_string(), "Restart ChatGPT")
.accelerator("CmdOrCtrl+Shift+R")
.into(),
MenuItem::Separator.into(),
CustomMenuItem::new("awesome".to_string(), "Awesome ChatGPT")
.accelerator("CmdOrCtrl+Z")
@ -133,6 +133,7 @@ pub fn init(context: &Context<EmbeddedAssets>) -> Menu {
let help_menu = Submenu::new(
"Help",
Menu::new()
.add_item(CustomMenuItem::new("update_log".to_string(), "Update Log"))
.add_item(CustomMenuItem::new("report_bug".to_string(), "Report Bug"))
.add_item(
CustomMenuItem::new("dev_tools".to_string(), "Toggle Developer Tools")
@ -160,9 +161,8 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
let menu_handle = core_window.menu_handle();
match menu_id {
// App
"restart" => tauri::api::process::restart(&app.env()),
// Preferences
"restart" => tauri::api::process::restart(&app.env()),
"inject_script" => open(&app, script_path),
"clear_conf" => utils::clear_conf(&app),
"switch_origin" => window::origin_window(&app),
@ -214,6 +214,7 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
)
.unwrap(),
// Help
"update_log" => open(&app, conf::UPDATE_LOG_URL.to_string()),
"report_bug" => open(&app, conf::ISSUES_URL.to_string()),
"dev_tools" => {
win.open_devtools();

View File

@ -7,7 +7,11 @@ use tauri::Theme;
#[cfg(target_os = "macos")]
use tauri::TitleBarStyle;
// pub const USER_AGENT: &str = "5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36";
// pub const PHONE_USER_AGENT: &str = "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1";
pub const ISSUES_URL: &str = "https://github.com/lencx/ChatGPT/issues";
pub const UPDATE_LOG_URL: &str = "https://github.com/lencx/ChatGPT/blob/main/UPDATE_LOG.md";
pub const AWESOME_URL: &str = "https://github.com/lencx/ChatGPT/blob/main/AWESOME.md";
pub const DEFAULT_CHAT_CONF: &str = r#"{
"always_on_top": false,
@ -15,8 +19,8 @@ pub const DEFAULT_CHAT_CONF: &str = r#"{
"titlebar": true,
"default_origin": "https://chat.openai.com",
"origin": "https://chat.openai.com",
"ua_pc": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
"ua_phone": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"
"ua_pc": "",
"ua_phone": ""
}"#;
pub const DEFAULT_CHAT_CONF_MAC: &str = r#"{
"always_on_top": false,
@ -24,8 +28,8 @@ pub const DEFAULT_CHAT_CONF_MAC: &str = r#"{
"titlebar": false,
"default_origin": "https://chat.openai.com",
"origin": "https://chat.openai.com",
"ua_pc": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
"ua_phone": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"
"ua_pc": "",
"ua_phone": ""
}"#;
pub struct ChatState {