chore: update native apis
This commit is contained in:
parent
9079067332
commit
85389aec68
@ -28,7 +28,7 @@ const getJanDataFolderPath = (): Promise<string> => globalThis.core.api?.getJanD
|
||||
* @returns {Promise<any>} A promise that resolves when the file explorer is opened.
|
||||
*/
|
||||
const openFileExplorer: (path: string) => Promise<any> = (path) =>
|
||||
globalThis.core.api?.openFileExplorer(path)
|
||||
globalThis.core.api?.openFileExplorer({ path })
|
||||
|
||||
/**
|
||||
* Joins multiple paths together.
|
||||
|
||||
@ -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<serde_json::Value> {
|
||||
let mut path = get_jan_extensions_path(app);
|
||||
|
||||
@ -14,8 +14,7 @@ struct AppState {
|
||||
|
||||
#[command]
|
||||
fn app_token(state: State<'_, AppState>) -> Option<String> {
|
||||
// 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::<AppState>();
|
||||
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");
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -36,7 +36,7 @@ export const themeDataAtom = atomWithStorage<Theme | undefined>(
|
||||
)
|
||||
export const reduceTransparentAtom = atomWithStorage<boolean>(
|
||||
REDUCE_TRANSPARENT,
|
||||
false,
|
||||
true,
|
||||
undefined,
|
||||
{ getOnInit: true }
|
||||
)
|
||||
|
||||
@ -60,7 +60,6 @@ export default function AppearanceOptions() {
|
||||
[
|
||||
janDataFolderPath,
|
||||
reduceTransparent,
|
||||
setReduceTransparent,
|
||||
setSelectedIdTheme,
|
||||
setTheme,
|
||||
setThemeData,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user