[engine] [adapters] [common] 增加 WebSocket 和子包的开关

This commit is contained in:
SmallMain
2024-11-22 16:54:43 +08:00
parent d6fb7f841b
commit 5a03a9dc86
11 changed files with 66 additions and 6 deletions

View File

@@ -111,6 +111,8 @@ function getSettings() {
CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL: getMacroIntegerValue(content, "CC_WORKER_AUDIO_SYSTEM_SYNC_INTERVAL"),
CC_CUSTOM_WORKER: getMacroBooleanValue(content, "CC_CUSTOM_WORKER"),
CC_WORKER_HTTP_REQUEST: getMacroBooleanValue(content, "CC_WORKER_HTTP_REQUEST"),
CC_WORKER_WEBSOCKET: getMacroBooleanValue(content, "CC_WORKER_WEBSOCKET"),
CC_WORKER_SUB_PACKAGE: getMacroBooleanValue(content, "CC_WORKER_SUB_PACKAGE"),
};
}
}
@@ -175,7 +177,7 @@ function checkAndModifyWorkerFiles() {
const gameJson = JSON.parse(fs.readFileSync(gameJsonPath, { encoding: "utf-8" }));
// 是否启用 Worker
if (result.CC_WORKER_ASSET_PIPELINE || result.CC_WORKER_AUDIO_SYSTEM || result.CC_CUSTOM_WORKER || result.CC_WORKER_HTTP_REQUEST) {
if (result.CC_WORKER_ASSET_PIPELINE || result.CC_WORKER_AUDIO_SYSTEM || result.CC_CUSTOM_WORKER || result.CC_WORKER_HTTP_REQUEST || result.CC_WORKER_WEBSOCKET) {
// 没有 Worker 目录与配置的话提醒用户重新安装
if (!(gameJson.workers && fs.existsSync(workerDir))) {
Editor.error(t('thread_not_right_workers_dir'));
@@ -183,6 +185,12 @@ function checkAndModifyWorkerFiles() {
} else {
Editor.warn(t('thread_need_delete_files'));
}
// 是否使用子包
if (gameJson.workers) {
gameJson.workers.isSubpackage = result.CC_WORKER_SUB_PACKAGE;
fs.writeFileSync(gameJsonPath, JSON.stringify(gameJson, null, 2));
}
}
}