新增: Phase2 阶段收尾(Sprint 1-20)
重构:删 5 零引用 crate(df-evolve/plugin/stages/task/traceability)+ 清死模块、ai.rs 拆 11 子 module、ai.ts 拆 6 composable、i18n 拆目录 功能:知识库全栈(df-project/scan + CRUD + 时间线 + 前端)、Settings 拆分、appSettings KV 迁移、模型池、LLM 并发 Semaphore 修复:审批持久化根治、ConditionEngine 默认拒绝、NodeRegistry unimplemented 清除、promote 补偿删除、工具结果截断 50KB、路径校验防 symlink 逃逸 文档:B-03 人工审批设计、决策记录三分档、规格契约自检、经验记录、todo 看板、PROGRESS 更新 详见 PROGRESS.md。src-tauri/儿童每日打卡应用/ 与本项目无关,已排除。
This commit is contained in:
47
src-tauri/src/commands/settings.rs
Normal file
47
src-tauri/src/commands/settings.rs
Normal file
@@ -0,0 +1,47 @@
|
||||
//! 通用应用设置 KV IPC — 前端 localStorage 迁移目标
|
||||
//!
|
||||
//! 4 个 command 读写 `app_settings` 表(key/value JSON 字符串),承载主题、面板折叠态、
|
||||
//! 最近使用项等前端持久化偏好。返回统一 `Result<T, String>`。
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use tauri::State;
|
||||
|
||||
use crate::state::AppState;
|
||||
|
||||
/// 取单个 key 的值(JSON 字符串),不存在返回 None
|
||||
#[tauri::command]
|
||||
pub async fn settings_get(
|
||||
state: State<'_, AppState>,
|
||||
key: String,
|
||||
) -> Result<Option<String>, String> {
|
||||
state.settings.get(&key).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// 写 key/value(`INSERT OR REPLACE`),刷新 updated_at
|
||||
#[tauri::command]
|
||||
pub async fn settings_set(
|
||||
state: State<'_, AppState>,
|
||||
key: String,
|
||||
value: String,
|
||||
) -> Result<bool, String> {
|
||||
state.settings.set(&key, &value).await.map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// 取全部 key/value(前端启动时一次性拉回恢复偏好)
|
||||
#[tauri::command]
|
||||
pub async fn settings_get_all(
|
||||
state: State<'_, AppState>,
|
||||
) -> Result<HashMap<String, String>, String> {
|
||||
let rows = state.settings.get_all().await.map_err(|e| e.to_string())?;
|
||||
Ok(rows.into_iter().collect())
|
||||
}
|
||||
|
||||
/// 删除单个 key
|
||||
#[tauri::command]
|
||||
pub async fn settings_delete(
|
||||
state: State<'_, AppState>,
|
||||
key: String,
|
||||
) -> Result<bool, String> {
|
||||
state.settings.delete(&key).await.map_err(|e| e.to_string())
|
||||
}
|
||||
Reference in New Issue
Block a user