chore: app updater
This commit is contained in:
parent
ed85ecb1e1
commit
52290f9ee5
@ -43,3 +43,6 @@ rmcp = { git = "https://github.com/modelcontextprotocol/rust-sdk", branch = "mai
|
||||
"transport-child-process",
|
||||
"tower",
|
||||
] }
|
||||
|
||||
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
|
||||
tauri-plugin-updater = "2"
|
||||
|
||||
@ -30,16 +30,19 @@ pub async fn run_mcp_commands(
|
||||
|
||||
if let Some(server_map) = mcp_servers.get("mcpServers").and_then(Value::as_object) {
|
||||
println!("MCP Servers: {server_map:#?}");
|
||||
|
||||
|
||||
for (name, config) in server_map {
|
||||
if let Some((command, args)) = extract_command_args(config) {
|
||||
let mut cmd = Command::new(command);
|
||||
args.iter().filter_map(Value::as_str).for_each(|arg| { cmd.arg(arg); });
|
||||
|
||||
let service = ().serve(TokioChildProcess::new(&mut cmd).map_err(|e| e.to_string())?)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
args.iter().filter_map(Value::as_str).for_each(|arg| {
|
||||
cmd.arg(arg);
|
||||
});
|
||||
|
||||
let service =
|
||||
().serve(TokioChildProcess::new(&mut cmd).map_err(|e| e.to_string())?)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
servers_state.lock().await.insert(name.clone(), service);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
pub mod cmd;
|
||||
pub mod fs;
|
||||
pub mod mcp;
|
||||
pub mod server;
|
||||
pub mod setup;
|
||||
pub mod state;
|
||||
pub mod server;
|
||||
pub mod mcp;
|
||||
@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
||||
#[derive(Default)]
|
||||
pub struct AppState {
|
||||
pub app_token: Option<String>,
|
||||
pub mcp_servers: Arc<Mutex<HashMap<String, RunningService<RoleClient, ()>>>>
|
||||
pub mcp_servers: Arc<Mutex<HashMap<String, RunningService<RoleClient, ()>>>>,
|
||||
}
|
||||
pub fn generate_app_token() -> String {
|
||||
rand::thread_rng()
|
||||
|
||||
@ -40,9 +40,18 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"plugins": {
|
||||
"updater": {
|
||||
"pubkey": "",
|
||||
"endpoints": [
|
||||
"https://github.com/menloresearch/jan/releases/latest/download/latest.json"
|
||||
]
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"active": true,
|
||||
"targets": "all",
|
||||
"createUpdaterArtifacts": true,
|
||||
"icon": [
|
||||
"icons/32x32.png",
|
||||
"icons/128x128.png",
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
|
||||
import { Button, Modal } from '@janhq/joi'
|
||||
|
||||
import { check, Update } from '@tauri-apps/plugin-updater'
|
||||
import { useAtom } from 'jotai'
|
||||
|
||||
import { useGetLatestRelease } from '@/hooks/useGetLatestRelease'
|
||||
@ -16,6 +17,7 @@ const ModalAppUpdaterChangelog = () => {
|
||||
const [appUpdateAvailable, setAppUpdateAvailable] = useAtom(
|
||||
appUpdateAvailableAtom
|
||||
)
|
||||
const updaterRef = useRef<Update | null>(null)
|
||||
|
||||
const [open, setOpen] = useState(appUpdateAvailable)
|
||||
|
||||
@ -26,6 +28,17 @@ const ModalAppUpdaterChangelog = () => {
|
||||
const beta = VERSION.includes('beta')
|
||||
const nightly = VERSION.includes('-')
|
||||
|
||||
const checkForUpdate = async () => {
|
||||
const update = await check()
|
||||
if (update) {
|
||||
setAppUpdateAvailable(true)
|
||||
updaterRef.current = update
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
checkForUpdate()
|
||||
}, [])
|
||||
|
||||
const { release } = useGetLatestRelease(beta ? true : false)
|
||||
|
||||
return (
|
||||
@ -73,8 +86,8 @@ const ModalAppUpdaterChangelog = () => {
|
||||
</Button>
|
||||
<Button
|
||||
autoFocus
|
||||
onClick={() => {
|
||||
window.core?.api?.appUpdateDownload()
|
||||
onClick={async () => {
|
||||
await updaterRef.current?.downloadAndInstall((event) => {})
|
||||
setOpen(false)
|
||||
setAppUpdateAvailable(false)
|
||||
}}
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
"@tanstack/react-virtual": "^3.10.9",
|
||||
"@tauri-apps/api": "^2.4.0",
|
||||
"@tauri-apps/plugin-http": "^2.4.2",
|
||||
"@tauri-apps/plugin-updater": "~2",
|
||||
"@uppy/core": "^4.3.0",
|
||||
"@uppy/react": "^4.0.4",
|
||||
"@uppy/xhr-upload": "^4.2.3",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user