save json
This commit is contained in:
@@ -168,6 +168,11 @@ pub fn get_timeline(date: String, base_dir: String) -> Vec<serde_json::Value> {
|
||||
results
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn write_file(path: String, content: String) -> Result<(), String> {
|
||||
std::fs::write(&path, content).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
pub fn start_engine(app: AppHandle) {
|
||||
// Start Cleanup routine
|
||||
let app_cleanup = app.clone();
|
||||
|
||||
@@ -30,7 +30,8 @@ pub fn run() {
|
||||
engine::get_events,
|
||||
engine::get_events_range,
|
||||
engine::save_event,
|
||||
engine::delete_event
|
||||
engine::delete_event,
|
||||
engine::write_file
|
||||
])
|
||||
.setup(|app| {
|
||||
app.manage(engine::AppState {
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { ref, onMounted, onUnmounted, computed, nextTick } from "vue";
|
||||
import { load } from "@tauri-apps/plugin-store";
|
||||
import { open, save } from "@tauri-apps/plugin-dialog";
|
||||
import { writeTextFile } from "@tauri-apps/plugin-fs";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { listen } from "@tauri-apps/api/event";
|
||||
import { Tag as TagIcon, FolderOpen, Settings, Play, Pause, Maximize2, X, RefreshCw, Plus, Trash2, ChevronDown, ChevronLeft, ChevronRight, Calendar, Download } from "lucide-vue-next";
|
||||
@@ -380,7 +379,7 @@ const handleExport = async () => {
|
||||
content: e.content
|
||||
}));
|
||||
|
||||
await writeTextFile(savePath, JSON.stringify(exportData, null, 2));
|
||||
await invoke("write_file", { path: savePath, content: JSON.stringify(exportData, null, 2) });
|
||||
isExportModalOpen.value = false;
|
||||
showToast("导出成功");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user