Skip to content

Commit 2be7806

Browse files
authored
Merge pull request #649 from GCWing/gcwing/dev
feat(desktop,web-ui,installer): Tokyo Night theme, tray, and settings/usage
2 parents f0bb3bf + c2d4458 commit 2be7806

33 files changed

Lines changed: 1249 additions & 113 deletions

File tree

BitFun-Installer/scripts/sync-theme-i18n.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const THEME_IDS = [
1212
"bitfun-china-night",
1313
"bitfun-cyber",
1414
"bitfun-slate",
15+
"bitfun-tokyo-night",
1516
];
1617

1718
function readJson(filePath) {

BitFun-Installer/src-tauri/src/installer/commands.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,7 @@ pub fn set_theme_preference(theme_preference: String) -> Result<(), String> {
826826
"bitfun-china-night",
827827
"bitfun-cyber",
828828
"bitfun-slate",
829+
"bitfun-tokyo-night",
829830
];
830831
if !allowed.contains(&theme_preference.as_str()) {
831832
return Err("Unsupported theme preference".to_string());

BitFun-Installer/src/i18n/locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@
208208
"bitfun-china-style": "Ink Charm",
209209
"bitfun-china-night": "Ink Night",
210210
"bitfun-cyber": "Cyber",
211-
"bitfun-slate": "Slate"
211+
"bitfun-slate": "Slate",
212+
"bitfun-tokyo-night": "Tokyo Night"
212213
}
213214
},
214215
"complete": {

BitFun-Installer/src/i18n/locales/zh-TW.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@
208208
"bitfun-china-style": "墨韻",
209209
"bitfun-china-night": "墨夜",
210210
"bitfun-cyber": "賽博",
211-
"bitfun-slate": "石板灰"
211+
"bitfun-slate": "石板灰",
212+
"bitfun-tokyo-night": "東京夜"
212213
}
213214
},
214215
"complete": {

BitFun-Installer/src/i18n/locales/zh.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@
208208
"bitfun-china-style": "墨韵",
209209
"bitfun-china-night": "墨夜",
210210
"bitfun-cyber": "赛博",
211-
"bitfun-slate": "石板灰"
211+
"bitfun-slate": "石板灰",
212+
"bitfun-tokyo-night": "东京夜"
212213
}
213214
},
214215
"complete": {

BitFun-Installer/src/theme/installerThemesData.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,20 @@ export const THEMES: InstallerTheme[] = [
134134
element: { subtle: 'rgba(0, 230, 255, 0.06)', soft: 'rgba(0, 230, 255, 0.09)', base: 'rgba(0, 230, 255, 0.13)', medium: 'rgba(0, 230, 255, 0.17)', strong: 'rgba(0, 230, 255, 0.22)', elevated: 'rgba(0, 230, 255, 0.27)' },
135135
},
136136
},
137+
{
138+
id: 'bitfun-tokyo-night',
139+
name: 'Tokyo Night',
140+
type: 'dark',
141+
colors: {
142+
background: { primary: '#1a1b26', secondary: '#16161e', tertiary: '#14141b', quaternary: '#1e202e', elevated: '#20222c', workbench: '#16161e', flowchat: '#1a1b26', tooltip: 'rgba(22, 22, 30, 0.94)' },
143+
text: { primary: '#c0caf5', secondary: '#a9b1d6', muted: '#787c99', disabled: '#545c7e' },
144+
accent: { '50': 'rgba(122, 162, 247, 0.05)', '100': 'rgba(122, 162, 247, 0.08)', '200': 'rgba(122, 162, 247, 0.15)', '300': 'rgba(122, 162, 247, 0.25)', '400': 'rgba(122, 162, 247, 0.4)', '500': '#7aa2f7', '600': '#6183bb', '700': 'rgba(97, 131, 187, 0.85)', '800': 'rgba(97, 131, 187, 0.95)' },
145+
purple: { '50': 'rgba(187, 154, 247, 0.05)', '100': 'rgba(187, 154, 247, 0.08)', '200': 'rgba(187, 154, 247, 0.15)', '300': 'rgba(187, 154, 247, 0.25)', '400': 'rgba(187, 154, 247, 0.4)', '500': '#bb9af7', '600': '#9d7cd8', '700': 'rgba(157, 124, 216, 0.85)', '800': 'rgba(157, 124, 216, 0.95)' },
146+
semantic: { success: '#9ece6a', warning: '#e0af68', error: '#f7768e', info: '#7dcfff', highlight: '#e0af68', highlightBg: 'rgba(224, 175, 104, 0.15)' },
147+
border: { subtle: 'rgba(54, 59, 84, 0.45)', base: 'rgba(54, 59, 84, 0.6)', medium: 'rgba(54, 59, 84, 0.72)', strong: 'rgba(54, 59, 84, 0.85)', prominent: 'rgba(122, 162, 247, 0.45)' },
148+
element: { subtle: 'rgba(122, 162, 247, 0.06)', soft: 'rgba(122, 162, 247, 0.08)', base: 'rgba(122, 162, 247, 0.11)', medium: 'rgba(122, 162, 247, 0.14)', strong: 'rgba(122, 162, 247, 0.18)', elevated: 'rgba(122, 162, 247, 0.22)' },
149+
},
150+
},
137151
{
138152
id: 'bitfun-slate',
139153
name: 'Slate',
@@ -158,6 +172,7 @@ export const THEME_DISPLAY_ORDER: ThemeId[] = [
158172
'bitfun-china-style',
159173
'bitfun-china-night',
160174
'bitfun-cyber',
175+
'bitfun-tokyo-night',
161176
];
162177

163178
export function findInstallerThemeById(id: ThemeId): InstallerTheme {

BitFun-Installer/src/types/installer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export type ThemeId =
3030
| 'bitfun-china-style'
3131
| 'bitfun-china-night'
3232
| 'bitfun-cyber'
33-
| 'bitfun-slate';
33+
| 'bitfun-slate'
34+
| 'bitfun-tokyo-night';
3435

3536
/** Matches main app `themes.current` when following OS appearance. */
3637
export const SYSTEM_THEME_ID = 'system' as const;

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ similar = "2.5"
103103
urlencoding = "2.1"
104104

105105
# Tauri (desktop only)
106-
tauri = { version = "2", features = ["unstable", "macos-private-api"] }
106+
tauri = { version = "2", features = ["unstable", "macos-private-api", "tray-icon"] }
107107
tauri-plugin-opener = "2"
108108
tauri-plugin-dialog = "2.6"
109109
tauri-plugin-fs = "2"

src/apps/desktop/src/api/i18n_api.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ pub async fn i18n_set_language(
9393
&_app, language, mode, edit_mode,
9494
);
9595
}
96+
97+
// Rebuild the system tray menu in the new language.
98+
{
99+
let app_handle = _app.clone();
100+
tauri::async_runtime::spawn(async move {
101+
crate::tray::rebuild_tray_menu_public(&app_handle).await;
102+
});
103+
}
104+
96105
Ok(format!("Language switched to: {}", language))
97106
}
98107
Err(e) => {

src/apps/desktop/src/api/system_api.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::{Arc, Mutex};
55
use crate::api::app_state::AppState;
66
use bitfun_core::service::system;
77
use serde::{Deserialize, Serialize};
8-
use tauri::{AppHandle, Emitter, State};
8+
use tauri::{AppHandle, Emitter, Manager, State};
99
use tauri_plugin_updater::UpdaterExt;
1010

1111
/// Emitted during `install_update` download; matches `installUpdateWithProgress` / frontend listener.
@@ -309,6 +309,29 @@ pub struct SendNotificationRequest {
309309
pub body: Option<String>,
310310
}
311311

312+
// ─── Window / Tray behavior commands ─────────────────────────────────────────
313+
314+
/// Immediately exit the application (used by the "ask" dialog when the user
315+
/// chooses to quit rather than minimize to tray).
316+
#[tauri::command]
317+
pub async fn quit_app(app: tauri::AppHandle) -> Result<(), String> {
318+
log::info!("Quit requested via quit_app command");
319+
crate::perform_process_exit_cleanup();
320+
app.exit(0);
321+
Ok(())
322+
}
323+
324+
/// Hide the main window so it lives only in the system tray (used by the "ask"
325+
/// dialog when the user chooses to minimize instead of quitting).
326+
#[tauri::command]
327+
pub async fn minimize_to_tray(app: tauri::AppHandle) -> Result<(), String> {
328+
if let Some(window) = app.get_webview_window("main") {
329+
window.hide().map_err(|e| e.to_string())?;
330+
log::info!("Main window minimized to tray via command");
331+
}
332+
Ok(())
333+
}
334+
312335
/// Send an OS-level desktop notification (Windows toast / macOS notification center).
313336
#[tauri::command]
314337
pub async fn send_system_notification(

0 commit comments

Comments
 (0)