fix(web): validate empty @ references before submit
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
zyc 2026-05-25 14:07:29 +08:00
parent 991bb6dd30
commit 540f8ef4bb

View File

@ -54,6 +54,15 @@ function mapProgress(backendStatus: string): number {
return 50;
}
const ORPHAN_MATERIAL_MENTION_RE = /@(?:图片|视频|音频|素材)\S*/;
function hasOrphanMaterialMention(input: ReturnType<typeof useInputBarStore.getState>): boolean {
if (input.mode !== 'universal') return false;
const hasDirectRefs = input.references.length > 0;
const hasAssetMentions = (input.assetMentions || []).length > 0;
return !hasDirectRefs && !hasAssetMentions && ORPHAN_MATERIAL_MENTION_RE.test(input.prompt);
}
/** Check if a URL is an asset library reference (case-insensitive protocol). */
function isAssetUrl(url: string): boolean {
return url.startsWith('asset://') || url.startsWith('Asset://');
@ -314,6 +323,10 @@ export const useGenerationStore = create<GenerationState>((set, get) => ({
addTask: async () => {
const input = useInputBarStore.getState();
if (hasOrphanMaterialMention(input)) {
showToast('@对应的内容为空');
return null;
}
if (!input.canSubmit()) return null;
// Collect files to upload (or existing TOS URLs for regeneration)