Skip to content

Commit fca3822

Browse files
committed
add data manager
1 parent 6576f3b commit fca3822

File tree

13 files changed

+493
-11
lines changed

13 files changed

+493
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@fortawesome/fontawesome-free": "^6.7.2",
4141
"@tauri-apps/api": "^2.0.0-beta.0",
4242
"@tauri-apps/plugin-autostart": "^2.5.0",
43-
"@tauri-apps/plugin-dialog": "^2.0.0",
43+
"@tauri-apps/plugin-dialog": "~2",
4444
"@tauri-apps/plugin-opener": "^2.0.0",
4545
"@tauri-apps/plugin-process": "~2.3.0",
4646
"@tauri-apps/plugin-sql": "^2.0.0",

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 110 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ futures = "0.3.31"
4343
tracing = "0.1"
4444
lazy_static = "1.4.0"
4545
rmcp = { version = "0.3.2", features = ["transport-sse-server", "macros", "server"] }
46+
tauri-plugin-dialog = "2"
4647

4748
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
4849
tauri-plugin-updater = "2"

src-tauri/capabilities/default.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"process:default",
2222
"process:allow-restart",
2323
"process:default",
24+
"dialog:default",
2425
"aptabase:allow-track-event"
2526
]
2627
}

src-tauri/src/commands.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use crate::mcp_server::{
22
get_server_address, is_server_running, start_server_with_permissions, stop_server,
33
};
4+
use std::fs;
5+
use std::path::Path;
46
use tauri::Manager;
57
use tauri_plugin_aptabase::EventTracker;
68
use tauri_plugin_sql::{Migration, MigrationKind};
@@ -381,6 +383,20 @@ pub async fn get_mcp_server_status() -> Result<serde_json::Value, String> {
381383
}))
382384
}
383385

386+
/// 写入文本文件
387+
#[tauri::command]
388+
pub fn write_text_file(path: String, contents: String) -> Result<(), String> {
389+
// 确保父目录存在
390+
if let Some(parent) = Path::new(&path).parent() {
391+
fs::create_dir_all(parent).map_err(|e| format!("Failed to create directory: {}", e))?;
392+
}
393+
394+
// 写入文件
395+
fs::write(&path, contents).map_err(|e| format!("Failed to write file: {}", e))?;
396+
397+
Ok(())
398+
}
399+
384400
// ============================================================================
385401
// 事件追踪
386402
// ============================================================================

src-tauri/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub async fn run() {
2525
let migrations = commands::get_migrations();
2626

2727
let app = tauri::Builder::default()
28+
.plugin(tauri_plugin_dialog::init())
2829
.plugin(tauri_plugin_process::init())
2930
.plugin(tauri_plugin_opener::init())
3031
.plugin(tauri_plugin_clipboard_manager::init())
@@ -121,6 +122,7 @@ pub async fn run() {
121122
commands::start_mcp_server,
122123
commands::stop_mcp_server,
123124
commands::get_mcp_server_status,
125+
commands::write_text_file,
124126
commands::track_event,
125127
])
126128
.build(tauri::generate_context!())

0 commit comments

Comments
 (0)