This commit is contained in:
949036910@qq.com
2026-06-03 22:12:23 +08:00
parent 921c737726
commit 18bc7075da
5 changed files with 51 additions and 4 deletions

2
src-tauri/Cargo.lock generated
View File

@@ -5112,7 +5112,7 @@ dependencies = [
[[package]]
name = "tauri-app"
version = "0.1.13"
version = "0.1.14"
dependencies = [
"aes-gcm",
"async-trait",

View File

@@ -1,6 +1,6 @@
[package]
name = "tauri-app"
version = "0.1.13"
version = "0.1.14"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

View File

@@ -2,7 +2,7 @@
use serde::Deserialize;
use serde_json::{json, Value};
use tauri::{AppHandle, Manager, State, Window};
use tauri::{AppHandle, Emitter, Manager, State, Window};
use tokio::sync::watch;
use crate::app_config::AppConfig;
@@ -108,6 +108,16 @@ pub async fn publish_login(
} else {
(store.create_account_slot(platform.clone()).await?.id, true)
};
let _ = window.emit(
"nodejs:event",
serde_json::json!({
"type": "progress",
"scriptName": "publish_login.js",
"status": "正在加载登录脚本并启动浏览器…",
}),
);
let result = run_publish_script(
app,
window,

View File

@@ -293,7 +293,44 @@ async fn write_script_bundle(
}
fn local_nodejs_scripts_dir() -> Option<PathBuf> {
if let Ok(dir) = std::env::var("AICLIENT_NODEJS_SCRIPTS_DIR") {
let p = PathBuf::from(dir.trim());
if p.is_dir() {
return Some(p);
}
}
#[cfg(debug_assertions)]
{
let dev = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../../pythonbackend/scripts/nodejs");
if dev.is_dir() {
return Some(dev);
}
}
None
}
fn read_local_node_script(script_name: &str) -> Option<String> {
let name = normalize_script_name(script_name)?;
let dir = local_nodejs_scripts_dir()?;
let path = dir.join(&name);
if !path.is_file() {
return None;
}
std::fs::read_to_string(&path).ok()
}
async fn fetch_node_script_source(script_name: &str) -> Result<String, NodeError> {
// if let Some(source) = read_local_node_script(script_name) {
// log::info!(
// target: "nodejs",
// "使用本地脚本: {}",
// script_name
// );
// return Ok(source);
// }
let q = urlencoding::encode(script_name);
let path = format!("/nodejs-scripts?name={q}");
let (_status, v) = crate::api_client::request_json("GET", &path, None, HashMap::new())

View File

@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "aiclient",
"version": "0.1.13",
"version": "0.1.14",
"identifier": "com.aiclient.desktop",
"build": {
"beforeDevCommand": "npm run dev --prefix ../aiclient_ui",