mirror of
https://github.com/qingchencloud/clawpanel.git
synced 2026-06-06 00:00:06 +08:00
feat: Windows 兼容性全面改进
- Windows Gateway 启动改为前台 spawn 模式(绕过 schtasks 管理员权限) - 添加全局 Gateway 未启动引导横幅(黄色提示条 + 一键启动按钮) - 所有页面加载动画改为脉冲效果 - 统一 Windows cmd /c 调用加 CREATE_NO_WINDOW 标志 - 托盘菜单复用 service.rs 逻辑 - 新增 utils.rs 封装 openclaw_command - 修复 config 文件 UI 字段污染问题 - 添加 dev.ps1 启动脚本
This commit is contained in:
@@ -2,11 +2,21 @@
|
||||
use std::fs;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
use crate::utils::openclaw_command;
|
||||
|
||||
/// 检查路径是否包含不安全字符(目录遍历、绝对路径等)
|
||||
fn is_unsafe_path(path: &str) -> bool {
|
||||
path.contains("..")
|
||||
|| path.contains('\0')
|
||||
|| path.starts_with('/')
|
||||
|| path.starts_with('\\')
|
||||
|| (path.len() >= 2 && path.as_bytes()[1] == b':') // Windows 绝对路径 C:\
|
||||
}
|
||||
|
||||
/// 根据 agent_id 获取 workspace 路径
|
||||
/// 调用 openclaw agents list --json 解析
|
||||
fn agent_workspace(agent_id: &str) -> Result<PathBuf, String> {
|
||||
let output = std::process::Command::new("openclaw")
|
||||
let output = openclaw_command()
|
||||
.args(["agents", "list", "--json"])
|
||||
.output()
|
||||
.map_err(|e| format!("执行 openclaw 失败: {e}"))?;
|
||||
@@ -96,7 +106,7 @@ fn collect_files(
|
||||
|
||||
#[tauri::command]
|
||||
pub fn read_memory_file(path: String, agent_id: Option<String>) -> Result<String, String> {
|
||||
if path.contains("..") || path.starts_with('/') || path.contains('\0') {
|
||||
if is_unsafe_path(&path) {
|
||||
return Err("非法路径".to_string());
|
||||
}
|
||||
|
||||
@@ -122,7 +132,7 @@ pub fn read_memory_file(path: String, agent_id: Option<String>) -> Result<String
|
||||
|
||||
#[tauri::command]
|
||||
pub fn write_memory_file(path: String, content: String, category: Option<String>, agent_id: Option<String>) -> Result<(), String> {
|
||||
if path.contains("..") || path.starts_with('/') || path.contains('\0') {
|
||||
if is_unsafe_path(&path) {
|
||||
return Err("非法路径".to_string());
|
||||
}
|
||||
|
||||
@@ -139,7 +149,7 @@ pub fn write_memory_file(path: String, content: String, category: Option<String>
|
||||
|
||||
#[tauri::command]
|
||||
pub fn delete_memory_file(path: String, agent_id: Option<String>) -> Result<(), String> {
|
||||
if path.contains("..") || path.starts_with('/') || path.contains('\0') {
|
||||
if is_unsafe_path(&path) {
|
||||
return Err("非法路径".to_string());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user