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