更新启动

This commit is contained in:
super
2026-06-08 11:50:02 +08:00
parent 84d1afcdc5
commit 9a3480dcb3
4 changed files with 15 additions and 41 deletions

View File

@@ -1,7 +1,5 @@
//! AES-256-GCM与 pythonbackend `app/core/aes_crypto.py` 一致。 //! AES-256-GCM与 pythonbackend `app/core/aes_crypto.py` 一致。
use rand::RngCore;
use aes_gcm::{ use aes_gcm::{
aead::{Aead, KeyInit}, aead::{Aead, KeyInit},
Aes256Gcm, Nonce, Aes256Gcm, Nonce,
@@ -33,8 +31,12 @@ pub fn parse_aes_key(raw: &str) -> Option<[u8; 32]> {
} }
pub fn aes_key_from_env() -> Option<[u8; 32]> { pub fn aes_key_from_env() -> Option<[u8; 32]> {
let s="98cde5e64ee0da6ed0c5842f43a950aa0d8ae5087c43c8d8ee5d10bd8d571bb4"; let raw = std::env::var("AICLIENT_API_AES_KEY")
parse_aes_key(&s) .or_else(|_| std::env::var("API_AES_KEY"))
.unwrap_or_else(|_| {
"a1825fb10e820d1de3abf8f1a34921684f8392e7018f373a41004abff3cdeafc".to_string()
});
parse_aes_key(&raw)
} }
pub fn encrypt_bytes(plaintext: &[u8], key: &[u8; 32]) -> Result<String, String> { pub fn encrypt_bytes(plaintext: &[u8], key: &[u8; 32]) -> Result<String, String> {

View File

@@ -48,7 +48,8 @@ pub fn api_base() -> String {
if is_dev() { if is_dev() {
"http://127.0.0.1:8001".to_string() "http://127.0.0.1:8001".to_string()
} else { } else {
"http://81.71.163.140:8001".to_string() // "http://81.71.163.140:8001".to_string()
"http://127.0.0.1:8001".to_string()
} }
}) })
} }

View File

@@ -36,15 +36,12 @@ use tauri::{Manager, WebviewUrl, WebviewWindowBuilder};
/// 开发:本地 Vite发布服务器静态资源与 aiclient_ui `build:deploy` 输出目录一致) /// 开发:本地 Vite发布服务器静态资源与 aiclient_ui `build:deploy` 输出目录一致)
const DEV_WEB_URL: &str = "http://localhost:1420/"; const DEV_WEB_URL: &str = "http://localhost:1420/";
const PROD_WEB_URL: &str = "http://81.71.163.140/images/newyaoyan/index.html";
fn webview_url() -> WebviewUrl { fn webview_url() -> WebviewUrl {
let url = if cfg!(debug_assertions) { if cfg!(debug_assertions) {
DEV_WEB_URL WebviewUrl::External(DEV_WEB_URL.parse().expect("dev webview url"))
} else { } else {
PROD_WEB_URL WebviewUrl::App("index.html".into())
}; }
WebviewUrl::External(url.parse().expect("webview url"))
} }
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
@@ -186,30 +183,3 @@ pub fn run() {
} }
}); });
} }
#[cfg(test)]
mod acl_url_tests {
use std::str::FromStr;
use tauri::utils::acl::RemoteUrlPattern;
#[test]
fn production_origin_matches_remote_patterns() {
let url: url::Url = "http://81.71.163.140/images/newyaoyan/index.html"
.parse()
.expect("valid url");
for pattern in [
"http://81.71.163.140/*",
"http://81.71.163.140:8001/*",
"http://81.71.163.140/images/newyaoyan/*",
"http://81.71.163.140/images/newyaoyan/index.html",
] {
let parsed = RemoteUrlPattern::from_str(pattern)
.unwrap_or_else(|e| panic!("failed to parse {pattern}: {e}"));
assert!(
parsed.test(&url),
"pattern {pattern} should match production origin"
);
}
}
}

View File

@@ -4,9 +4,10 @@
"version": "0.1.15", "version": "0.1.15",
"identifier": "com.aiclient.desktop", "identifier": "com.aiclient.desktop",
"build": { "build": {
"beforeDevCommand": "npm run dev --prefix ../aiclient_ui", "beforeDevCommand": "npm --prefix ../aiclientpureui run dev",
"beforeBuildCommand": "npm --prefix ../aiclientpureui run build:tauri",
"devUrl": "http://localhost:1420", "devUrl": "http://localhost:1420",
"frontendDist": "frontend-stub" "frontendDist": "../../aiclientpureui/dist"
}, },
"app": { "app": {
"withGlobalTauri": true, "withGlobalTauri": true,