1
0
mirror of https://github.com/lencx/ChatGPT.git synced 2024-10-01 01:06:13 -04:00

fix: tray icon (#87)

This commit is contained in:
lencx 2022-12-28 01:12:03 +08:00
parent f4d3cc6c8e
commit 2d018c4967
7 changed files with 40 additions and 19 deletions

View File

@ -64,6 +64,11 @@ jobs:
- name: Install app dependencies and build it - name: Install app dependencies and build it
run: yarn && yarn build:fe run: yarn && yarn build:fe
- name: fix tray icon
if: matrix.platform != 'macos-latest'
run: |
yarn fix:tray
- uses: tauri-apps/tauri-action@v0.3 - uses: tauri-apps/tauri-action@v0.3
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,5 +1,12 @@
# UPDATE LOG # UPDATE LOG
## v0.7.1
fix:
- some windows systems cannot start the application
- windows and linux add about menu (show version information)
- the tray icon is indistinguishable from the background in dark mode on window and linux
## v0.7.0 ## v0.7.0
fix: fix:

View File

@ -8,6 +8,8 @@
"build": "yarn tauri build", "build": "yarn tauri build",
"updater": "tr updater", "updater": "tr updater",
"release": "tr release --git", "release": "tr release --git",
"fix:tray": "tr override --json.tauri_systemTray_iconPath=\"icons/tray-icon-light.png\" --json.tauri_systemTray_iconAsTemplate=false",
"fix:tray:mac": "tr override --json.tauri_systemTray_iconPath=\"icons/tray-icon.png\" --json.tauri_systemTray_iconAsTemplate=true",
"download": "node ./scripts/download.js", "download": "node ./scripts/download.js",
"tr": "tr", "tr": "tr",
"tauri": "tauri" "tauri": "tauri"

View File

@ -17,7 +17,7 @@ tauri-build = {version = "1.2.1", features = [] }
anyhow = "1.0.66" anyhow = "1.0.66"
serde_json = "1.0" serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2.2", features = ["api-all", "devtools", "system-tray", "updater"] } tauri = { version = "1.2.3", features = ["api-all", "devtools", "system-tray", "updater"] }
tauri-plugin-positioner = { version = "1.0.4", features = ["system-tray"] } tauri-plugin-positioner = { version = "1.0.4", features = ["system-tray"] }
log = "0.4.17" log = "0.4.17"
csv = "1.1.6" csv = "1.1.6"

Binary file not shown.

After

Width:  |  Height:  |  Size: 124 KiB

View File

@ -16,16 +16,19 @@ pub fn init() -> Menu {
let name = "ChatGPT"; let name = "ChatGPT";
let app_menu = Submenu::new( let app_menu = Submenu::new(
name, name,
Menu::new() Menu::with_items([
.add_native_item(MenuItem::About(name.into(), AboutMetadata::default())) #[cfg(target_os = "macos")]
.add_native_item(MenuItem::Services) MenuItem::About(name.into(), AboutMetadata::default()).into(),
.add_native_item(MenuItem::Separator) #[cfg(not(target_os = "macos"))]
.add_native_item(MenuItem::Hide) CustomMenuItem::new("about".to_string(), "About ChatGPT")
.add_native_item(MenuItem::HideOthers) .into(),
.add_native_item(MenuItem::ShowAll) MenuItem::Services.into(),
.add_native_item(MenuItem::Separator) MenuItem::Hide.into(),
.add_native_item(MenuItem::Quit), MenuItem::HideOthers.into(),
); MenuItem::ShowAll.into(),
MenuItem::Separator.into(),
MenuItem::Quit.into(),
]));
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");
@ -177,6 +180,11 @@ pub fn menu_handler(event: WindowMenuEvent<tauri::Wry>) {
let menu_handle = core_window.menu_handle(); let menu_handle = core_window.menu_handle();
match menu_id { match menu_id {
// App
"about" => {
let tauri_conf = utils::get_tauri_conf().unwrap();
tauri::api::dialog::message(app.get_window("core").as_ref(), "ChatGPT", format!("Version {}", tauri_conf.package.version.unwrap()));
}
// Preferences // Preferences
"control_center" => window::control_window(&app), "control_center" => window::control_window(&app),
"restart" => tauri::api::process::restart(&app.env()), "restart" => tauri::api::process::restart(&app.env()),

View File

@ -8,19 +8,18 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
process::Command, process::Command,
}; };
use tauri::Manager; use tauri::{Manager, utils::config::Config};
// use tauri::utils::config::Config;
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")
} }
// pub fn get_tauri_conf() -> Option<Config> { pub fn get_tauri_conf() -> Option<Config> {
// let config_file = include_str!("../tauri.conf.json"); let config_file = include_str!("../tauri.conf.json");
// let config: Config = let config: Config =
// serde_json::from_str(config_file).expect("failed to parse tauri.conf.json"); serde_json::from_str(config_file).expect("failed to parse tauri.conf.json");
// Some(config) Some(config)
// } }
pub fn exists(path: &Path) -> bool { pub fn exists(path: &Path) -> bool {
Path::new(path).exists() Path::new(path).exists()