fix(short-drama-agent-front): 统一全屏布局与问题处理交互
This commit is contained in:
1 parent
db91a4b871
commit
cc27d463e0
25 files changed
+838
-316
No files matched your search
@@ -1,10 +1,12 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onScopeDispose, ref, watch } from 'vue'
|
||||
import { NButton, NCheckbox, NFormItem, NInput, NSelect } from 'naive-ui'
|
||||
import { Trash2 } from '@lucide/vue'
|
||||
import { projectsApi } from '../../projects/api'
|
||||
import { actionResourceOptions, policyDraft, policyIssue } from '../../projects/quality-policy'
|
||||
import type { ProjectQualityPolicy } from '../../projects/types'
|
||||
import { errorMessage } from '../../../lib/http'
|
||||
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
|
||||
|
||||
/** 项目质量策略独立编辑表单。 */
|
||||
const props = defineProps<{
|
||||
@@ -31,10 +33,18 @@ const physicsOptions = [
|
||||
{ value: 'stylized', label: '风格化表现' },
|
||||
{ value: 'fantasy', label: '幻想表现' }
|
||||
]
|
||||
/** 草稿校验错误。 */
|
||||
const issue = computed(() => (policy.value ? policyIssue(policy.value) : ''))
|
||||
/** 只有已读取真实策略且没有活动操作才允许提交。 */
|
||||
const canSave = computed(() => !!policy.value && !issue.value && !props.disabled && !loading.value && !saving.value)
|
||||
/** 仅在用户点击保存时产生校验反馈,不在读取或新增空白例外时提前报错。 */
|
||||
const issue = ref('')
|
||||
/** 已读取策略且没有活动操作时允许点击保存,由保存入口校验完整性。 */
|
||||
const canSave = computed(() => !!policy.value && !props.disabled && !loading.value && !saving.value)
|
||||
/** 修改草稿后清除上一次校验反馈,下一次保存再检查完整策略。 */
|
||||
watch(
|
||||
policy,
|
||||
() => {
|
||||
issue.value = ''
|
||||
},
|
||||
{ deep: true, flush: 'sync' }
|
||||
)
|
||||
/** 规则文本仅做逐行编辑,空行不作为规则提交。 */
|
||||
const rulesText = ref('')
|
||||
/** 保留输入中的换行,仅在策略草稿中去除空白规则。 */
|
||||
@@ -60,6 +70,7 @@ async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
notice.value = ''
|
||||
issue.value = ''
|
||||
try {
|
||||
const result = await projectsApi.qualityPolicy(id, controller.signal)
|
||||
if (current !== version) return
|
||||
@@ -89,9 +100,11 @@ function removeException(index: number) {
|
||||
policy.value?.actionExceptions?.splice(index, 1)
|
||||
}
|
||||
|
||||
/** 保存完整策略,保留项目和请求归属检查。 */
|
||||
/** 点击保存时校验完整策略,通过后再提交并核对项目归属。 */
|
||||
async function save() {
|
||||
if (!canSave.value || !policy.value) return
|
||||
issue.value = policyIssue(policy.value)
|
||||
if (issue.value) return
|
||||
const id = props.projectId
|
||||
const current = version
|
||||
const input = policyDraft(policy.value)
|
||||
@@ -134,12 +147,10 @@ defineExpose({ save, canSave })
|
||||
<template v-if="policy">
|
||||
<!-- 以下是物理表现与明确动作许可模块 -->
|
||||
<section class="space-y-4" aria-label="动作与物理规则">
|
||||
<div>
|
||||
<h3 class="text-sm font-medium">动作与物理规则</h3>
|
||||
<p class="mt-2 text-xs leading-6 text-muted">
|
||||
选择表现方式后,仍需明确勾选允许的动作范围。保存不会重新生成已有资产。
|
||||
</p>
|
||||
</div>
|
||||
<WorkspaceSectionHeading
|
||||
title="动作与物理规则"
|
||||
description="选择表现方式后,仍需明确勾选允许的动作范围。保存不会重新生成已有资产。"
|
||||
/>
|
||||
<NFormItem label="物理表现方式" :label-props="{ id: 'quality-physics-mode-label' }">
|
||||
<NSelect
|
||||
v-model:value="policy.physicsMode"
|
||||
@@ -173,16 +184,20 @@ defineExpose({ save, canSave })
|
||||
</NFormItem>
|
||||
<!-- 以下是主体和具体动作资源的精确例外模块 -->
|
||||
<section class="space-y-4" aria-label="精确动作例外">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-medium">精确动作例外</h3>
|
||||
<NButton
|
||||
size="small"
|
||||
:disabled="disabled || saving || (policy.actionExceptions?.length ?? 0) >= 30"
|
||||
@click="addException"
|
||||
>添加例外</NButton
|
||||
>
|
||||
</div>
|
||||
<p class="text-xs leading-6 text-muted">仅对填写的主体与资源放宽动作资源冲突,需记录明确依据。</p>
|
||||
<!-- 以下是与生成配置统一间距的模块标题、说明和操作模块 -->
|
||||
<WorkspaceSectionHeading
|
||||
title="精确动作例外"
|
||||
description="仅对填写的主体与资源放宽动作资源冲突,需记录明确依据。"
|
||||
>
|
||||
<template #actions>
|
||||
<NButton
|
||||
size="small"
|
||||
:disabled="disabled || saving || (policy.actionExceptions?.length ?? 0) >= 30"
|
||||
@click="addException"
|
||||
>添加例外</NButton
|
||||
>
|
||||
</template>
|
||||
</WorkspaceSectionHeading>
|
||||
<div v-for="(item, index) in policy.actionExceptions" :key="index" class="quality-exception-row">
|
||||
<NFormItem label="主体引用"
|
||||
><NInput
|
||||
@@ -204,7 +219,15 @@ defineExpose({ save, canSave })
|
||||
:aria-label="`例外 ${index + 1} 确认依据`"
|
||||
:disabled="disabled || saving"
|
||||
/></NFormItem>
|
||||
<NButton :disabled="disabled || saving" @click="removeException(index)">移除</NButton>
|
||||
<!-- 以下是与输入框底部对齐的图标移除操作,保留明确的可访问名称 -->
|
||||
<NButton
|
||||
class="icon-button quality-exception-remove"
|
||||
:aria-label="`移除例外 ${index + 1}`"
|
||||
title="移除例外"
|
||||
:disabled="disabled || saving"
|
||||
@click="removeException(index)"
|
||||
><Trash2 :size="16" aria-hidden="true"
|
||||
/></NButton>
|
||||
</div>
|
||||
</section>
|
||||
<p v-if="issue" role="status" class="text-xs leading-6 text-danger">{{ issue }}</p>
|
||||
@@ -222,9 +245,12 @@ defineExpose({ save, canSave })
|
||||
.quality-exception-row {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(120px, 1fr) minmax(100px, 0.7fr) minmax(160px, 1.5fr) auto;
|
||||
align-items: center;
|
||||
align-items: end;
|
||||
gap: 16px;
|
||||
}
|
||||
.quality-exception-remove {
|
||||
justify-self: end;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.quality-exception-row {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
|
||||
Reference in new issue
Block a user