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
|
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) {
|
pub fn start_engine(app: AppHandle) {
|
||||||
// Start Cleanup routine
|
// Start Cleanup routine
|
||||||
let app_cleanup = app.clone();
|
let app_cleanup = app.clone();
|
||||||
|
|||||||
@@ -30,7 +30,8 @@ pub fn run() {
|
|||||||
engine::get_events,
|
engine::get_events,
|
||||||
engine::get_events_range,
|
engine::get_events_range,
|
||||||
engine::save_event,
|
engine::save_event,
|
||||||
engine::delete_event
|
engine::delete_event,
|
||||||
|
engine::write_file
|
||||||
])
|
])
|
||||||
.setup(|app| {
|
.setup(|app| {
|
||||||
app.manage(engine::AppState {
|
app.manage(engine::AppState {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import { ref, onMounted, onUnmounted, computed, nextTick } from "vue";
|
import { ref, onMounted, onUnmounted, computed, nextTick } from "vue";
|
||||||
import { load } from "@tauri-apps/plugin-store";
|
import { load } from "@tauri-apps/plugin-store";
|
||||||
import { open, save } from "@tauri-apps/plugin-dialog";
|
import { open, save } from "@tauri-apps/plugin-dialog";
|
||||||
import { writeTextFile } from "@tauri-apps/plugin-fs";
|
|
||||||
import { invoke } from "@tauri-apps/api/core";
|
import { invoke } from "@tauri-apps/api/core";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
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";
|
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
|
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;
|
isExportModalOpen.value = false;
|
||||||
showToast("导出成功");
|
showToast("导出成功");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user