补强静态发布安全边界

This commit is contained in:
2026-08-10 18:27:53 +08:00
parent 4df047708b
commit 8dd99c1855
15 changed files with 560 additions and 85 deletions

View File

@@ -135,9 +135,15 @@ export type WorksProjectSourcePublishInput = {
project: WorksProjectMetadataInput;
};
export type WorksSubmissionBindingWarning = {
code: 'LOCAL_PREVIEW_BINDING_SAVE_FAILED';
message: string;
};
export type WorksProjectSourcePublishResult = {
package: WorksStaticPackageSummary;
upload: WorksProjectVersionUpload;
bindingWarning?: WorksSubmissionBindingWarning;
};
export type WorksSpeechTranscription = {
@@ -416,6 +422,7 @@ export async function publishWorksProjectSource(
error?: string;
package?: WorksStaticPackageSummary;
upload?: WorksProjectVersionUpload;
binding_warning?: unknown;
}>('/api/works/projects/publish-source', {
method: 'POST',
body: JSON.stringify({
@@ -430,7 +437,18 @@ export async function publishWorksProjectSource(
response.code,
);
}
return { package: response.package, upload: response.upload };
const bindingWarning = isRecord(response.binding_warning)
&& response.binding_warning.code === 'LOCAL_PREVIEW_BINDING_SAVE_FAILED'
? {
code: 'LOCAL_PREVIEW_BINDING_SAVE_FAILED' as const,
message: '已提交云端,但本机预览绑定保存失败;可重新打开项目/重新提交。',
}
: undefined;
return {
package: response.package,
upload: response.upload,
...(bindingWarning ? { bindingWarning } : {}),
};
}
export async function fetchWorksProjectVersions(