import { createApp, defineComponent, h, ref } from 'vue' import { NButton, NConfigProvider, NMessageProvider } from 'naive-ui' import QualityDialog from '../../src/features/production/components/QualityDialog.vue' import SourceReviewDrawer from '../../src/features/production/components/SourceReviewDrawer.vue' import { validationPreview } from '../fixtures/validation-preview' import '../../src/styles/styles.css' import '../../src/styles/admin.css' /** 仅本隔离页的当前计划状态。 */ const status = ref<'ready' | 'blocked' | 'reusable'>('ready') /** 重新打开不同隔离状态。 */ const revision = ref(0) /** 仅允许加载本地静态测试图片。 */ const nativeFetch = window.fetch.bind(window) /** * 隔离所有 API;全部写入返回拒绝,不能连接真实 Provider。 * @param input 请求路径 * @param init 请求选项 * @returns 隔离回执 */ window.fetch = async (input, init) => { if (init?.method && init.method !== 'GET') return new Response(JSON.stringify({ message: '隔离验收禁止写入' }), { status: 403 }) const path = String(input) if (path.includes('/tests/browser/')) return nativeFetch(input, init) const data = path.includes('/validate/preview') ? { ...validationPreview, status: status.value, activeTasks: status.value === 'blocked' ? [{ status: 'running' }] : [], reusableResult: status.value === 'reusable' ? { passed: false, summary: '历史审核未通过,复用不重复计费' } : null } : path.includes('/quality-review') ? { shotId: 's', keyframeId: 'k', qualityDecision: 'failed', effectiveQualityStatus: 'stale', manualReviewAvailable: false, validationTaskId: 't', historicalGazePreview: [], manualReview: null } : path.includes('/source-review/preview') ? { projectId: 'p', shotId: 's', keyframeId: 'k', imageUrl: 'http://localhost:4312/tests/browser/candidate.svg', fingerprint: 'a'.repeat(64), originalPixels: { sha256: 'b'.repeat(64) }, originalInputFingerprint: 'c'.repeat(64), originalProviderInput: {}, sourceChanges: {}, historicalVision: [], references: [ { imageNumber: 1, imageUrl: 'http://localhost:4312/tests/browser/candidate.svg', imageId: 'i' } ], currentReferenceInput: { references: [{ imageNumber: 1, bindings: [{ subjectRef: '@CH1', role: 'identity-anchor' }] }] }, applicabilityBasis: { fingerprint: 'd'.repeat(64), actionIds: ['A1', 'A2'], cameraMovement: 'static', references: [{ imageNumber: 1, subjectRefs: ['@CH1'] }], facts: { rawJson: JSON.stringify({ requiredActions: [ { id: 'A1', description: '静立' }, { id: 'A2', description: '观察' } ] }), direction: { cameraMovement: 'static' }, visualState: { gaze: '朝向画面左侧' } } } } : [] return new Response(JSON.stringify({ data }), { headers: { 'Content-Type': 'application/json' } }) } /** 真实组件的只读隔离验收入口。 */ const Preview = defineComponent({ setup() { /** 质量面板可见性。 */ const open = ref(false) /** 来源面板可见性。 */ const source = ref(false) return () => h('main', { style: 'padding:24px;height:100dvh;overflow:auto' }, [ h('h1', { style: 'margin-bottom:20px' }, 'B04 首帧审核隔离验收(全部写请求禁止)'), h('div', { style: 'display:flex;flex-wrap:wrap;gap:12px' }, [ ...(['ready', 'blocked', 'reusable'] as const).map(value => h( NButton, { onClick: () => { status.value = value revision.value++ open.value = true } }, () => value ) ), h(NButton, { onClick: () => (source.value = true) }, () => '来源证据范围') ]), h(QualityDialog, { key: revision.value, open: open.value, 'onUpdate:open': (v: boolean) => (open.value = v), projectId: 'p', target: { kind: 'keyframe', shotId: 's', assetId: 'k', title: '隔离候选' }, disabled: true }), h(SourceReviewDrawer, { open: source.value, 'onUpdate:open': (v: boolean) => (source.value = v), projectId: 'p', shotId: 's', keyframeId: 'k' }) ]) } }) createApp({ render: () => h(NConfigProvider, null, { default: () => h(NMessageProvider, null, { default: () => h(Preview) }) }) }).mount('#app')