fix: 使用 NScrollbar 统一内容区滚动条
This commit is contained in:
1 parent
db8c176b55
commit
3fe1b3f5c3
17 files changed
+967
-737
No files matched your search
@@ -1,6 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue'
|
||||
import { NEmpty, NTimeline, NTimelineItem } from 'naive-ui'
|
||||
import { NScrollbar, NEmpty, NTimeline, NTimelineItem } from 'naive-ui'
|
||||
import { Clock3 } from '@lucide/vue'
|
||||
import { formatDate, nodeLabel } from '../../lib/format'
|
||||
import { workflowCheckpoints } from './selectors'
|
||||
@@ -13,29 +13,33 @@ const history = computed(() => workflowCheckpoints(props.checkpoints, props.work
|
||||
|
||||
<template>
|
||||
<aside class="history-panel">
|
||||
<h3 class="mb-1 flex items-center gap-2 text-sm font-semibold"><Clock3 :size="15" />执行记录</h3>
|
||||
<p class="mb-6 text-xs leading-5 text-muted">最近 18 个 checkpoint · 自动刷新</p>
|
||||
<NEmpty v-if="!history.length" size="small" description="工作流尚未保存执行记录。" />
|
||||
<NTimeline v-else>
|
||||
<NTimelineItem
|
||||
v-for="item in history"
|
||||
:key="item.checkpointId"
|
||||
:type="item.state.workflowExecution?.status === 'failed' ? 'error' : 'default'"
|
||||
>
|
||||
<p class="text-xs font-medium">{{ nodeLabel(item.metadata?.nodeName) }}</p>
|
||||
<p class="mt-1 text-[11px] text-muted">
|
||||
{{ formatDate(item.createdAt)
|
||||
}}<span v-if="item.metadata?.nodeDurationMs">
|
||||
· {{ (item.metadata.nodeDurationMs / 1000).toFixed(1) }}s</span
|
||||
>
|
||||
</p>
|
||||
<span v-if="item.state.workflowExecution?.status === 'failed'" class="mt-1 block text-xs text-danger"
|
||||
>运行失败</span
|
||||
<NScrollbar class="panel-scroll" content-class="history-content">
|
||||
<h3 class="mb-1 flex items-center gap-2 text-sm font-semibold"><Clock3 :size="15" />执行记录</h3>
|
||||
<p class="mb-6 text-xs leading-5 text-muted">最近 18 个 checkpoint · 自动刷新</p>
|
||||
<NEmpty v-if="!history.length" size="small" description="工作流尚未保存执行记录。" />
|
||||
<NTimeline v-else>
|
||||
<NTimelineItem
|
||||
v-for="item in history"
|
||||
:key="item.checkpointId"
|
||||
:type="item.state.workflowExecution?.status === 'failed' ? 'error' : 'default'"
|
||||
>
|
||||
</NTimelineItem>
|
||||
</NTimeline>
|
||||
<p class="mt-5 border-t border-line pt-4 text-[11px] leading-5 text-muted">
|
||||
记录在节点或批次结束后更新,长时间无新记录不一定意味着任务失败。
|
||||
</p>
|
||||
<p class="text-xs font-medium">{{ nodeLabel(item.metadata?.nodeName) }}</p>
|
||||
<p class="mt-1 text-[11px] text-muted">
|
||||
{{ formatDate(item.createdAt)
|
||||
}}<span v-if="item.metadata?.nodeDurationMs">
|
||||
· {{ (item.metadata.nodeDurationMs / 1000).toFixed(1) }}s</span
|
||||
>
|
||||
</p>
|
||||
<span
|
||||
v-if="item.state.workflowExecution?.status === 'failed'"
|
||||
class="mt-1 block text-xs text-danger"
|
||||
>运行失败</span
|
||||
>
|
||||
</NTimelineItem>
|
||||
</NTimeline>
|
||||
<p class="mt-5 border-t border-line pt-4 text-[11px] leading-5 text-muted">
|
||||
记录在节点或批次结束后更新,长时间无新记录不一定意味着任务失败。
|
||||
</p>
|
||||
</NScrollbar>
|
||||
</aside>
|
||||
</template>
|
||||
@@ -1,4 +1,5 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { NScrollbar } from 'naive-ui'
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { flushPromises, mount, type VueWrapper } from '@vue/test-utils'
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
@@ -142,6 +143,45 @@ afterEach(() => {
|
||||
})
|
||||
|
||||
describe('内容级滚动下的生产反馈', () => {
|
||||
it('生产目录和资产详情由两个独立 NScrollbar 接管,切镜头不会新增生产请求', async () => {
|
||||
const fetcher = vi.fn<typeof fetch>().mockImplementation(async url => {
|
||||
const path = String(url)
|
||||
if (path.includes('/storyboard-directions')) return jsonResponse(directionsResult(fixture.id))
|
||||
if (path.includes('/readiness') || path.endsWith('/videos/status'))
|
||||
return jsonResponse({
|
||||
total: 2,
|
||||
ready: 0,
|
||||
skipped: 0,
|
||||
blocked: 0,
|
||||
completed: 0,
|
||||
queued: 0,
|
||||
pending: 0,
|
||||
running: 0,
|
||||
failed: 0,
|
||||
cancelled: 0,
|
||||
notStarted: 2,
|
||||
items: []
|
||||
})
|
||||
return jsonResponse([])
|
||||
})
|
||||
vi.stubGlobal('fetch', fetcher)
|
||||
wrapper = mount(ProductionPage, {
|
||||
attachTo: document.body,
|
||||
global: { provide: { [projectContextKey as symbol]: context() }, stubs: { RouterLink: true } }
|
||||
})
|
||||
await flushPromises()
|
||||
const directory = wrapper.get('.production-shot-list')
|
||||
const detail = wrapper.get('.production-detail')
|
||||
expect(directory.getComponent(NScrollbar).props('xScrollable')).toBe(true)
|
||||
expect(detail.get('.panel-scroll').classes()).toContain('n-scrollbar')
|
||||
expect(directory.get('.n-scrollbar-container').element).not.toBe(detail.get('.n-scrollbar-container').element)
|
||||
const items = directory.findAll('.production-shot-link')
|
||||
expect(items).toHaveLength(2)
|
||||
await items[1]!.trigger('click')
|
||||
await flushPromises()
|
||||
expect(items[1]!.attributes('aria-current')).toBe('true')
|
||||
expect(fetcher.mock.calls.every(([, init]) => init?.method === 'GET')).toBe(true)
|
||||
})
|
||||
it('默认折叠总览时查询错误仍显示在内容区外层', async () => {
|
||||
vi.stubGlobal('fetch', vi.fn<typeof fetch>().mockRejectedValue(new Error('生产连接中断')))
|
||||
wrapper = mount(ProductionPage, {
|
||||
|
||||
Reference in new issue
Block a user