44f415d057
Project CI / AI game creator shell Rust lane 1/2 (push) Failing after 2m23s
Project CI / AI game creator shell Rust lane 2/2 (push) Failing after 1m15s
Project CI / AI game creator shell Rust crates (push) Successful in 1m14s
Project CI / AI game creator shell Rust smoke (push) Successful in 1m35s
Project CI / Frontend tests (push) Successful in 2m53s
Project CI / Repository checks (push) Successful in 3m36s
Project CI / Backend tests (push) Successful in 4m26s
Project CI / AI game creator shell web tests (push) Successful in 2m23s
Project CI / Native shell tests (push) Successful in 7m27s
- 合并 origin/master 58 个提交,解决 2 处文件冲突:决策记录与踩坑记录均按两侧新增条目并存处理 - claude_code_cli.rs 自动合并通过:本机 Claude sidecar 诊断改动与上游 sidecar 归位并存,无重复函数定义、无冲突残留 - 保留本地未推送提交:AGC Claude 执行认证与错误诊断、Claude sidecar 超时诊断 - 本次推送主体内容不变:生产 Nginx 模板收敛、host-only snippet 与运维/踩坑/决策文档同步
70 lines
2.4 KiB
TypeScript
70 lines
2.4 KiB
TypeScript
import type { ProjectStartMode, TauriInvoke } from '../../app/types';
|
|
import type { HomeCreationType } from '../../view/home/useHomeDraftStore';
|
|
|
|
export const HOME_WEB_PREFLIGHT_FAILURE =
|
|
'Web 游戏环境预检未通过,请检查 Node/npm 或浏览器后重试;尚未开始生成。';
|
|
|
|
export const HOME_WEB_PREFLIGHT_IPC_FAILURE =
|
|
'Web 游戏环境预检调用失败,客户端连接异常;请重启客户端后重试,尚未开始生成。';
|
|
|
|
type HomeWebPreflightReport = {
|
|
status?: string;
|
|
code?: string;
|
|
};
|
|
|
|
function knownPreflightCode(value: unknown): string | undefined {
|
|
const text = value instanceof Error ? value.message : value;
|
|
if (typeof text !== 'string') return undefined;
|
|
const match = text.match(
|
|
/(?:预检未通过:|预检未通过(|code[=:])([a-z0-9-]+)/i,
|
|
);
|
|
return match?.[1];
|
|
}
|
|
|
|
export function homeWebPreflightErrorMessage(value: unknown): string {
|
|
if (value instanceof Error && value.message === HOME_WEB_PREFLIGHT_FAILURE) {
|
|
return HOME_WEB_PREFLIGHT_FAILURE;
|
|
}
|
|
const code = knownPreflightCode(value);
|
|
if (code) return `Web 游戏环境预检未通过(${code});尚未开始生成。`;
|
|
return HOME_WEB_PREFLIGHT_IPC_FAILURE;
|
|
}
|
|
|
|
function isHostPreflightError(value: unknown): boolean {
|
|
if (!(value instanceof Error)) return false;
|
|
return (
|
|
value.message === HOME_WEB_PREFLIGHT_FAILURE ||
|
|
Boolean(knownPreflightCode(value.message))
|
|
);
|
|
}
|
|
|
|
export async function ensureHomeWebCreationEnvironment(
|
|
invoke: TauriInvoke,
|
|
creationType: HomeCreationType,
|
|
startMode: ProjectStartMode,
|
|
): Promise<void> {
|
|
if (creationType !== 'game' || startMode !== 'direct-build') return;
|
|
let lastError: unknown;
|
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
try {
|
|
const report = await invoke<HomeWebPreflightReport>(
|
|
'preflight_web_game_creation',
|
|
);
|
|
if (report?.status === 'ready') return;
|
|
throw new Error(
|
|
report?.code
|
|
? `Web 游戏环境预检未通过:${report.code}`
|
|
: HOME_WEB_PREFLIGHT_FAILURE,
|
|
);
|
|
} catch (error) {
|
|
lastError = error;
|
|
const code = knownPreflightCode(error);
|
|
if (isHostPreflightError(error) || code || attempt === 1) {
|
|
throw new Error(homeWebPreflightErrorMessage(error));
|
|
}
|
|
await new Promise((resolve) => window.setTimeout(resolve, 250));
|
|
}
|
|
}
|
|
throw new Error(homeWebPreflightErrorMessage(lastError));
|
|
}
|