Skip to content

Commit

Permalink
feat: menu optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
lencx committed Dec 12, 2022
1 parent dea81eb commit 4bedb8b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 15 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
4 changes: 4 additions & 0 deletions UPDATE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# UPDATE LOG

## v0.2.1

feat: menu optimization

## v0.2.0

feat: menu enhancement
Expand Down
15 changes: 8 additions & 7 deletions src-tauri/src/app/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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();
Expand Down
12 changes: 8 additions & 4 deletions src-tauri/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,29 @@ 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,
"theme": "Light",
"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,
"theme": "Light",
"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 {
Expand Down

0 comments on commit 4bedb8b

Please sign in to comment.