fix: 修复项目切换时运行时和系统重复初始化问题 (#267)
* feat(editor): 添加 GitHub Discussions 社区论坛功能 * chore: 更新 pnpm-lock.yaml * chore: 删除测试图片 * refactor: 改用 Imgur 图床上传图片 * fix: 修复项目切换时运行时和系统重复初始化问题 * fix: 修复多个编辑器问题 * feat: 添加脚本编辑器配置和类型定义支持 * feat: 实现资产 .meta 文件自动生成功能
This commit is contained in:
@@ -22,10 +22,19 @@ export class TauriFileSystemService implements IFileSystem {
|
||||
|
||||
async exists(path: string): Promise<boolean> {
|
||||
try {
|
||||
await invoke('read_file_content', { path });
|
||||
// 首先尝试作为目录列出内容
|
||||
// First try to list as directory
|
||||
await invoke('list_directory', { path });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
// 如果不是目录,尝试读取文件
|
||||
// If not a directory, try reading as file
|
||||
try {
|
||||
await invoke('read_file_content', { path });
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,11 +43,19 @@ export class TauriFileSystemService implements IFileSystem {
|
||||
}
|
||||
|
||||
async listDirectory(path: string): Promise<FileEntry[]> {
|
||||
const entries = await invoke<Array<{ name: string; path: string; is_dir: boolean }>>('list_directory', { path });
|
||||
const entries = await invoke<Array<{
|
||||
name: string;
|
||||
path: string;
|
||||
is_dir: boolean;
|
||||
size?: number;
|
||||
modified?: number;
|
||||
}>>('list_directory', { path });
|
||||
return entries.map((entry) => ({
|
||||
name: entry.name,
|
||||
isDirectory: entry.is_dir,
|
||||
path: entry.path
|
||||
path: entry.path,
|
||||
size: entry.size,
|
||||
modified: entry.modified ? new Date(entry.modified * 1000) : undefined
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user