diff --git a/core/src/browser/core.ts b/core/src/browser/core.ts index 0be3f1a7d..cf832e4d8 100644 --- a/core/src/browser/core.ts +++ b/core/src/browser/core.ts @@ -28,7 +28,7 @@ const getJanDataFolderPath = (): Promise => globalThis.core.api?.getJanD * @returns {Promise} A promise that resolves when the file explorer is opened. */ const openFileExplorer: (path: string) => Promise = (path) => - globalThis.core.api?.openFileExplorer(path) + globalThis.core.api?.openFileExplorer({ path }) /** * Joins multiple paths together. diff --git a/src-tauri/src/handlers/cmd.rs b/src-tauri/src/handlers/cmd.rs index 82bb06c61..9a96f1082 100644 --- a/src-tauri/src/handlers/cmd.rs +++ b/src-tauri/src/handlers/cmd.rs @@ -4,7 +4,7 @@ use std::fs; use std::fs::File; use std::io::Read; use tar::Archive; -use tauri::{process, AppHandle}; +use tauri::AppHandle; use serde::{Deserialize, Serialize}; use std::path::PathBuf; @@ -155,6 +155,48 @@ pub fn relaunch(app: AppHandle) { app.restart() } +#[tauri::command] +pub fn open_app_directory(app: AppHandle) { + let app_path = app.path().app_data_dir().unwrap(); + if cfg!(target_os = "windows") { + std::process::Command::new("explorer") + .arg(app_path) + .spawn() + .expect("Failed to open app directory"); + } else if cfg!(target_os = "macos") { + std::process::Command::new("open") + .arg(app_path) + .spawn() + .expect("Failed to open app directory"); + } else { + std::process::Command::new("xdg-open") + .arg(app_path) + .spawn() + .expect("Failed to open app directory"); + } +} + +#[tauri::command] +pub fn open_file_explorer(app: AppHandle, path: String) { + let path = PathBuf::from(path); + if cfg!(target_os = "windows") { + std::process::Command::new("explorer") + .arg(path) + .spawn() + .expect("Failed to open file explorer"); + } else if cfg!(target_os = "macos") { + std::process::Command::new("open") + .arg(path) + .spawn() + .expect("Failed to open file explorer"); + } else { + std::process::Command::new("xdg-open") + .arg(path) + .spawn() + .expect("Failed to open file explorer"); + } +} + #[tauri::command] pub fn get_active_extensions(app: AppHandle) -> Vec { let mut path = get_jan_extensions_path(app); diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index a0cc29d45..5be78d97c 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -14,8 +14,7 @@ struct AppState { #[command] fn app_token(state: State<'_, AppState>) -> Option { - // state.app_token.clone() - None + state.app_token.clone() } fn generate_app_token() -> String { @@ -62,6 +61,8 @@ pub fn run() { handlers::cmd::get_jan_data_folder_path, handlers::cmd::get_jan_extensions_path, handlers::cmd::relaunch, + handlers::cmd::open_app_directory, + handlers::cmd::open_file_explorer, app_token, ]) .manage(AppState { @@ -77,6 +78,7 @@ pub fn run() { } // Setup sidecar + let app_state = app.state::(); let sidecar_command = app.shell().sidecar("cortex-server").unwrap().args([ "--start-server", "--port", @@ -96,8 +98,9 @@ pub fn run() { .unwrap() .to_str() .unwrap(), - // "config", - // "--api_keys", + "config", + "--api_keys", + app_state.inner().app_token.as_deref().unwrap_or("") ]); let (mut rx, mut _child) = sidecar_command.spawn().expect("Failed to spawn sidecar"); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index b3f91d609..eabdb3954 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -13,9 +13,9 @@ "macOSPrivateApi": true, "windows": [ { - "title": "jan-app", - "width": 800, - "height": 600, + "title": "Jan", + "width": 1000, + "height": 700, "resizable": true, "fullscreen": false, "hiddenTitle": true, diff --git a/web/helpers/atoms/Setting.atom.ts b/web/helpers/atoms/Setting.atom.ts index 1fbb3d2a6..914e7ddd1 100644 --- a/web/helpers/atoms/Setting.atom.ts +++ b/web/helpers/atoms/Setting.atom.ts @@ -36,7 +36,7 @@ export const themeDataAtom = atomWithStorage( ) export const reduceTransparentAtom = atomWithStorage( REDUCE_TRANSPARENT, - false, + true, undefined, { getOnInit: true } ) diff --git a/web/screens/Settings/Appearance/index.tsx b/web/screens/Settings/Appearance/index.tsx index 9cff4b9ac..69c68dd52 100644 --- a/web/screens/Settings/Appearance/index.tsx +++ b/web/screens/Settings/Appearance/index.tsx @@ -60,7 +60,6 @@ export default function AppearanceOptions() { [ janDataFolderPath, reduceTransparent, - setReduceTransparent, setSelectedIdTheme, setTheme, setThemeData,