2025-11-25 22:23:19 +08:00
|
|
|
|
import { invoke, convertFileSrc } from '@tauri-apps/api/core';
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-18 14:46:51 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 文件过滤器定义
|
|
|
|
|
|
*/
|
|
|
|
|
|
interface FileFilter {
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
extensions: string[];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-14 22:53:26 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* Tauri IPC 通信层
|
|
|
|
|
|
*/
|
|
|
|
|
|
export class TauriAPI {
|
2025-11-18 14:46:51 +08:00
|
|
|
|
static async openFolderDialog(title?: string): Promise<string | null> {
|
|
|
|
|
|
return await invoke<string | null>('open_folder_dialog', { title });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static async openFileDialog(
|
|
|
|
|
|
title?: string,
|
|
|
|
|
|
filters?: FileFilter[],
|
|
|
|
|
|
multiple?: boolean
|
|
|
|
|
|
): Promise<string[] | null> {
|
|
|
|
|
|
return await invoke<string[] | null>('open_file_dialog', {
|
|
|
|
|
|
title,
|
|
|
|
|
|
filters,
|
|
|
|
|
|
multiple
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static async saveFileDialog(
|
|
|
|
|
|
title?: string,
|
|
|
|
|
|
defaultName?: string,
|
2025-12-13 19:44:08 +08:00
|
|
|
|
filters?: FileFilter[],
|
|
|
|
|
|
defaultPath?: string
|
2025-11-18 14:46:51 +08:00
|
|
|
|
): Promise<string | null> {
|
|
|
|
|
|
return await invoke<string | null>('save_file_dialog', {
|
|
|
|
|
|
title,
|
|
|
|
|
|
defaultName,
|
2025-12-13 19:44:08 +08:00
|
|
|
|
defaultPath,
|
2025-11-18 14:46:51 +08:00
|
|
|
|
filters
|
|
|
|
|
|
});
|
2025-11-02 23:50:41 +08:00
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async openProjectDialog(): Promise<string | null> {
|
2025-11-18 14:46:51 +08:00
|
|
|
|
return await this.openFolderDialog('Select Project Directory');
|
2025-11-02 23:50:41 +08:00
|
|
|
|
}
|
2025-10-15 00:23:19 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async openProject(path: string): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('open_project', { path });
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-14 22:53:26 +08:00
|
|
|
|
* 保存项目
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async saveProject(path: string, data: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('save_project', { path, data });
|
|
|
|
|
|
}
|
2025-10-14 22:53:26 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-14 22:53:26 +08:00
|
|
|
|
* 导出二进制数据
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async exportBinary(data: Uint8Array, outputPath: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('export_binary', {
|
|
|
|
|
|
data: Array.from(data),
|
|
|
|
|
|
outputPath
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-10-15 00:40:27 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-15 00:40:27 +08:00
|
|
|
|
* 扫描目录查找匹配模式的文件
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async scanDirectory(path: string, pattern: string): Promise<string[]> {
|
|
|
|
|
|
return await invoke<string[]>('scan_directory', { path, pattern });
|
|
|
|
|
|
}
|
2025-10-15 00:40:27 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-15 00:40:27 +08:00
|
|
|
|
* 读取文件内容
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async readFileContent(path: string): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('read_file_content', { path });
|
|
|
|
|
|
}
|
2025-10-15 09:43:48 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-15 09:43:48 +08:00
|
|
|
|
* 列出目录内容
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async listDirectory(path: string): Promise<DirectoryEntry[]> {
|
|
|
|
|
|
return await invoke<DirectoryEntry[]>('list_directory', { path });
|
|
|
|
|
|
}
|
2025-10-15 17:15:05 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-15 17:15:05 +08:00
|
|
|
|
* 设置项目基础路径,用于 Custom Protocol
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async setProjectBasePath(path: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('set_project_base_path', { path });
|
|
|
|
|
|
}
|
2025-10-15 20:23:55 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-15 20:23:55 +08:00
|
|
|
|
* 切换开发者工具(仅在debug模式下可用)
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async toggleDevtools(): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('toggle_devtools');
|
|
|
|
|
|
}
|
2025-10-17 18:13:31 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-12-13 19:44:08 +08:00
|
|
|
|
* 打开保存场景对话框
|
|
|
|
|
|
* Open save scene dialog
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param defaultName 默认文件名(可选)| Default file name (optional)
|
|
|
|
|
|
* @param scenesDir 场景目录路径(可选)| Scenes directory path (optional)
|
|
|
|
|
|
* @returns 用户选择的文件路径,取消则返回 null | Selected file path or null
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async saveSceneDialog(defaultName?: string, scenesDir?: string): Promise<string | null> {
|
2025-11-18 14:46:51 +08:00
|
|
|
|
return await this.saveFileDialog(
|
|
|
|
|
|
'Save ECS Scene',
|
|
|
|
|
|
defaultName,
|
2025-12-13 19:44:08 +08:00
|
|
|
|
[{ name: 'ECS Scene Files', extensions: ['ecs'] }],
|
|
|
|
|
|
scenesDir
|
2025-11-18 14:46:51 +08:00
|
|
|
|
);
|
2025-11-02 23:50:41 +08:00
|
|
|
|
}
|
2025-10-17 18:13:31 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-17 18:13:31 +08:00
|
|
|
|
* 打开场景文件选择对话框
|
|
|
|
|
|
* @returns 用户选择的文件路径,取消则返回 null
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async openSceneDialog(): Promise<string | null> {
|
2025-11-18 14:46:51 +08:00
|
|
|
|
const result = await this.openFileDialog(
|
|
|
|
|
|
'Open ECS Scene',
|
|
|
|
|
|
[{ name: 'ECS Scene Files', extensions: ['ecs'] }],
|
|
|
|
|
|
false
|
|
|
|
|
|
);
|
|
|
|
|
|
return result && result[0] ? result[0] : null;
|
2025-11-02 23:50:41 +08:00
|
|
|
|
}
|
2025-10-17 18:13:31 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-17 18:13:31 +08:00
|
|
|
|
* 创建目录
|
|
|
|
|
|
* @param path 目录路径
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async createDirectory(path: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('create_directory', { path });
|
|
|
|
|
|
}
|
2025-10-17 18:13:31 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-17 18:13:31 +08:00
|
|
|
|
* 写入文件内容
|
|
|
|
|
|
* @param path 文件路径
|
|
|
|
|
|
* @param content 文件内容
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async writeFileContent(path: string, content: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('write_file_content', { path, content });
|
|
|
|
|
|
}
|
2025-10-17 18:13:31 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-17 18:13:31 +08:00
|
|
|
|
* 检查路径是否存在
|
|
|
|
|
|
* @param path 文件或目录路径
|
|
|
|
|
|
* @returns 路径是否存在
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async pathExists(path: string): Promise<boolean> {
|
|
|
|
|
|
return await invoke<boolean>('path_exists', { path });
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-27 09:29:11 +08:00
|
|
|
|
* 使用系统默认程序打开文件
|
|
|
|
|
|
* @param path 文件路径
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async openFileWithSystemApp(path: string): Promise<void> {
|
|
|
|
|
|
await invoke('open_file_with_default_app', { filePath: path });
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-27 09:29:11 +08:00
|
|
|
|
* 在文件管理器中显示文件
|
|
|
|
|
|
* @param path 文件路径
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async showInFolder(path: string): Promise<void> {
|
|
|
|
|
|
await invoke('show_in_folder', { filePath: path });
|
|
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-12-04 14:04:39 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 使用指定编辑器打开项目
|
|
|
|
|
|
* Open project with specified editor
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param projectPath 项目文件夹路径 | Project folder path
|
|
|
|
|
|
* @param editorCommand 编辑器命令(如 "code", "cursor")| Editor command
|
|
|
|
|
|
* @param filePath 可选的要打开的文件路径 | Optional file path to open
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async openWithEditor(
|
|
|
|
|
|
projectPath: string,
|
|
|
|
|
|
editorCommand: string,
|
|
|
|
|
|
filePath?: string
|
|
|
|
|
|
): Promise<void> {
|
|
|
|
|
|
await invoke('open_with_editor', {
|
|
|
|
|
|
projectPath,
|
|
|
|
|
|
editorCommand,
|
|
|
|
|
|
filePath: filePath || null
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-27 09:29:11 +08:00
|
|
|
|
* 打开行为树文件选择对话框
|
|
|
|
|
|
* @returns 用户选择的文件路径,取消则返回 null
|
|
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async openBehaviorTreeDialog(): Promise<string | null> {
|
2025-11-18 14:46:51 +08:00
|
|
|
|
const result = await this.openFileDialog(
|
|
|
|
|
|
'Select Behavior Tree',
|
|
|
|
|
|
[{ name: 'Behavior Tree Files', extensions: ['btree'] }],
|
|
|
|
|
|
false
|
|
|
|
|
|
);
|
|
|
|
|
|
return result && result[0] ? result[0] : null;
|
2025-11-02 23:50:41 +08:00
|
|
|
|
}
|
2025-10-27 09:29:11 +08:00
|
|
|
|
|
2025-11-02 23:50:41 +08:00
|
|
|
|
/**
|
2025-10-27 09:29:11 +08:00
|
|
|
|
* 扫描项目中的所有行为树文件
|
|
|
|
|
|
* @param projectPath 项目路径
|
2025-11-18 14:46:51 +08:00
|
|
|
|
* @returns 行为树资产ID列表(相对于 .ecs/behaviors 的路 径,不含扩展名)
|
2025-10-27 09:29:11 +08:00
|
|
|
|
*/
|
2025-11-02 23:50:41 +08:00
|
|
|
|
static async scanBehaviorTrees(projectPath: string): Promise<string[]> {
|
|
|
|
|
|
return await invoke<string[]>('scan_behavior_trees', { projectPath });
|
|
|
|
|
|
}
|
2025-11-04 18:29:28 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 重命名文件或文件夹
|
|
|
|
|
|
* @param oldPath 原路径
|
|
|
|
|
|
* @param newPath 新路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async renameFileOrFolder(oldPath: string, newPath: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('rename_file_or_folder', { oldPath, newPath });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除文件
|
|
|
|
|
|
* @param path 文件路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async deleteFile(path: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('delete_file', { path });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 删除文件夹
|
|
|
|
|
|
* @param path 文件夹路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async deleteFolder(path: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('delete_folder', { path });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 创建文件
|
|
|
|
|
|
* @param path 文件路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async createFile(path: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('create_file', { path });
|
|
|
|
|
|
}
|
2025-11-18 14:46:51 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 读取文件并转换为base64
|
|
|
|
|
|
* @param path 文件路径
|
|
|
|
|
|
* @returns base64编码的文件内容
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async readFileAsBase64(path: string): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('read_file_as_base64', { filePath: path });
|
|
|
|
|
|
}
|
2025-11-23 14:49:37 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 复制文件
|
|
|
|
|
|
* @param src 源文件路径
|
|
|
|
|
|
* @param dst 目标文件路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async copyFile(src: string, dst: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('copy_file', { src, dst });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-16 12:46:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取文件修改时间
|
|
|
|
|
|
* Get file modification time
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param path 文件路径 | File path
|
|
|
|
|
|
* @returns 文件修改时间(毫秒时间戳)| File modification time (milliseconds timestamp)
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async getFileMtime(path: string): Promise<number> {
|
|
|
|
|
|
return await invoke<number>('get_file_mtime', { path });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-27 20:42:46 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 写入二进制文件
|
|
|
|
|
|
* @param filePath 文件路径
|
|
|
|
|
|
* @param content 二进制数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async writeBinaryFile(filePath: string, content: Uint8Array): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('write_binary_file', {
|
|
|
|
|
|
filePath,
|
|
|
|
|
|
content: Array.from(content)
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-23 14:49:37 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取临时目录路径
|
|
|
|
|
|
* @returns 临时目录路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async getTempDir(): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('get_temp_dir');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取应用资源目录
|
|
|
|
|
|
* @returns 资源目录路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async getAppResourceDir(): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('get_app_resource_dir');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取当前工作目录
|
|
|
|
|
|
* @returns 当前工作目录路径
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async getCurrentDir(): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('get_current_dir');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 启动本地HTTP服务器
|
|
|
|
|
|
* @param rootPath 服务器根目录
|
|
|
|
|
|
* @param port 端口号
|
|
|
|
|
|
* @returns 服务器URL
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async startLocalServer(rootPath: string, port: number): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('start_local_server', { rootPath, port });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 停止本地HTTP服务器
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async stopLocalServer(): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('stop_local_server');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 获取本机局域网IP地址
|
|
|
|
|
|
* @returns 局域网IP地址
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async getLocalIp(): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('get_local_ip');
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 生成二维码
|
|
|
|
|
|
* @param text 要编码的文本
|
|
|
|
|
|
* @returns base64编码的PNG图片
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async generateQRCode(text: string): Promise<string> {
|
|
|
|
|
|
return await invoke<string>('generate_qrcode', { text });
|
|
|
|
|
|
}
|
2025-11-25 22:23:19 +08:00
|
|
|
|
|
2025-12-04 14:04:39 +08:00
|
|
|
|
/**
|
2025-12-04 19:32:51 +08:00
|
|
|
|
* 更新项目的 tsconfig.json,添加引擎类型路径
|
|
|
|
|
|
* Update project tsconfig.json with engine type paths
|
|
|
|
|
|
*
|
|
|
|
|
|
* This updates the tsconfig to point directly to engine's .d.ts files
|
|
|
|
|
|
* instead of copying them to the project.
|
|
|
|
|
|
* 这会更新 tsconfig 直接指向引擎的 .d.ts 文件,而不是复制到项目。
|
2025-12-04 14:04:39 +08:00
|
|
|
|
*
|
|
|
|
|
|
* @param projectPath 项目路径 | Project path
|
|
|
|
|
|
*/
|
2025-12-04 19:32:51 +08:00
|
|
|
|
static async updateProjectTsconfig(projectPath: string): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('update_project_tsconfig', { projectPath });
|
2025-12-04 14:04:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-25 22:23:19 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 将本地文件路径转换为 Tauri 可访问的 asset URL
|
|
|
|
|
|
* @param filePath 本地文件路径
|
|
|
|
|
|
* @param protocol 协议类型 (默认: 'asset')
|
|
|
|
|
|
* @returns 转换后的 URL,可用于 img src、audio src 等
|
|
|
|
|
|
* @example
|
|
|
|
|
|
* const url = TauriAPI.convertFileSrc('C:\\Users\\...\\image.png');
|
|
|
|
|
|
* // 返回: 'https://asset.localhost/C:/Users/.../image.png'
|
|
|
|
|
|
*/
|
|
|
|
|
|
static convertFileSrc(filePath: string, protocol?: string): string {
|
|
|
|
|
|
return convertFileSrc(filePath, protocol);
|
|
|
|
|
|
}
|
2025-12-05 14:24:09 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 检测开发环境
|
|
|
|
|
|
* Check development environment
|
|
|
|
|
|
*
|
|
|
|
|
|
* Checks if all required tools (esbuild, etc.) are available.
|
|
|
|
|
|
* 检查所有必需的工具是否可用。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @returns 环境检测结果 | Environment check result
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async checkEnvironment(): Promise<EnvironmentCheckResult> {
|
|
|
|
|
|
return await invoke<EnvironmentCheckResult>('check_environment');
|
|
|
|
|
|
}
|
2025-12-13 19:44:08 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 安装 esbuild(全局)
|
|
|
|
|
|
* Install esbuild globally via npm
|
|
|
|
|
|
*
|
|
|
|
|
|
* This command installs esbuild globally using `npm install -g esbuild`.
|
|
|
|
|
|
* 使用 `npm install -g esbuild` 全局安装 esbuild。
|
|
|
|
|
|
*
|
|
|
|
|
|
* @returns Promise that resolves when installation completes
|
|
|
|
|
|
*/
|
|
|
|
|
|
static async installEsbuild(): Promise<void> {
|
|
|
|
|
|
return await invoke<void>('install_esbuild');
|
|
|
|
|
|
}
|
2025-12-05 14:24:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 工具可用性状态
|
|
|
|
|
|
* Tool availability status
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface ToolStatus {
|
|
|
|
|
|
/** 工具是否可用 | Whether the tool is available */
|
|
|
|
|
|
available: boolean;
|
|
|
|
|
|
/** 工具版本 | Tool version */
|
|
|
|
|
|
version?: string;
|
|
|
|
|
|
/** 工具路径 | Tool path */
|
|
|
|
|
|
path?: string;
|
|
|
|
|
|
/** 工具来源: "bundled", "local", "global" | Tool source */
|
|
|
|
|
|
source?: string;
|
|
|
|
|
|
/** 错误信息 | Error message */
|
|
|
|
|
|
error?: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 环境检测结果
|
|
|
|
|
|
* Environment check result
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface EnvironmentCheckResult {
|
|
|
|
|
|
/** 所有必需工具是否可用 | Whether all required tools are available */
|
|
|
|
|
|
ready: boolean;
|
|
|
|
|
|
/** esbuild 可用性状态 | esbuild availability status */
|
|
|
|
|
|
esbuild: ToolStatus;
|
2025-10-15 09:43:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export interface DirectoryEntry {
|
2025-11-18 14:46:51 +08:00
|
|
|
|
name: string;
|
|
|
|
|
|
path: string;
|
|
|
|
|
|
is_dir: boolean;
|
|
|
|
|
|
size?: number;
|
|
|
|
|
|
modified?: number;
|
2025-10-14 22:53:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 项目信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface ProjectInfo {
|
2025-11-18 14:46:51 +08:00
|
|
|
|
name: string;
|
|
|
|
|
|
path: string;
|
|
|
|
|
|
version: string;
|
2025-10-14 22:53:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 编辑器配置
|
|
|
|
|
|
*/
|
|
|
|
|
|
export interface EditorConfig {
|
2025-11-18 14:46:51 +08:00
|
|
|
|
theme: string;
|
|
|
|
|
|
autoSave: boolean;
|
|
|
|
|
|
recentProjects: string[];
|
2025-10-14 22:53:26 +08:00
|
|
|
|
}
|