Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: cross-platform openFile and openInEditor commands

esengine8f4bafa456e4
diff --git a/desktop/src/native-fs.ts b/desktop/src/native-fs.ts
index 4c059b959..d3ffc04d6 100644
--- a/desktop/src/native-fs.ts
+++ b/desktop/src/native-fs.ts
@@ -437,11 +437,7 @@ export const nativeFS: NativeFS = {
export const nativeShell: NativeShell = {
async openFile(path: string): Promise<void> {
- await invoke('execute_command', {
- cmd: 'open',
- args: [path],
- cwd: '/',
- });
+ await shellOpen(path);
},
async openUrl(url: string): Promise<void> {
@@ -449,11 +445,20 @@ export const nativeShell: NativeShell = {
},
async openInEditor(projectPath: string, filePath: string): Promise<void> {
- await invoke('execute_command', {
- cmd: 'open',
- args: ['-a', 'Visual Studio Code', projectPath, filePath],
- cwd: projectPath,
- });
+ const isMac = navigator.platform.startsWith('Mac');
+ if (isMac) {
+ await invoke('execute_command', {
+ cmd: 'open',
+ args: ['-a', 'Visual Studio Code', projectPath, filePath],
+ cwd: projectPath,
+ });
+ } else {
+ await invoke('execute_command', {
+ cmd: 'cmd',
+ args: ['/c', 'code', projectPath, filePath],
+ cwd: projectPath,
+ });
+ }
},
async execute(