mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
Merge pull request #11 from lencx/dev
This commit is contained in:
13
README.md
13
README.md
@@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
**Latest:**
|
**Latest:**
|
||||||
|
|
||||||
- `Mac`: [ChatGPT_0.1.6_x64.dmg](https://github.com/lencx/ChatGPT/releases/download/v0.1.6/ChatGPT_0.1.6_x64.dmg)
|
- `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.6_amd64.deb](https://github.com/lencx/ChatGPT/releases/download/v0.1.6/chat-gpt_0.1.6_amd64.deb)
|
- `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.6_x64_en-US.msi](https://github.com/lencx/ChatGPT/releases/download/v0.1.6/ChatGPT_0.1.6_x64_en-US.msi)
|
- `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)
|
||||||
|
|
||||||
[Other version...](https://github.com/lencx/ChatGPT/releases)
|
[Other version...](https://github.com/lencx/ChatGPT/releases)
|
||||||
|
|
||||||
@@ -31,13 +31,14 @@
|
|||||||
- inject script
|
- inject script
|
||||||
- auto updater
|
- auto updater
|
||||||
- app menu
|
- app menu
|
||||||
- system tray
|
- tray window
|
||||||
- shortcut
|
- shortcut
|
||||||
|
|
||||||
## Preview
|
## Preview
|
||||||
|
|
||||||
<img width="360" src="./assets/install.png" alt="install"> <img width="360" src="./assets/chat.png" alt="chat">
|
<img width="320" src="./assets/install.png" alt="install"> <img width="320" src="./assets/chat.png" alt="chat">
|
||||||
<img width="360" src="./assets/export.png" alt="export"> <img width="360" src="./assets/auto-update.png" alt="auto update">
|
<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">
|
||||||
|
|
||||||
## FAQ
|
## FAQ
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
# UPDATE LOG
|
# UPDATE LOG
|
||||||
|
|
||||||
|
## v0.1.7
|
||||||
|
|
||||||
|
feat: tray window
|
||||||
|
|
||||||
## v0.1.6
|
## v0.1.6
|
||||||
|
|
||||||
feat:
|
feat:
|
||||||
|
|||||||
BIN
assets/tray.png
Normal file
BIN
assets/tray.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 543 KiB |
@@ -17,6 +17,7 @@ tauri-build = {version = "1.2.1", features = [] }
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
tauri = { version = "1.2.1", features = ["api-all", "devtools", "system-tray", "updater"] }
|
tauri = { version = "1.2.1", features = ["api-all", "devtools", "system-tray", "updater"] }
|
||||||
|
tauri-plugin-positioner = { version = "1.0.4", features = ["system-tray"] }
|
||||||
anyhow = "1.0.66"
|
anyhow = "1.0.66"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ use tauri::{
|
|||||||
utils::assets::EmbeddedAssets, AboutMetadata, AppHandle, Context, CustomMenuItem, Manager,
|
utils::assets::EmbeddedAssets, AboutMetadata, AppHandle, Context, CustomMenuItem, Manager,
|
||||||
Menu, MenuItem, Submenu, SystemTray, SystemTrayEvent, SystemTrayMenu, WindowMenuEvent,
|
Menu, MenuItem, Submenu, SystemTray, SystemTrayEvent, SystemTrayMenu, WindowMenuEvent,
|
||||||
};
|
};
|
||||||
|
use tauri_plugin_positioner::{on_tray_event, Position, WindowExt};
|
||||||
|
|
||||||
// --- Menu
|
// --- Menu
|
||||||
pub fn init(chat_conf: &conf::ChatConfJson, context: &Context<EmbeddedAssets>) -> Menu {
|
pub fn init(chat_conf: &conf::ChatConfJson, context: &Context<EmbeddedAssets>) -> Menu {
|
||||||
@@ -159,16 +160,19 @@ pub fn tray_menu() -> SystemTray {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- SystemTray Event
|
// --- SystemTray Event
|
||||||
pub fn tray_handler(app: &AppHandle, event: SystemTrayEvent) {
|
pub fn tray_handler(handle: &AppHandle, event: SystemTrayEvent) {
|
||||||
let win = app.get_window("core").unwrap();
|
let core_win = handle.get_window("core").unwrap();
|
||||||
|
on_tray_event(handle, &event);
|
||||||
|
|
||||||
if let SystemTrayEvent::LeftClick { .. } = event {
|
if let SystemTrayEvent::LeftClick { .. } = event {
|
||||||
// TODO: tray window
|
core_win.minimize().unwrap();
|
||||||
if win.is_visible().unwrap() {
|
let mini_win = handle.get_window("mini").unwrap();
|
||||||
win.hide().unwrap();
|
mini_win.move_window(Position::TrayCenter).unwrap();
|
||||||
|
|
||||||
|
if mini_win.is_visible().unwrap() {
|
||||||
|
mini_win.hide().unwrap();
|
||||||
} else {
|
} else {
|
||||||
win.show().unwrap();
|
mini_win.show().unwrap();
|
||||||
win.set_focus().unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
pub mod cmd;
|
pub mod cmd;
|
||||||
pub mod menu;
|
pub mod menu;
|
||||||
pub mod setup;
|
pub mod setup;
|
||||||
|
pub mod window;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::{conf, utils};
|
use crate::{app::window, conf, utils};
|
||||||
use tauri::{utils::config::WindowUrl, window::WindowBuilder, App};
|
use tauri::{utils::config::WindowUrl, window::WindowBuilder, App, Manager};
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
use tauri::TitleBarStyle;
|
use tauri::TitleBarStyle;
|
||||||
@@ -10,6 +10,7 @@ pub fn init(
|
|||||||
) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
) -> std::result::Result<(), Box<dyn std::error::Error>> {
|
||||||
let conf = utils::get_tauri_conf().unwrap();
|
let conf = utils::get_tauri_conf().unwrap();
|
||||||
let url = conf.build.dev_path.to_string();
|
let url = conf.build.dev_path.to_string();
|
||||||
|
window::mini_window(&app.app_handle());
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
WindowBuilder::new(app, "core", WindowUrl::App(url.into()))
|
WindowBuilder::new(app, "core", WindowUrl::App(url.into()))
|
||||||
|
|||||||
25
src-tauri/src/app/window.rs
Normal file
25
src-tauri/src/app/window.rs
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
use crate::{conf, utils};
|
||||||
|
use tauri::{utils::config::WindowUrl, window::WindowBuilder};
|
||||||
|
|
||||||
|
pub fn mini_window(handle: &tauri::AppHandle) {
|
||||||
|
let conf = utils::get_tauri_conf().unwrap();
|
||||||
|
let url = conf.build.dev_path.to_string();
|
||||||
|
|
||||||
|
WindowBuilder::new(handle, "mini", WindowUrl::App(url.into()))
|
||||||
|
.resizable(false)
|
||||||
|
.fullscreen(false)
|
||||||
|
.inner_size(360.0, 540.0)
|
||||||
|
.decorations(false)
|
||||||
|
.always_on_top(true)
|
||||||
|
.initialization_script(&utils::user_script())
|
||||||
|
.initialization_script(include_str!("../assets/html2canvas.js"))
|
||||||
|
.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)
|
||||||
|
.menu(tauri::Menu::new())
|
||||||
|
.build()
|
||||||
|
.unwrap()
|
||||||
|
.hide()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
6
src-tauri/src/assets/core.js
vendored
6
src-tauri/src/assets/core.js
vendored
@@ -40,6 +40,12 @@ window.invoke = invoke;
|
|||||||
window.transformCallback = transformCallback;
|
window.transformCallback = transformCallback;
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
|
if (__TAURI_METADATA__.__currentWindow.label === 'mini') {
|
||||||
|
document.getElementsByTagName('html')[0].style['font-size'] = '70%';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (__TAURI_METADATA__.__currentWindow.label !== 'core') return;
|
||||||
|
|
||||||
async function platform() {
|
async function platform() {
|
||||||
return invoke('platform', {
|
return invoke('platform', {
|
||||||
__tauriModule: 'Os',
|
__tauriModule: 'Os',
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ use std::path::PathBuf;
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
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 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 ISSUES_URL: &str = "https://github.com/lencx/ChatGPT/issues";
|
||||||
pub const AWESOME_URL: &str = "https://github.com/lencx/ChatGPT/blob/main/AWESOME.md";
|
pub const AWESOME_URL: &str = "https://github.com/lencx/ChatGPT/blob/main/AWESOME.md";
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ fn main() {
|
|||||||
cmd::open_link
|
cmd::open_link
|
||||||
])
|
])
|
||||||
.setup(|app| setup::init(app, chat_conf2))
|
.setup(|app| setup::init(app, chat_conf2))
|
||||||
|
.plugin(tauri_plugin_positioner::init())
|
||||||
.menu(menu::init(&chat_conf, &context))
|
.menu(menu::init(&chat_conf, &context))
|
||||||
.system_tray(menu::tray_menu())
|
.system_tray(menu::tray_menu())
|
||||||
.on_menu_event(menu::menu_handler)
|
.on_menu_event(menu::menu_handler)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
"package": {
|
"package": {
|
||||||
"productName": "ChatGPT",
|
"productName": "ChatGPT",
|
||||||
"version": "0.1.6"
|
"version": "0.1.7"
|
||||||
},
|
},
|
||||||
"tauri": {
|
"tauri": {
|
||||||
"allowlist": {
|
"allowlist": {
|
||||||
|
|||||||
Reference in New Issue
Block a user