mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
Merge branch 'main' into dev
This commit is contained in:
@@ -12,47 +12,49 @@
|
|||||||
[](https://discord.gg/aPhCRf4zZr)
|
[](https://discord.gg/aPhCRf4zZr)
|
||||||
[](https://twitter.com/lencx_)
|
[](https://twitter.com/lencx_)
|
||||||
|
|
||||||
[Awesome ChatGPT](./AWESOME.md)
|
<a href="https://www.buymeacoffee.com/lencx" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 145px !important;" ></a>
|
||||||
|
|
||||||
## 📦 下载
|
## 📦 安装
|
||||||
|
|
||||||
[📝 更新日志](./UPDATE_LOG.md)
|
[📝 更新日志](./UPDATE_LOG.md)
|
||||||
|
|
||||||
<!-- download start -->
|
<!-- download start -->
|
||||||
|
|
||||||
**最新版:**
|
### Windows
|
||||||
|
|
||||||
- `Mac`: [ChatGPT_0.7.4_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64.dmg)
|
- [ChatGPT_0.7.4_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64_en-US.msi)
|
||||||
- `Windows`: [ChatGPT_0.7.4_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64_en-US.msi)
|
- 或者使用 [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/):
|
||||||
- `Linux`:
|
- `winget install --id=lencx.ChatGPT -e`
|
||||||
- [chat-gpt_0.7.4_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.deb)
|
- `winget install --id=lencx.ChatGPT -e --version 0.7.4`
|
||||||
- [chat-gpt_0.7.4_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它**
|
|
||||||
|
|
||||||
[其他版本...](https://github.com/lencx/ChatGPT/releases)
|
**注意:如果安装路径和应用名称相同,会导致冲突 ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-1371166972))**
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
|
||||||
|
- [ChatGPT_0.7.4_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64.dmg)
|
||||||
|
- 如果你偏爱 `.app` 的安装包,你同样可以在我们的 github releases 里找到 [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT.app.tar.gz)
|
||||||
|
- Homebrew \
|
||||||
|
_[Homebrew 快捷安装](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
||||||
|
```sh
|
||||||
|
brew tap lencx/chatgpt https://github.com/lencx/ChatGPT.git
|
||||||
|
brew install --cask chatgpt --no-quarantine
|
||||||
|
```
|
||||||
|
如果你坚持使用 _[Brewfile](https://github.com/Homebrew/homebrew-bundle#usage)_ ,你需要添加以下配置:
|
||||||
|
```rb
|
||||||
|
repo = "lencx/chatgpt"
|
||||||
|
tap repo, "https://github.com/#{repo}.git"
|
||||||
|
cask "chatgpt", args: { "no-quarantine": true }
|
||||||
|
```
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
- [chat-gpt_0.7.4_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.deb)
|
||||||
|
- [chat-gpt_0.7.4_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.AppImage): **工作可靠,`.deb` 运行失败时可以尝试它**
|
||||||
|
|
||||||
<!-- download end -->
|
<!-- download end -->
|
||||||
|
|
||||||
<a href="https://www.buymeacoffee.com/lencx" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 145px !important;" ></a>
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### brew 安装
|
|
||||||
|
|
||||||
_[Homebrew快捷安装](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
|
||||||
|
|
||||||
```sh
|
|
||||||
brew tap lencx/chatgpt https://github.com/lencx/ChatGPT.git
|
|
||||||
brew install --cask chatgpt --no-quarantine
|
|
||||||
```
|
|
||||||
|
|
||||||
如果你坚持使用 _[Brewfile](https://github.com/Homebrew/homebrew-bundle#usage)_ ,你需要添加以下配置:
|
|
||||||
|
|
||||||
```rb
|
|
||||||
repo = "lencx/chatgpt"
|
|
||||||
tap repo, "https://github.com/#{repo}.git"
|
|
||||||
cask "chatgpt", args: { "no-quarantine": true }
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📢 公告
|
## 📢 公告
|
||||||
|
|
||||||
这是一个令人兴奋的重大更新。像 `Telegram 机器人指令` 那样工作,帮助你快速填充自定模型,来让 ChatGPT 按照你想要的方式去工作。这个项目倾注了我大量业余时间,如果它对你有所帮助,宣传转发,或者 star 都是对我的巨大鼓励。我希望我可以持续更新下去,加入更多有趣的功能。
|
这是一个令人兴奋的重大更新。像 `Telegram 机器人指令` 那样工作,帮助你快速填充自定模型,来让 ChatGPT 按照你想要的方式去工作。这个项目倾注了我大量业余时间,如果它对你有所帮助,宣传转发,或者 star 都是对我的巨大鼓励。我希望我可以持续更新下去,加入更多有趣的功能。
|
||||||
|
|||||||
65
README.md
65
README.md
@@ -15,48 +15,55 @@
|
|||||||
|
|
||||||
<!-- [](./README-ZH.md) -->
|
<!-- [](./README-ZH.md) -->
|
||||||
|
|
||||||
## 📦 Downloads
|
<a href="https://www.buymeacoffee.com/lencx" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 145px !important;" ></a>
|
||||||
|
|
||||||
|
## 📦 Install
|
||||||
|
|
||||||
[📝 Update Log](./UPDATE_LOG.md)
|
[📝 Update Log](./UPDATE_LOG.md)
|
||||||
|
|
||||||
<!-- download start -->
|
<!-- download start -->
|
||||||
|
|
||||||
**Latest:**
|
### Windows
|
||||||
|
|
||||||
- `Mac`: [ChatGPT_0.7.4_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64.dmg)
|
- From our github releases: [ChatGPT_0.7.4_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64_en-US.msi)
|
||||||
- `Windows`: [ChatGPT_0.7.4_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64_en-US.msi)
|
- Or install with [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/):
|
||||||
- `Linux`:
|
- `winget install --id=lencx.ChatGPT -e`
|
||||||
- [chat-gpt_0.7.4_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.deb)
|
- `winget install --id=lencx.ChatGPT -e --version 0.7.4`
|
||||||
- [chat-gpt_0.7.4_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.AppImage): **works reliably, you can try it if `.deb` fails to run**
|
|
||||||
|
|
||||||
[Other version...](https://github.com/lencx/ChatGPT/releases)
|
**Note: If the installation path and application name are the same, it will lead to conflict ([#142](https://github.com/lencx/ChatGPT/issues/142#issuecomment-1371166972))**
|
||||||
|
|
||||||
|
### Mac
|
||||||
|
|
||||||
|
- From our github releases: [ChatGPT_0.7.4_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT_0.7.4_x64.dmg)
|
||||||
|
- If you prefer `.app` installation, you can also download it from our github releases: [ChatGPT.app.tar.gz](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/ChatGPT.app.tar.gz)
|
||||||
|
- Homebrew \
|
||||||
|
Or you can install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
||||||
|
```sh
|
||||||
|
brew tap lencx/chatgpt https://github.com/lencx/ChatGPT.git
|
||||||
|
brew install --cask chatgpt --no-quarantine
|
||||||
|
```
|
||||||
|
Also, if you keep a _[Brewfile](https://github.com/Homebrew/homebrew-bundle#usage)_, you can add something like this:
|
||||||
|
```rb
|
||||||
|
repo = "lencx/chatgpt"
|
||||||
|
tap repo, "https://github.com/#{repo}.git"
|
||||||
|
cask "chatgpt", args: { "no-quarantine": true }
|
||||||
|
```
|
||||||
|
|
||||||
|
### Linux
|
||||||
|
|
||||||
|
- [chat-gpt_0.7.4_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.deb)
|
||||||
|
- [chat-gpt_0.7.4_amd64.AppImage](https://github.com/lencx/ChatGPT/releases/download/v0.7.4/chat-gpt_0.7.4_amd64.AppImage): **works reliably, you can try it if `.deb` fails to run**
|
||||||
|
|
||||||
|
[History versions...](https://github.com/lencx/ChatGPT/releases)
|
||||||
|
|
||||||
<!-- download end -->
|
<!-- download end -->
|
||||||
|
|
||||||
<a href="https://www.buymeacoffee.com/lencx" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-blue.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 145px !important;" ></a>
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Install
|
|
||||||
|
|
||||||
Easily install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
|
||||||
|
|
||||||
```sh
|
|
||||||
brew tap lencx/chatgpt https://github.com/lencx/ChatGPT.git
|
|
||||||
brew install --cask chatgpt --no-quarantine
|
|
||||||
```
|
|
||||||
|
|
||||||
Also, if you keep a _[Brewfile](https://github.com/Homebrew/homebrew-bundle#usage)_, you can add something like this:
|
|
||||||
|
|
||||||
```rb
|
|
||||||
repo = "lencx/chatgpt"
|
|
||||||
tap repo, "https://github.com/#{repo}.git"
|
|
||||||
cask "chatgpt", args: { "no-quarantine": true }
|
|
||||||
```
|
|
||||||
|
|
||||||
## 📢 Announcement
|
## 📢 Announcement
|
||||||
|
|
||||||
### ChatGPT Prompts!
|
### ChatGPT Prompts!
|
||||||
|
|
||||||
This is a major and exciting update. It works like a `Telegram bot command` and helps you quickly populate custom models to make chatgpt work the way you want it to. This project has taken a lot of my spare time, so if it helps you, please help spread the word or star it would be a great encouragement to me. I hope I can keep updating it and adding more interesting features.
|
This is a major and exciting update. It works like a `Telegram bot command` and helps you quickly populate custom models to make chatgpt work the way you want it to. This project has taken a lot of my spare time, so if it helps you, please help spread the word or star it would be a great encouragement to me. I hope I can keep updating it and adding more interesting features.
|
||||||
|
|
||||||
### How does it work?
|
### How does it work?
|
||||||
@@ -140,7 +147,7 @@ You can look at **[awesome-chatgpt-prompts](https://github.com/f/awesome-chatgpt
|
|||||||
|
|
||||||
Currently, only json and csv are supported for synchronizing custom files, and the following formats need to be met, otherwise the application will be abnormal:
|
Currently, only json and csv are supported for synchronizing custom files, and the following formats need to be met, otherwise the application will be abnormal:
|
||||||
|
|
||||||
> JSON format:
|
`JSON format:`
|
||||||
|
|
||||||
```json
|
```json
|
||||||
[
|
[
|
||||||
@@ -157,7 +164,7 @@ Currently, only json and csv are supported for synchronizing custom files, and t
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
> CSV format
|
`CSV format`
|
||||||
|
|
||||||
```csv
|
```csv
|
||||||
"cmd","act","prompt"
|
"cmd","act","prompt"
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ pub fn reset_chat_conf() -> ChatConfJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
pub fn run_check_update(app: AppHandle) -> () {
|
pub fn run_check_update(app: AppHandle, silent: bool) {
|
||||||
utils::run_check_update(app).unwrap();
|
utils::run_check_update(app, silent).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[command]
|
#[command]
|
||||||
|
|||||||
@@ -36,20 +36,27 @@ pub fn init() -> Menu {
|
|||||||
|
|
||||||
let stay_on_top =
|
let stay_on_top =
|
||||||
CustomMenuItem::new("stay_on_top".to_string(), "Stay On Top").accelerator("CmdOrCtrl+T");
|
CustomMenuItem::new("stay_on_top".to_string(), "Stay On Top").accelerator("CmdOrCtrl+T");
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let titlebar =
|
let titlebar =
|
||||||
CustomMenuItem::new("titlebar".to_string(), "Titlebar").accelerator("CmdOrCtrl+B");
|
CustomMenuItem::new("titlebar".to_string(), "Titlebar").accelerator("CmdOrCtrl+B");
|
||||||
|
|
||||||
let theme_light = CustomMenuItem::new("theme_light".to_string(), "Light");
|
let theme_light = CustomMenuItem::new("theme_light".to_string(), "Light");
|
||||||
let theme_dark = CustomMenuItem::new("theme_dark".to_string(), "Dark");
|
let theme_dark = CustomMenuItem::new("theme_dark".to_string(), "Dark");
|
||||||
let theme_system = CustomMenuItem::new("theme_system".to_string(), "System");
|
let theme_system = CustomMenuItem::new("theme_system".to_string(), "System");
|
||||||
let is_dark = chat_conf.theme == "Dark";
|
let is_dark = chat_conf.theme == "Dark";
|
||||||
let is_system = chat_conf.theme == "System";
|
let is_system = chat_conf.theme == "System";
|
||||||
|
|
||||||
|
let update_prompt = CustomMenuItem::new("update_prompt".to_string(), "Prompt");
|
||||||
|
let update_silent = CustomMenuItem::new("update_silent".to_string(), "Silent");
|
||||||
|
let _update_disable = CustomMenuItem::new("update_disable".to_string(), "Disable");
|
||||||
|
|
||||||
let stay_on_top_menu = if chat_conf.stay_on_top {
|
let stay_on_top_menu = if chat_conf.stay_on_top {
|
||||||
stay_on_top.selected()
|
stay_on_top.selected()
|
||||||
} else {
|
} else {
|
||||||
stay_on_top
|
stay_on_top
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let titlebar_menu = if chat_conf.titlebar {
|
let titlebar_menu = if chat_conf.titlebar {
|
||||||
titlebar.selected()
|
titlebar.selected()
|
||||||
@@ -84,6 +91,26 @@ pub fn init() -> Menu {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.into(),
|
.into(),
|
||||||
|
Submenu::new(
|
||||||
|
"Auto Update",
|
||||||
|
Menu::new()
|
||||||
|
.add_item(if chat_conf.auto_update == "Prompt" {
|
||||||
|
update_prompt.selected()
|
||||||
|
} else {
|
||||||
|
update_prompt
|
||||||
|
})
|
||||||
|
.add_item(if chat_conf.auto_update == "Silent" {
|
||||||
|
update_silent.selected()
|
||||||
|
} else {
|
||||||
|
update_silent
|
||||||
|
})
|
||||||
|
// .add_item(if chat_conf.auto_update == "Disable" {
|
||||||
|
// update_disable.selected()
|
||||||
|
// } else {
|
||||||
|
// update_disable
|
||||||
|
// })
|
||||||
|
,
|
||||||
|
).into(),
|
||||||
stay_on_top_menu.into(),
|
stay_on_top_menu.into(),
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
titlebar_menu.into(),
|
titlebar_menu.into(),
|
||||||
@@ -201,7 +228,7 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
"check_update" => {
|
"check_update" => {
|
||||||
utils::run_check_update(app).unwrap();
|
utils::run_check_update(app, false).unwrap();
|
||||||
}
|
}
|
||||||
// Preferences
|
// Preferences
|
||||||
"control_center" => window::control_window(&app),
|
"control_center" => window::control_window(&app),
|
||||||
@@ -237,16 +264,34 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
tauri::api::process::restart(&app.env());
|
tauri::api::process::restart(&app.env());
|
||||||
}
|
}
|
||||||
"theme_light" | "theme_dark" | "theme_system" => {
|
"theme_light" | "theme_dark" | "theme_system" => {
|
||||||
let theme = if menu_id == "theme_dark" {
|
let theme = match menu_id {
|
||||||
"Dark"
|
"theme_dark" => "Dark",
|
||||||
} else if menu_id == "theme_system" {
|
"theme_system" => "System",
|
||||||
"System"
|
_ => "Light",
|
||||||
} else {
|
|
||||||
"Light"
|
|
||||||
};
|
};
|
||||||
ChatConfJson::amend(&serde_json::json!({ "theme": theme }), Some(app)).unwrap();
|
ChatConfJson::amend(&serde_json::json!({ "theme": theme }), Some(app)).unwrap();
|
||||||
}
|
}
|
||||||
|
"update_prompt" | "update_silent" | "update_disable" => {
|
||||||
|
for id in ["update_prompt" , "update_silent" , "update_disable"] {
|
||||||
|
menu_handle.get_item(id).set_selected(false).unwrap();
|
||||||
|
}
|
||||||
|
let auto_update = match menu_id {
|
||||||
|
"update_silent" => {
|
||||||
|
menu_handle.get_item("update_silent").set_selected(true).unwrap();
|
||||||
|
"Silent"
|
||||||
|
},
|
||||||
|
"update_disable" => {
|
||||||
|
menu_handle.get_item("update_disable").set_selected(true).unwrap();
|
||||||
|
"Disable"
|
||||||
|
},
|
||||||
|
_ => {
|
||||||
|
menu_handle.get_item("update_prompt").set_selected(true).unwrap();
|
||||||
|
"Prompt"
|
||||||
|
},
|
||||||
|
};
|
||||||
|
ChatConfJson::amend(&serde_json::json!({ "auto_update": auto_update }), None).unwrap();
|
||||||
|
}
|
||||||
"stay_on_top" => {
|
"stay_on_top" => {
|
||||||
let mut stay_on_top = state.stay_on_top.lock().unwrap();
|
let mut stay_on_top = state.stay_on_top.lock().unwrap();
|
||||||
*stay_on_top = !*stay_on_top;
|
*stay_on_top = !*stay_on_top;
|
||||||
|
|||||||
@@ -95,10 +95,10 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// auto_check_update
|
// auto_update
|
||||||
if chat_conf.auto_check_update {
|
if chat_conf.auto_update != "Disable" {
|
||||||
let app = app.handle();
|
let app = app.handle();
|
||||||
utils::run_check_update(app).unwrap();
|
utils::run_check_update(app, chat_conf.auto_update == "Silent").unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ pub const GITHUB_PROMPTS_CSV_URL: &str =
|
|||||||
"https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv";
|
"https://raw.githubusercontent.com/f/awesome-chatgpt-prompts/main/prompts.csv";
|
||||||
pub const DEFAULT_CHAT_CONF: &str = r#"{
|
pub const DEFAULT_CHAT_CONF: &str = r#"{
|
||||||
"stay_on_top": false,
|
"stay_on_top": false,
|
||||||
"auto_check_update": true,
|
"auto_update": "Prompt",
|
||||||
"theme": "Light",
|
"theme": "Light",
|
||||||
"titlebar": true,
|
"titlebar": true,
|
||||||
"global_shortcut": "",
|
"global_shortcut": "",
|
||||||
@@ -30,7 +30,7 @@ pub const DEFAULT_CHAT_CONF: &str = r#"{
|
|||||||
}"#;
|
}"#;
|
||||||
pub const DEFAULT_CHAT_CONF_MAC: &str = r#"{
|
pub const DEFAULT_CHAT_CONF_MAC: &str = r#"{
|
||||||
"stay_on_top": false,
|
"stay_on_top": false,
|
||||||
"auto_check_update": true,
|
"auto_update": "Prompt",
|
||||||
"theme": "Light",
|
"theme": "Light",
|
||||||
"titlebar": false,
|
"titlebar": false,
|
||||||
"global_shortcut": "",
|
"global_shortcut": "",
|
||||||
@@ -59,10 +59,10 @@ pub struct ChatConfJson {
|
|||||||
pub titlebar: bool,
|
pub titlebar: bool,
|
||||||
pub hide_dock_icon: bool,
|
pub hide_dock_icon: bool,
|
||||||
|
|
||||||
// macOS and Windows
|
// macOS and Windows, Light/Dark/System
|
||||||
pub theme: String,
|
pub theme: String,
|
||||||
|
// auto update policy, Prompt/Silent/Disable
|
||||||
pub auto_check_update: bool,
|
pub auto_update: String,
|
||||||
pub stay_on_top: bool,
|
pub stay_on_top: bool,
|
||||||
pub default_origin: String,
|
pub default_origin: String,
|
||||||
pub origin: String,
|
pub origin: String,
|
||||||
@@ -177,21 +177,20 @@ impl ChatConfJson {
|
|||||||
|
|
||||||
pub fn theme() -> Option<Theme> {
|
pub fn theme() -> Option<Theme> {
|
||||||
let conf = ChatConfJson::get_chat_conf();
|
let conf = ChatConfJson::get_chat_conf();
|
||||||
if conf.theme == "System" {
|
let theme = match conf.theme.as_str() {
|
||||||
let mode = dark_light::detect();
|
"System" => match dark_light::detect() {
|
||||||
return match mode {
|
|
||||||
// Dark mode
|
// Dark mode
|
||||||
dark_light::Mode::Dark => Some(Theme::Dark),
|
dark_light::Mode::Dark => Theme::Dark,
|
||||||
// Light mode
|
// Light mode
|
||||||
dark_light::Mode::Light => Some(Theme::Light),
|
dark_light::Mode::Light => Theme::Light,
|
||||||
// Unspecified
|
// Unspecified
|
||||||
dark_light::Mode::Default => Some(Theme::Light),
|
dark_light::Mode::Default => Theme::Light,
|
||||||
}
|
},
|
||||||
} if conf.theme == "Dark" {
|
"Dark" => Theme::Dark,
|
||||||
Some(Theme::Dark)
|
_ => Theme::Light,
|
||||||
} else {
|
};
|
||||||
Some(Theme::Light)
|
|
||||||
}
|
Some(theme)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ use std::{
|
|||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
process::Command,
|
process::Command,
|
||||||
};
|
};
|
||||||
use tauri::{utils::config::Config, Manager, AppHandle, Wry};
|
|
||||||
use tauri::updater::UpdateResponse;
|
use tauri::updater::UpdateResponse;
|
||||||
|
use tauri::{utils::config::Config, AppHandle, Manager, Wry};
|
||||||
|
|
||||||
pub fn chat_root() -> PathBuf {
|
pub fn chat_root() -> PathBuf {
|
||||||
tauri::api::path::home_dir().unwrap().join(".chatgpt")
|
tauri::api::path::home_dir().unwrap().join(".chatgpt")
|
||||||
@@ -130,14 +130,20 @@ pub async fn get_data(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run_check_update(app: AppHandle<Wry>) -> Result<()> {
|
pub fn run_check_update(app: AppHandle<Wry>, silent: bool) -> Result<()> {
|
||||||
tauri::async_runtime::spawn(async move {
|
tauri::async_runtime::spawn(async move {
|
||||||
let result = app.updater().check().await;
|
let result = app.updater().check().await;
|
||||||
let update_resp = result.unwrap();
|
let update_resp = result.unwrap();
|
||||||
if update_resp.is_update_available() {
|
if update_resp.is_update_available() {
|
||||||
tauri::async_runtime::spawn(async move {
|
if silent {
|
||||||
prompt_for_install(app, update_resp).await.unwrap();
|
tauri::async_runtime::spawn(async move {
|
||||||
});
|
silent_install(app, update_resp).await.unwrap();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
tauri::async_runtime::spawn(async move {
|
||||||
|
prompt_for_install(app, update_resp).await.unwrap();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -146,10 +152,7 @@ pub fn run_check_update(app: AppHandle<Wry>) -> Result<()> {
|
|||||||
// Copy private api in tauri/updater/mod.rs. TODO: refactor to public api
|
// Copy private api in tauri/updater/mod.rs. TODO: refactor to public api
|
||||||
// Prompt a dialog asking if the user want to install the new version
|
// Prompt a dialog asking if the user want to install the new version
|
||||||
// Maybe we should add an option to customize it in future versions.
|
// Maybe we should add an option to customize it in future versions.
|
||||||
pub async fn prompt_for_install (
|
pub async fn prompt_for_install(app: AppHandle<Wry>, update: UpdateResponse<Wry>) -> Result<()> {
|
||||||
app: AppHandle<Wry>,
|
|
||||||
update: UpdateResponse<Wry>
|
|
||||||
) -> Result<()> {
|
|
||||||
let windows = app.windows();
|
let windows = app.windows();
|
||||||
let parent_window = windows.values().next();
|
let parent_window = windows.values().next();
|
||||||
let package_info = app.package_info().clone();
|
let package_info = app.package_info().clone();
|
||||||
@@ -167,7 +170,11 @@ Would you like to install it now?
|
|||||||
|
|
||||||
Release Notes:
|
Release Notes:
|
||||||
{}"#,
|
{}"#,
|
||||||
package_info.name, update.latest_version(), package_info.version, body),
|
package_info.name,
|
||||||
|
update.latest_version(),
|
||||||
|
package_info.version,
|
||||||
|
body
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
if should_install {
|
if should_install {
|
||||||
@@ -190,3 +197,26 @@ Release Notes:
|
|||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn silent_install(app: AppHandle<Wry>, update: UpdateResponse<Wry>) -> Result<()> {
|
||||||
|
let windows = app.windows();
|
||||||
|
let parent_window = windows.values().next();
|
||||||
|
|
||||||
|
// Launch updater download process
|
||||||
|
// macOS we display the `Ready to restart dialog` asking to restart
|
||||||
|
// Windows is closing the current App and launch the downloaded MSI when ready (the process stop here)
|
||||||
|
// Linux we replace the AppImage by launching a new install, it start a new AppImage instance, so we're closing the previous. (the process stop here)
|
||||||
|
update.download_and_install().await?;
|
||||||
|
|
||||||
|
// Ask user if we need to restart the application
|
||||||
|
let should_exit = tauri::api::dialog::blocking::ask(
|
||||||
|
parent_window,
|
||||||
|
"Ready to Restart",
|
||||||
|
"The silent installation was successful, do you want to restart the application now?",
|
||||||
|
);
|
||||||
|
if should_exit {
|
||||||
|
app.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
},
|
},
|
||||||
"updater": {
|
"updater": {
|
||||||
"active": true,
|
"active": true,
|
||||||
"dialog": true,
|
"dialog": false,
|
||||||
"endpoints": [
|
"endpoints": [
|
||||||
"https://lencx.github.io/ChatGPT/install.json"
|
"https://lencx.github.io/ChatGPT/install.json"
|
||||||
],
|
],
|
||||||
|
|||||||
2
src/layout/index.tsx
vendored
2
src/layout/index.tsx
vendored
@@ -23,7 +23,7 @@ const ChatLayout: FC<ChatLayoutProps> = ({ children }) => {
|
|||||||
const go = useNavigate();
|
const go = useNavigate();
|
||||||
|
|
||||||
const checkAppUpdate = async () => {
|
const checkAppUpdate = async () => {
|
||||||
await invoke('run_check_update');
|
await invoke('run_check_update', {silent: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
19
src/view/General.tsx
vendored
19
src/view/General.tsx
vendored
@@ -10,10 +10,17 @@ import { clone, omit, isEqual } from 'lodash';
|
|||||||
import useInit from '@/hooks/useInit';
|
import useInit from '@/hooks/useInit';
|
||||||
import { DISABLE_AUTO_COMPLETE, chatRoot } from '@/utils';
|
import { DISABLE_AUTO_COMPLETE, chatRoot } from '@/utils';
|
||||||
|
|
||||||
const CheckUpdateLabel = () => {
|
const AutoUpdateLabel = () => {
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
Auto Check Update <Tooltip title={`check update on start`}><QuestionCircleOutlined style={{ color: '#1677ff' }} /></Tooltip>
|
Auto Update <Tooltip title={(
|
||||||
|
<div>
|
||||||
|
<div>Auto Update Policy</div>
|
||||||
|
<span><strong>Prompt</strong>: prompt to install</span><br/>
|
||||||
|
<span><strong>Silent</strong>: install silently</span><br/>
|
||||||
|
{/*<span><strong>Disable</strong>: disable auto update</span><br/>*/}
|
||||||
|
</div>
|
||||||
|
)}><QuestionCircleOutlined style={{ color: '#1677ff' }} /></Tooltip>
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -121,8 +128,12 @@ export default function General() {
|
|||||||
<Form.Item label="Stay On Top" name="stay_on_top" valuePropName="checked">
|
<Form.Item label="Stay On Top" name="stay_on_top" valuePropName="checked">
|
||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={<CheckUpdateLabel />} name="auto_check_update" valuePropName="checked">
|
<Form.Item label={<AutoUpdateLabel />} name="auto_update">
|
||||||
<Switch />
|
<Radio.Group>
|
||||||
|
<Radio value="Prompt">Prompt</Radio>
|
||||||
|
<Radio value="Silent">Silent</Radio>
|
||||||
|
{/*<Radio value="Disable">Disable</Radio>*/}
|
||||||
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item label={<GlobalShortcut />} name="global_shortcut">
|
<Form.Item label={<GlobalShortcut />} name="global_shortcut">
|
||||||
<Input placeholder="CmdOrCtrl+Shift+O" {...DISABLE_AUTO_COMPLETE} />
|
<Input placeholder="CmdOrCtrl+Shift+O" {...DISABLE_AUTO_COMPLETE} />
|
||||||
|
|||||||
Reference in New Issue
Block a user