fix(short-drama-agent-front): 修复代码格式检查问题

This commit is contained in:
GJ committed 2026-10-21 17:04:02 +08:00
1 parent 81d6a85260
commit 48fce3975f
87 files changed
+5714 -1436

No files matched your search

@@ -215,7 +215,11 @@ async function save() {
emit('saved', profile.value)
} catch (cause) {
if (!disposed && props.projectId === projectId)
showActionFeedback(feedback, errorMessage(cause), cause instanceof ApiError && cause.status === 409 ? 'warning' : 'error')
showActionFeedback(
feedback,
errorMessage(cause),
cause instanceof ApiError && cause.status === 409 ? 'warning' : 'error'
)
} finally {
saving.value = false
}
@@ -103,7 +103,11 @@ function selectValue(key: string): string | number | null {
:show-feedback="false"
>
<!-- 以下是生成参数标签与说明提示模块 -->
<template #label><FieldLabel :label="userFacingText(item.label, item.label)" :description="userFacingText(item.description)" /></template>
<template #label
><FieldLabel
:label="userFacingText(item.label, item.label)"
:description="userFacingText(item.description)"
/></template>
<div class="generation-model-field-control">
<div v-if="item.type === 'boolean'" class="generation-model-toggle">
<NSwitch
@@ -70,7 +70,10 @@ function constrainedOptions(schema: GenerationOptionSchema, current: string | nu
}
}
if (typeof schema.providerDefault === 'string' || typeof schema.providerDefault === 'number') {
options.push({ label: userFacingText(String(schema.providerDefault), String(schema.providerDefault)), value: schema.providerDefault })
options.push({
label: userFacingText(String(schema.providerDefault), String(schema.providerDefault)),
value: schema.providerDefault
})
}
if (typeof current === 'string' || typeof current === 'number') {
options.push({ label: userFacingText(String(current), String(current)), value: current })
@@ -17,7 +17,12 @@ defineProps<{
<p class="text-xs leading-6 text-muted">这些例外会继续保留。新增例外请在拆解后的具体动作问题中填写。</p>
<ul class="mt-3 space-y-3">
<li v-for="(item, index) in exceptions" :key="index" class="space-y-1 break-words text-sm">
<p>{{ item.ownerRef }} · {{ actionResourceOptions.find(option => option.value === item.resource)?.label || item.resource }}</p>
<p>
{{ item.ownerRef }} ·
{{
actionResourceOptions.find(option => option.value === item.resource)?.label || item.resource
}}
</p>
<p class="text-xs leading-6 text-muted">{{ item.reason }}</p>
</li>
</ul>
@@ -35,22 +35,37 @@ const policy = ref<ProjectQualityPolicy | null>(null)
let savedGeneralSignature = ''
/** 整体表现方式及通俗示例,仅说明含义,不自动修改动作许可。 */
const physicsOptions = [
{ value: 'realistic', label: '写实物理', description: '按现实生活中的规律设计动作,例如跳起需要借力,物品失去支撑会落下。' },
{ value: 'stylized', label: '风格化表现', description: '适合卡通、喜剧,让动作更有戏剧感;具体允许哪些夸张动作,还需在下方勾选。' },
{ value: 'fantasy', label: '幻想表现', description: '适合仙侠、魔法等故事,按故事设定设计动作;飞行、法术等能力仍需在下方明确允许。' }
{
value: 'realistic',
label: '写实物理',
description: '按现实生活中的规律设计动作,例如跳起需要借力,物品失去支撑会落下。'
},
{
value: 'stylized',
label: '风格化表现',
description: '适合卡通、喜剧,让动作更有戏剧感;具体允许哪些夸张动作,还需在下方勾选。'
},
{
value: 'fantasy',
label: '幻想表现',
description: '适合仙侠、魔法等故事,按故事设定设计动作;飞行、法术等能力仍需在下方明确允许。'
}
]
/** 当前选择的说明始终显示,关闭下拉菜单后也能了解含义。 */
const physicsDescription = computed(() => physicsOptions.find(option => option.value === policy.value?.physicsMode)?.description ?? '')
const physicsDescription = computed(
() => physicsOptions.find(option => option.value === policy.value?.physicsMode)?.description ?? ''
)
/**
* 下拉选项同时展示名称与说明,窄屏可自然换行。
* @param option Naive UI 提供的当前选项
* @returns 包含通俗说明的选项内容
*/
const renderPhysicsLabel: SelectRenderLabel = option => h('div', { class: 'grid min-w-0 gap-1 py-1 whitespace-normal' }, [
h('span', { class: 'text-sm leading-6' }, String(option.label ?? '')),
h('span', { class: 'text-xs leading-5 text-muted' }, String(option.description ?? ''))
])
const renderPhysicsLabel: SelectRenderLabel = option =>
h('div', { class: 'grid min-w-0 gap-1 py-1 whitespace-normal' }, [
h('span', { class: 'text-sm leading-6' }, String(option.label ?? '')),
h('span', { class: 'text-xs leading-5 text-muted' }, String(option.description ?? ''))
])
/**
* 选择框只显示简短名称,完整说明放在控件下方,避免撑高或截断控件。
@@ -70,9 +85,21 @@ interface MotionPermissionOption {
}
/** 三类许可的区别直接展示,不依赖悬停或术语理解。 */
const motionPermissions: MotionPermissionOption[] = [
{ field: 'allowExaggeratedMotion', label: '允许夸张动作', description: '把正常动作做得更夸张,例如惊讶时大幅后仰、跑步时摆臂更大;不等于允许悬空或法术。' },
{ field: 'allowNonPhysicalActions', label: '允许非物理动作', description: '允许现实中做不到的动作,例如身体像橡皮一样拉长、没有支撑也能悬空。' },
{ field: 'allowSupernaturalAbilities', label: '允许超自然能力', description: '允许角色使用法术或特殊能力,例如瞬间移动、隔空移动物品、凭空变出火焰。' }
{
field: 'allowExaggeratedMotion',
label: '允许夸张动作',
description: '把正常动作做得更夸张,例如惊讶时大幅后仰、跑步时摆臂更大;不等于允许悬空或法术。'
},
{
field: 'allowNonPhysicalActions',
label: '允许非物理动作',
description: '允许现实中做不到的动作,例如身体像橡皮一样拉长、没有支撑也能悬空。'
},
{
field: 'allowSupernaturalAbilities',
label: '允许超自然能力',
description: '允许角色使用法术或特殊能力,例如瞬间移动、隔空移动物品、凭空变出火焰。'
}
]
/** 仅在用户点击保存时产生校验反馈,不在读取或新增空白例外时提前报错。 */
const issue = ref('')
@@ -113,7 +140,7 @@ async function load() {
notice.value = ''
issue.value = ''
try {
const result = props.initialPolicy ?? await projectsApi.qualityPolicy(id, controller.signal)
const result = props.initialPolicy ?? (await projectsApi.qualityPolicy(id, controller.signal))
if (current !== version) return
validateQualityPolicyReceipt(result, id)
savedGeneralSignature = qualityPolicySignature({ ...result.policy, actionExceptions: [] })
@@ -154,7 +181,8 @@ async function save() {
if (qualityPolicySignature({ ...latest.policy, actionExceptions: [] }) !== savedGeneralSignature)
throw new Error('质量规则已在其他位置更新,请重新打开配置后再保存。')
// 例外由问题修订入口管理,基础配置永远合并服务端最新例外,不提交隐藏的旧副本。
if (latest.policy.actionExceptions) input.actionExceptions = latest.policy.actionExceptions.map(item => ({ ...item }))
if (latest.policy.actionExceptions)
input.actionExceptions = latest.policy.actionExceptions.map(item => ({ ...item }))
else delete input.actionExceptions
loading.value = false
saving.value = true
@@ -164,12 +192,17 @@ async function save() {
savedGeneralSignature = qualityPolicySignature({ ...result.policy, actionExceptions: [] })
policy.value = policyDraft(result.policy)
rulesText.value = policy.value.customRules.join('\n')
notice.value = result.confirmed ? '质量规则已保存,当前版本已经确认。' : '质量规则已保存。下次启动拆解前需要核对并确认。'
notice.value = result.confirmed
? '质量规则已保存,当前版本已经确认。'
: '质量规则已保存。下次启动拆解前需要核对并确认。'
emit('saved')
} catch (cause) {
if (current === version) error.value = errorMessage(cause)
} finally {
if (current === version) { saving.value = false; loading.value = false }
if (current === version) {
saving.value = false
loading.value = false
}
}
}
@@ -210,21 +243,32 @@ defineExpose({ save, canSave, validatedDraft })
:virtual-scroll="false"
:disabled="disabled || saving"
/>
<p id="quality-physics-mode-help" class="text-xs leading-6 text-muted">{{ physicsDescription }}</p>
<p id="quality-physics-mode-help" class="text-xs leading-6 text-muted">
{{ physicsDescription }}
</p>
</div>
</NFormItem>
<!-- 以下是动作许可及其日常示例,桌面按列对齐,手机逐项展示 -->
<div class="grid gap-4 sm:grid-cols-3">
<div v-for="permission in motionPermissions" :key="permission.field" class="min-w-0 space-y-2">
<NCheckbox v-model:checked="policy[permission.field]" :disabled="disabled || saving" :aria-describedby="`quality-${permission.field}-help`">{{ permission.label }}</NCheckbox>
<p :id="`quality-${permission.field}-help`" class="pl-6 text-xs leading-6 text-muted">{{ permission.description }}</p>
<NCheckbox
v-model:checked="policy[permission.field]"
:disabled="disabled || saving"
:aria-describedby="`quality-${permission.field}-help`"
>{{ permission.label }}</NCheckbox
>
<p :id="`quality-${permission.field}-help`" class="pl-6 text-xs leading-6 text-muted">
{{ permission.description }}
</p>
</div>
</div>
</section>
<!-- 以下是逐行声明的自定义规则模块 -->
<NFormItem label="自定义规则" :label-props="{ for: 'quality-custom-rules' }">
<div class="quality-policy-field">
<p id="quality-custom-rules-help" class="text-xs leading-6 text-muted">补充这个故事允许的特殊情况或需要遵守的要求,每行一条,最多 30 条。</p>
<p id="quality-custom-rules-help" class="text-xs leading-6 text-muted">
补充这个故事允许的特殊情况或需要遵守的要求,每行一条,最多 30 条。
</p>
<NInput
v-model:value="rulesText"
type="textarea"