feat(editor): 实现用户脚本编译加载和自动重编译 (#273)

This commit is contained in:
YHH
2025-12-04 19:32:51 +08:00
committed by GitHub
parent 3d16bbdc64
commit 0d9bab910e
17 changed files with 951 additions and 127 deletions

View File

@@ -188,6 +188,46 @@ export class PlatformDetector {
window.location !== undefined;
}
/**
* 检测是否在 Tauri 桌面环境中运行
* Check if running in Tauri desktop environment
*
* 同时支持 Tauri v1 (__TAURI__) 和 v2 (__TAURI_INTERNALS__)
* Supports both Tauri v1 (__TAURI__) and v2 (__TAURI_INTERNALS__)
*/
public static isTauriEnvironment(): boolean {
if (typeof window === 'undefined') {
return false;
}
// Tauri v1 uses __TAURI__, Tauri v2 uses __TAURI_INTERNALS__
return '__TAURI__' in window || '__TAURI_INTERNALS__' in window;
}
/**
* 检测是否在编辑器环境中运行
* Check if running in editor environment
*
* 包括 Tauri 桌面应用或带 __ESENGINE_EDITOR__ 标记的环境
* Includes Tauri desktop app or environments marked with __ESENGINE_EDITOR__
*/
public static isEditorEnvironment(): boolean {
if (typeof window === 'undefined') {
return false;
}
// Tauri desktop app | Tauri 桌面应用
if (this.isTauriEnvironment()) {
return true;
}
// Editor marker | 编辑器标记
if ('__ESENGINE_EDITOR__' in window) {
return true;
}
return false;
}
/**
* 获取详细的环境信息(用于调试)
*/