mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f26e854df | ||
|
|
4bedb8b5c1 | ||
|
|
dea81eb3d9 | ||
|
|
9e5dff5dab | ||
|
|
2a3e252eb0 | ||
|
|
0da9aef346 | ||
|
|
fd221815a6 | ||
|
|
410c1c597c | ||
|
|
15610ae1d3 | ||
|
|
bc940d97db | ||
|
|
92dc316c4f | ||
|
|
36e7be2c29 | ||
|
|
f1f58f37c4 | ||
|
|
5e295aeb1d | ||
|
|
325dbb305c | ||
|
|
55e17e1e5f |
@@ -1,5 +1,6 @@
|
||||
# Awesome ChatGPT
|
||||
|
||||
- [Awesome ChatGPT Prompts](https://github.com/f/awesome-chatgpt-prompts) - This repo includes ChatGPT promt curation to use ChatGPT better.
|
||||
- [Awesome ChatGPT](https://github.com/humanloop/awesome-chatgpt) - Curated list of awesome tools, demos, docs for ChatGPT and GPT-3
|
||||
|
||||
## Extension
|
||||
|
||||
41
README.md
41
README.md
@@ -10,21 +10,23 @@
|
||||
|
||||
[Awesome ChatGPT](./AWESOME.md)
|
||||
|
||||
## Downloads
|
||||
## 📦 Downloads
|
||||
|
||||
[📝 Update Log](./UPDATE_LOG.md)
|
||||
|
||||
<!-- download start -->
|
||||
|
||||
**Latest:**
|
||||
|
||||
- `Mac`: [ChatGPT_0.1.7_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.1.7/ChatGPT_0.1.7_x64.dmg)
|
||||
- `Linux`: [chat-gpt_0.1.7_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.1.7/chat-gpt_0.1.7_amd64.deb)
|
||||
- `Windows`: [ChatGPT_0.1.7_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.1.7/ChatGPT_0.1.7_x64_en-US.msi)
|
||||
- `Mac`: [ChatGPT_0.2.0_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.2.0/ChatGPT_0.2.0_x64.dmg)
|
||||
- `Linux`: [chat-gpt_0.2.0_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.2.0/chat-gpt_0.2.0_amd64.deb)
|
||||
- `Windows`: [ChatGPT_0.2.0_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.2.0/ChatGPT_0.2.0_x64_en-US.msi)
|
||||
|
||||
[Other version...](https://github.com/lencx/ChatGPT/releases)
|
||||
|
||||
<!-- download end -->
|
||||
|
||||
## Install
|
||||
### Install
|
||||
|
||||
Easily install with _[Homebrew](https://brew.sh) ([Cask](https://docs.brew.sh/Cask-Cookbook)):_
|
||||
|
||||
@@ -41,7 +43,7 @@ tap repo, "https://github.com/#{repo}.git"
|
||||
cask "popcorn-time", args: { "no-quarantine": true }
|
||||
~~~
|
||||
|
||||
## Features
|
||||
## ✨ Features
|
||||
|
||||
- multi-platform: `macOS` `Linux` `Windows`
|
||||
- export ChatGPT history (PNG, PDF and Share Link)
|
||||
@@ -54,32 +56,43 @@ 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.
|
||||
- `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.
|
||||
- `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.
|
||||
- `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.
|
||||
|
||||
## Preview
|
||||
## 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">
|
||||
<img width="320" src="./assets/export.png" alt="export"> <img width="320" src="./assets/tray.png" alt="tray">
|
||||
<img width="320" src="./assets/auto-update.png" alt="auto update">
|
||||
<img width="320" src="./assets/chat-ua.png" alt="user agent"> <img width="320" src="./assets/auto-update.png" alt="auto update">
|
||||
|
||||
---
|
||||
|
||||
<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: 60px !important;width: 217px !important;" ></a>
|
||||
|
||||
## FAQ
|
||||
## ❓FAQ
|
||||
|
||||
### Can't open ChatGPT
|
||||
|
||||
If the application cannot be opened after the upgrade, please try to clear the configuration file, which is in the `~/.chatgpt/*` directory.
|
||||
|
||||
### Is it safe?
|
||||
|
||||
@@ -118,6 +131,10 @@ yarn dev
|
||||
yarn build
|
||||
```
|
||||
|
||||
## ❤️ Thanks
|
||||
|
||||
- The share buttons code is copied directly from [@liady](https://github.com/liady) extension with minor modifications.
|
||||
|
||||
## Related
|
||||
|
||||
- [Tauri](https://tauri.app) - Build an optimized, secure, and frontend-independent application for multi-platform deployment.
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
# UPDATE LOG
|
||||
|
||||
## v0.2.1
|
||||
|
||||
feat: menu optimization
|
||||
|
||||
## v0.2.0
|
||||
|
||||
feat: menu enhancement
|
||||
- customize user-agent to prevent security detection interception
|
||||
- clear all chatgpt configuration files
|
||||
|
||||
## v0.1.8
|
||||
|
||||
feat:
|
||||
|
||||
BIN
assets/chat-ua.png
Normal file
BIN
assets/chat-ua.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 391 KiB |
@@ -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,12 @@ 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")
|
||||
.accelerator("CmdOrCtrl+U")
|
||||
.into(),
|
||||
CustomMenuItem::new("switch_origin".to_string(), "Switch Origin")
|
||||
.accelerator("CmdOrCtrl+O")
|
||||
.into(),
|
||||
@@ -78,6 +79,13 @@ pub fn init(context: &Context<EmbeddedAssets>) -> Menu {
|
||||
.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")
|
||||
.into(),
|
||||
@@ -125,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")
|
||||
@@ -152,15 +161,13 @@ 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),
|
||||
"user_agent" => window::ua_window(&app),
|
||||
"awesome" => open(&app, conf::AWESOME_URL.to_string()),
|
||||
"switch_origin" => {
|
||||
window::origin_window(&app);
|
||||
// app.get_window("origin").unwrap().show();
|
||||
}
|
||||
"titlebar" => {
|
||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||
ChatConfJson::amend(&serde_json::json!({ "titlebar": !chat_conf.titlebar })).unwrap();
|
||||
@@ -207,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();
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
use crate::{
|
||||
app::window,
|
||||
conf::{ChatConfJson, USER_AGENT},
|
||||
utils,
|
||||
};
|
||||
use crate::{app::window, conf::ChatConfJson, utils};
|
||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, Manager};
|
||||
|
||||
pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||
@@ -25,7 +21,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
||||
.initialization_script(include_str!("../assets/jspdf.js"))
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(include_str!("../assets/export.js"))
|
||||
.user_agent(USER_AGENT)
|
||||
.user_agent(&chat_conf.ua_pc)
|
||||
.build()?;
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
@@ -41,7 +37,7 @@ pub fn init(app: &mut App) -> std::result::Result<(), Box<dyn std::error::Error>
|
||||
.initialization_script(include_str!("../assets/jspdf.js"))
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(include_str!("../assets/export.js"))
|
||||
.user_agent(USER_AGENT)
|
||||
.user_agent(&chat_conf.ua_pc)
|
||||
.build()?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -17,7 +17,7 @@ pub fn mini_window(handle: &tauri::AppHandle) {
|
||||
.initialization_script(include_str!("../assets/jspdf.js"))
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(include_str!("../assets/export.js"))
|
||||
.user_agent(conf::PHONE_USER_AGENT)
|
||||
.user_agent(&chat_conf.ua_phone)
|
||||
.build()
|
||||
.unwrap()
|
||||
.hide()
|
||||
@@ -26,8 +26,6 @@ pub fn mini_window(handle: &tauri::AppHandle) {
|
||||
|
||||
pub fn origin_window(handle: &tauri::AppHandle) {
|
||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||
// tauri://localhost/origin
|
||||
// let url = chat_conf.origin;
|
||||
WindowBuilder::new(handle, "origin", WindowUrl::App(chat_conf.origin.into()))
|
||||
.resizable(false)
|
||||
.fullscreen(false)
|
||||
@@ -39,3 +37,17 @@ pub fn origin_window(handle: &tauri::AppHandle) {
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
pub fn ua_window(handle: &tauri::AppHandle) {
|
||||
let chat_conf = conf::ChatConfJson::get_chat_conf();
|
||||
WindowBuilder::new(handle, "ua", WindowUrl::App(chat_conf.origin.into()))
|
||||
.resizable(false)
|
||||
.fullscreen(false)
|
||||
.inner_size(540.0, 480.0)
|
||||
.always_on_top(true)
|
||||
.decorations(false)
|
||||
.initialization_script(include_str!("../assets/core.js"))
|
||||
.initialization_script(include_str!("../assets/ua.js"))
|
||||
.build()
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
2
src-tauri/src/assets/origin.js
vendored
2
src-tauri/src/assets/origin.js
vendored
@@ -54,7 +54,7 @@ function init() {
|
||||
const cancelBtn = document.getElementById('cancel');
|
||||
const confirmBtn = document.getElementById('confirm');
|
||||
cancelBtn.addEventListener('click', () => {
|
||||
window.invoke('form_cancel', { label: 'origin', title: 'Switch Origin', msg: 'Sure you want to give up the switch?' });
|
||||
window.invoke('form_cancel', { label: 'origin', title: 'Switch Origin', msg: 'Are you sure you want to cancel editing?' });
|
||||
})
|
||||
confirmBtn.addEventListener('click', () => {
|
||||
if (/^https?:\\/\\//.test(input.value)) {
|
||||
|
||||
89
src-tauri/src/assets/ua.js
vendored
Normal file
89
src-tauri/src/assets/ua.js
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
function init() {
|
||||
document.body.innerHTML = `<style>
|
||||
body {
|
||||
height: 100vh;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: Söhne,ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,Helvetica Neue,Arial,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;
|
||||
}
|
||||
h3 {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
textarea {
|
||||
all: unset;
|
||||
width: 300px;
|
||||
height: 60px;
|
||||
margin-bottom: 10px;
|
||||
padding: 10px;
|
||||
border: solid 2px #d8d8d8;
|
||||
background-color: #fff;
|
||||
border-radius: 5px !important;
|
||||
color: #4a4a4a;
|
||||
}
|
||||
button {
|
||||
all: unset;
|
||||
height: 30px;
|
||||
font-size: 16px;
|
||||
padding: 0 10px;
|
||||
line-height: 30px;
|
||||
margin: 0 5px;
|
||||
color: #fff;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#cancel {
|
||||
background-color: #999;
|
||||
}
|
||||
#confirm {
|
||||
background-color: #10a37f;
|
||||
}
|
||||
.item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
label {
|
||||
width: 120px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
</style>
|
||||
<h3>User Agent</h3>
|
||||
<div class="item">
|
||||
<label>Main Window (PC)</label>
|
||||
<textarea id="ua_pc" type="text" autocapitalize="off" autocomplete="off" spellcheck="false" autofocus placeholder="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) ..."></textarea>
|
||||
</div>
|
||||
<div class="item">
|
||||
<label>Tray Window (Phone)</label>
|
||||
<textarea id="ua_phone" type="text" autocapitalize="off" autocomplete="off" spellcheck="false" autofocus placeholder="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS ..."></textarea>
|
||||
</div>
|
||||
<div class="btns">
|
||||
<button id="cancel">Cancel</button>
|
||||
<button id="confirm">Confirm</button>
|
||||
</div>`;
|
||||
|
||||
const srcipt = document.createElement('script');
|
||||
srcipt.innerHTML = `const ua_pc = document.getElementById('ua_pc');
|
||||
const ua_phone = document.getElementById('ua_phone');
|
||||
const cancelBtn = document.getElementById('cancel');
|
||||
const confirmBtn = document.getElementById('confirm');
|
||||
cancelBtn.addEventListener('click', () => {
|
||||
window.invoke('form_cancel', { label: 'ua', title: 'User Agent', msg: 'Are you sure you want to cancel editing?' });
|
||||
})
|
||||
confirmBtn.addEventListener('click', () => {
|
||||
window.invoke('form_confirm', { data: { ua_pc: ua_pc.value, ua_phone: ua_phone.value } });
|
||||
})`;
|
||||
document.head.appendChild(srcipt);
|
||||
}
|
||||
|
||||
// run init
|
||||
if (
|
||||
document.readyState === "complete" ||
|
||||
document.readyState === "interactive"
|
||||
) {
|
||||
init();
|
||||
} else {
|
||||
document.addEventListener("DOMContentLoaded", init);
|
||||
}
|
||||
@@ -7,16 +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 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"
|
||||
"origin": "https://chat.openai.com",
|
||||
"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": "",
|
||||
"ua_phone": ""
|
||||
}"#;
|
||||
|
||||
pub struct ChatState {
|
||||
@@ -33,11 +46,13 @@ impl ChatState {
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
|
||||
pub struct ChatConfJson {
|
||||
pub titlebar: bool,
|
||||
pub always_on_top: bool,
|
||||
pub theme: String,
|
||||
pub titlebar: bool,
|
||||
pub default_origin: String,
|
||||
pub origin: String,
|
||||
pub ua_pc: String,
|
||||
pub ua_phone: String,
|
||||
}
|
||||
|
||||
impl ChatConfJson {
|
||||
@@ -49,17 +64,7 @@ impl ChatConfJson {
|
||||
create_file(&conf_file).unwrap();
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
fs::write(
|
||||
&conf_file,
|
||||
r#"{
|
||||
"always_on_top": false,
|
||||
"theme": "Light",
|
||||
"titlebar": false,
|
||||
"default_origin": "https://chat.openai.com",
|
||||
"origin": "https://chat.openai.com"
|
||||
}"#,
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(&conf_file, DEFAULT_CHAT_CONF_MAC).unwrap();
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
fs::write(&conf_file, DEFAULT_CHAT_CONF).unwrap();
|
||||
@@ -72,7 +77,8 @@ impl ChatConfJson {
|
||||
}
|
||||
|
||||
pub fn get_chat_conf() -> Self {
|
||||
let config_file = fs::read_to_string(ChatConfJson::conf_path()).unwrap();
|
||||
let config_file = fs::read_to_string(ChatConfJson::conf_path())
|
||||
.unwrap_or_else(|_| DEFAULT_CHAT_CONF.to_string());
|
||||
let config: Value =
|
||||
serde_json::from_str(&config_file).expect("failed to parse chat.conf.json");
|
||||
serde_json::from_value(config).unwrap_or_else(|_| ChatConfJson::chat_conf_default())
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
};
|
||||
use tauri::Manager;
|
||||
// use tauri::utils::config::Config;
|
||||
|
||||
pub fn chat_root() -> PathBuf {
|
||||
@@ -61,3 +62,20 @@ pub fn open_file(path: PathBuf) {
|
||||
#[cfg(target_os = "linux")]
|
||||
Command::new("xdg-open").arg(path).spawn().unwrap();
|
||||
}
|
||||
|
||||
pub fn clear_conf(app: &tauri::AppHandle) {
|
||||
let root = chat_root();
|
||||
let app2 = app.clone();
|
||||
let msg = format!("Path: {}\nAre you sure to clear all ChatGPT configurations? Please backup in advance if necessary!", root.to_string_lossy());
|
||||
tauri::api::dialog::ask(
|
||||
app.get_window("core").as_ref(),
|
||||
"Clear Config",
|
||||
msg,
|
||||
move |is_ok| {
|
||||
if is_ok {
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
tauri::api::process::restart(&app2.env());
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "ChatGPT",
|
||||
"version": "0.1.8"
|
||||
"version": "0.2.1"
|
||||
},
|
||||
"tauri": {
|
||||
"allowlist": {
|
||||
|
||||
Reference in New Issue
Block a user