fix(web): validate empty @ references before submit
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
This commit is contained in:
parent
991bb6dd30
commit
540f8ef4bb
@ -54,6 +54,15 @@ function mapProgress(backendStatus: string): number {
|
|||||||
return 50;
|
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). */
|
/** Check if a URL is an asset library reference (case-insensitive protocol). */
|
||||||
function isAssetUrl(url: string): boolean {
|
function isAssetUrl(url: string): boolean {
|
||||||
return url.startsWith('asset://') || url.startsWith('Asset://');
|
return url.startsWith('asset://') || url.startsWith('Asset://');
|
||||||
@ -314,6 +323,10 @@ export const useGenerationStore = create<GenerationState>((set, get) => ({
|
|||||||
|
|
||||||
addTask: async () => {
|
addTask: async () => {
|
||||||
const input = useInputBarStore.getState();
|
const input = useInputBarStore.getState();
|
||||||
|
if (hasOrphanMaterialMention(input)) {
|
||||||
|
showToast('@对应的内容为空');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
if (!input.canSubmit()) return null;
|
if (!input.canSubmit()) return null;
|
||||||
|
|
||||||
// Collect files to upload (or existing TOS URLs for regeneration)
|
// Collect files to upload (or existing TOS URLs for regeneration)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user