import { invoke } from '@tauri-apps/api/core'; /** * Tauri IPC 通信层 */ export class TauriAPI { /** * 打招呼(测试命令) */ static async greet(name: string): Promise { return await invoke('greet', { name }); } static async openProjectDialog(): Promise { return await invoke('open_project_dialog'); } static async openProject(path: string): Promise { return await invoke('open_project', { path }); } /** * 保存项目 */ static async saveProject(path: string, data: string): Promise { return await invoke('save_project', { path, data }); } /** * 导出二进制数据 */ static async exportBinary(data: Uint8Array, outputPath: string): Promise { return await invoke('export_binary', { data: Array.from(data), outputPath }); } /** * 扫描目录查找匹配模式的文件 */ static async scanDirectory(path: string, pattern: string): Promise { return await invoke('scan_directory', { path, pattern }); } /** * 读取文件内容 */ static async readFileContent(path: string): Promise { return await invoke('read_file_content', { path }); } /** * 列出目录内容 */ static async listDirectory(path: string): Promise { return await invoke('list_directory', { path }); } /** * 设置项目基础路径,用于 Custom Protocol */ static async setProjectBasePath(path: string): Promise { return await invoke('set_project_base_path', { path }); } /** * 切换开发者工具(仅在debug模式下可用) */ static async toggleDevtools(): Promise { return await invoke('toggle_devtools'); } } export interface DirectoryEntry { name: string; path: string; is_dir: boolean; } /** * 项目信息 */ export interface ProjectInfo { name: string; path: string; version: string; } /** * 编辑器配置 */ export interface EditorConfig { theme: string; autoSave: boolean; recentProjects: string[]; }