style: 恢复标签页分隔线并统一工具栏与图标按钮

This commit is contained in:
GouJ
2026-09-02 09:37:45 +08:00
parent 370e7bb4a6
commit 2ddd9b8009
11 changed files with 203 additions and 33 deletions
+6 -3
View File
@@ -122,7 +122,7 @@ const menuOptions = computed<MenuOption[]>(() => [
quaternary
block
class="admin-settings-button"
:class="{ 'is-collapsed': collapsed }"
:class="{ 'is-collapsed': collapsed, 'icon-button': collapsed }"
aria-label="后端连接"
@click="settingsOpen = true"
>
@@ -139,11 +139,14 @@ const menuOptions = computed<MenuOption[]>(() => [
<div class="flex min-w-0 items-center gap-3">
<NButton
quaternary
circle
class="icon-button"
:aria-label="collapsed ? '展开侧栏' : '折叠侧栏'"
:title="collapsed ? '展开侧栏' : '折叠侧栏'"
@click="collapsed = !collapsed"
>
<PanelLeftOpen v-if="collapsed" :size="18" /><PanelLeftClose v-else :size="18" />
<template #icon
><PanelLeftOpen v-if="collapsed" :size="18" /><PanelLeftClose v-else :size="18"
/></template>
</NButton>
<span class="truncate text-sm">{{ route.meta.title || '工作空间' }}</span>
</div>
+69 -1
View File
@@ -100,6 +100,10 @@ body {
.n-button.admin-settings-button.is-collapsed {
justify-content: center;
padding-inline: 0;
width: 44px;
min-width: 44px;
height: 44px;
margin-inline: auto;
}
.admin-settings-button.is-collapsed .n-button__icon {
margin: 0;
@@ -144,10 +148,20 @@ body {
padding: 0 20px;
gap: 12px;
}
/* 图标按钮保留原有方形点击热区;仅取消 circle 属性产生的圆形外观。 */
/* 按钮保持直角,单图标按钮以 Naive 当前尺寸为边长,加载时也不改变宽度。 */
.n-button {
border-radius: 0;
}
.n-button.icon-button {
width: var(--n-height);
min-width: var(--n-height);
height: var(--n-height);
padding: 0;
flex: 0 0 auto;
}
.n-button.icon-button .n-button__icon {
margin: 0;
}
.n-button:focus-visible {
outline: 2px solid var(--app-accent-text);
outline-offset: 2px;
@@ -1037,6 +1051,60 @@ body {
.project-search {
width: 240px;
}
/* 项目筛选与搜索框同高,保留更宽的点击区;窄屏可自然换行。 */
.project-status-filters.n-radio-group {
display: flex;
flex-wrap: wrap;
height: auto;
min-height: var(--n-height);
gap: 4px 1px;
}
.project-status-filters .n-radio-group__splitor {
display: none;
}
.project-status-filters .n-radio-button {
min-width: 76px;
padding-inline: 18px;
text-align: center;
}
/* 状态说明与操作各自成组,避免小标签夹在不同尺寸的按钮之间。 */
.visual-style-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 16px 24px;
margin-block: 20px;
padding: 14px 16px;
background: var(--app-subtle);
}
.visual-style-status {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
}
.visual-style-status > svg {
flex-shrink: 0;
color: var(--app-muted);
}
.visual-style-status strong {
font-size: 14px;
font-weight: 500;
}
.visual-style-status p {
margin: 4px 0 0;
color: var(--app-muted);
font-size: 12px;
line-height: 1.6;
}
.visual-style-actions {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 10px;
margin-left: auto;
}
.project-name-cell {
display: block;
min-width: 0;
+2 -3
View File
@@ -27,13 +27,12 @@ function selectTheme(key: string | number) {
<template #trigger>
<NButton
quaternary
circle
class="theme-toggle"
class="theme-toggle icon-button"
:aria-label="`主题模式:${current.label}`"
aria-haspopup="menu"
:aria-expanded="open"
>
<component :is="current.icon" :size="18" aria-hidden="true" />
<template #icon><component :is="current.icon" :size="18" aria-hidden="true" /></template>
</NButton>
</template>
{{ current.label }} · 切换主题
+8 -3
View File
@@ -35,9 +35,14 @@ const host = inject(workspaceHostKey, undefined)
<template #header
><div class="workspace-tools-heading">
<span>{{ title }}</span
><NButton quaternary circle aria-label="关闭操作面板" @click="open = false"
><X :size="18"
/></NButton></div
><NButton
quaternary
class="icon-button"
aria-label="关闭操作面板"
title="关闭操作面板"
@click="open = false"
><template #icon><X :size="18" /></template
></NButton></div
></template>
<slot />
<template #footer><span class="text-xs text-muted">关闭面板不会取消已提交的后台任务</span></template>
+42 -1
View File
@@ -1,7 +1,19 @@
import { h } from 'vue'
import { mount, type VueWrapper } from '@vue/test-utils'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { NAlert, NButton, NCard, NCheckbox, NConfigProvider, NInput, NSelect, NTable, NTag } from 'naive-ui'
import {
NAlert,
NButton,
NCard,
NCheckbox,
NConfigProvider,
NInput,
NSelect,
NTable,
NTag,
NTabPane,
NTabs
} from 'naive-ui'
import { readFileSync, readdirSync } from 'node:fs'
import { useTheme } from '../../composables/useTheme'
@@ -74,6 +86,10 @@ describe('全站平面主题', () => {
h(NAlert, { type: 'error' }, () => '生成失败'),
h(NCard, {}, () => '内容'),
h(NTag, {}, () => '待设计'),
h(NTabs, { type: 'line', value: 'one' }, () => [
h(NTabPane, { name: 'one', tab: '人物' }, () => '人物内容'),
h(NTabPane, { name: 'two', tab: '场景' }, () => '场景内容')
]),
h(NTable, { striped: true }, () => h('tbody', [h('tr', [h('td', '记录')])]))
])
}
@@ -103,6 +119,31 @@ describe('全站平面主题', () => {
expect(theme.common?.borderColor).not.toBe('transparent')
expect(theme.Checkbox).not.toHaveProperty('border')
expect(theme.Tabs?.barColor).toBe('#07c160')
expect(value('.n-tabs', '--n-tab-border-color')).toBe(dark ? '#333333' : '#e5e5e5')
})
it('单图标按钮以当前控件高度为边长,尺寸与内容按钮互不影响', () => {
// happy-dom 不计算几何尺寸,此项约束共用样式和调用方,实际布局仍需浏览器验收。
const css = readFileSync('src/admin.css', 'utf8')
expect(css).toMatch(
/\.n-button\.icon-button\s*\{[^}]*width:\s*var\(--n-height\);[^}]*min-width:\s*var\(--n-height\);[^}]*height:\s*var\(--n-height\);[^}]*padding:\s*0/
)
expect(css).toMatch(
/\.project-status-filters \.n-radio-button\s*\{[^}]*min-width:\s*76px;[^}]*padding-inline:\s*18px/
)
expect(css).toMatch(/\.project-status-filters\.n-radio-group\s*\{[^}]*flex-wrap:\s*wrap;[^}]*height:\s*auto;/)
for (const file of [
'src/App.vue',
'src/components/ui/ThemeToggle.vue',
'src/components/ui/WorkspaceTools.vue',
'src/features/projects/ProjectsPage.vue',
'src/features/subject-identity/SubjectIdentityPage.vue'
]) {
const source = readFileSync(file, 'utf8')
expect(source).toContain('icon-button')
expect(source).not.toMatch(/<NButton\b[^>]*\bcircle\b/)
}
expect(readFileSync('src/components/ui/DirectoryItem.vue', 'utf8')).not.toContain('icon-button')
})
it('业务面板、列表分组和标签以背景区分,保留键盘焦点与选中指示', () => {
+2 -1
View File
@@ -215,7 +215,8 @@ export function useTheme() {
tabTextColorActiveLine: accentText,
tabTextColorHoverLine: accentText,
barColor: primary,
tabBorderColor: 'transparent'
// Tabs 保留横向分隔线,明确导航与内容边界;选中下划线仍使用主绿色。
tabBorderColor: dark ? '#333333' : '#e5e5e5'
},
Tag: {
textColorPrimary: accentText,
+9 -4
View File
@@ -75,7 +75,7 @@ function clearFilters() {
</div>
</template>
<div class="project-index-toolbar">
<NRadioGroup v-model:value="filter" size="small" aria-label="项目状态筛选"
<NRadioGroup v-model:value="filter" size="medium" class="project-status-filters" aria-label="项目状态筛选"
><NRadioButton v-for="item in filters" :key="item.value" :value="item.value">{{
item.label
}}</NRadioButton></NRadioGroup
@@ -89,9 +89,14 @@ function clearFilters() {
:input-props="{ 'aria-label': '搜索项目' }"
><template #prefix><Search :size="15" /></template
></NInput>
<NButton :loading="query.loading.value" aria-label="刷新项目" @click="query.refresh"
><RefreshCw :size="16"
/></NButton>
<NButton
class="icon-button"
:loading="query.loading.value"
aria-label="刷新项目"
title="刷新项目"
@click="query.refresh"
><template #icon><RefreshCw :size="16" /></template
></NButton>
</div>
</div>
<NAlert v-if="query.error.value" type="error" :show-icon="false"
@@ -423,12 +423,12 @@ watch(
:disabled="catalog.loading.value || castingQuery.loading.value"
@click="refreshDirectory"
quaternary
circle
class="icon-button"
size="small"
aria-label="刷新主体目录"
title="刷新主体目录"
><RefreshCw :size="14"
/></NButton>
><template #icon><RefreshCw :size="14" /></template
></NButton>
</div>
<div class="directory-filters">
<NInput
+32 -13
View File
@@ -1,6 +1,7 @@
<script setup lang="ts">
import WorkspacePage from '../../components/ui/WorkspacePage.vue'
import { NAlert, NButton, NTag } from 'naive-ui'
import { NAlert, NButton } from 'naive-ui'
import { LoaderCircle, LockKeyhole, LockKeyholeOpen, Palette, RefreshCw, TriangleAlert } from '@lucide/vue'
import { computed, ref } from 'vue'
import { usePolling } from '../../composables/usePolling'
import { runOperation } from '../workflows/operations'
@@ -24,6 +25,16 @@ const editorRevision = ref(0)
const imageRevision = ref(0)
const dirty = ref(false)
/** 状态是只读说明,与操作按钮分组;读取失败不能被误报成尚未创建。 */
const statusInfo = computed(() => {
if (query.error.value) return { label: '读取失败', hint: '请刷新重试,现有内容不会被覆盖', icon: TriangleAlert }
if (!query.data.value) return { label: '正在读取', hint: '正在获取项目视觉风格', icon: LoaderCircle }
if (!style.value) return { label: '尚未创建', hint: '可使用 AI 生成,或在下方手动填写', icon: Palette }
return style.value.isLocked
? { label: '已锁定', hint: 'AI 不会覆盖,仍可在下方手动编辑', icon: LockKeyhole }
: { label: '未锁定', hint: '定稿后可在下方锁定,避免 AI 覆盖', icon: LockKeyholeOpen }
})
/** 防止错误项目的数据进入编辑器;空风格是正常的首次使用状态。 */
function assertProject(value: VisualStyle | null, id: string) {
if (value && (value.projectId !== id || value.images.some(image => image.visualStyleId !== value.id)))
@@ -101,18 +112,26 @@ function removeImage(image: VisualStyleImage) {
>
</div></template
>
<div class="my-5 flex flex-wrap items-center gap-3">
<NTag size="small" :bordered="false">{{
style ? (style.isLocked ? '已锁定' : '未锁定') : '尚未创建'
}}</NTag>
<ConfirmAction
:label="style ? 'AI 重新生成风格' : 'AI 生成风格'"
:disabled="disabled || !!style?.isLocked || dirty"
acknowledgement
description="调用文本模型生成整体及分类风格。重新生成会覆盖已保存的文本与硬约束;旧身份、旧图片和已有提示词不会自动更新。"
@confirm="generate"
/>
<NButton :disabled="query.loading.value" @click="query.refresh" text size="small">刷新风格</NButton>
<div class="visual-style-toolbar">
<div class="visual-style-status" role="status">
<component :is="statusInfo.icon" :size="18" aria-hidden="true" />
<div>
<strong>{{ statusInfo.label }}</strong>
<p>{{ statusInfo.hint }}</p>
</div>
</div>
<div class="visual-style-actions">
<ConfirmAction
:label="style ? 'AI 重新生成风格' : 'AI 生成风格'"
:disabled="disabled || !!style?.isLocked || dirty"
acknowledgement
description="调用文本模型生成整体及分类风格。重新生成会覆盖已保存的文本与硬约束;旧身份、旧图片和已有提示词不会自动更新。"
@confirm="generate"
/>
<NButton :loading="query.loading.value" @click="query.refresh"
><template #icon><RefreshCw :size="16" /></template>刷新风格</NButton
>
</div>
</div>
<NAlert v-if="query.error.value" role="alert" type="error" :show-icon="false" class="mb-4"
>{{ query.error.value }} 请确认后端 dev 已更新并重启查询失败不等同于尚未创建
+28 -1
View File
@@ -1,5 +1,5 @@
import { computed, nextTick, ref } from 'vue'
import { NImage, NScrollbar } from 'naive-ui'
import { NImage, NRadioGroup, 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'
@@ -223,6 +223,28 @@ describe('内容级滚动下的生产反馈', () => {
})
describe('视觉风格与主体身份工作区', () => {
it.each([
{ locked: null, label: '尚未创建', action: 'AI 生成风格', disabled: false },
{ locked: false, label: '未锁定', action: 'AI 重新生成风格', disabled: false },
{ locked: true, label: '已锁定', action: 'AI 重新生成风格', disabled: true }
])('视觉风格 $label 使用独立状态说明与等高操作按钮,保留锁定限制', async ({ locked, label, action, disabled }) => {
const fetcher = vi
.fn<typeof fetch>()
.mockImplementation(async () => jsonResponse(locked === null ? null : styleFixture({ isLocked: locked })))
vi.stubGlobal('fetch', fetcher)
await mountAssets('style')
const status = wrapper!.get('.visual-style-status')
expect(status.attributes('role')).toBe('status')
expect(status.get('strong').text()).toBe(label)
expect(status.find('button').exists()).toBe(false)
expect(wrapper!.find('.visual-style-toolbar .n-tag').exists()).toBe(false)
expect(wrapper!.get('.visual-style-actions').findAll('button')).toHaveLength(2)
expect(button(action).disabled).toBe(disabled)
expect(button(action).style.getPropertyValue('--n-height')).toBe('34px')
expect(button('刷新风格').style.getPropertyValue('--n-height')).toBe('34px')
expect(fetcher.mock.calls.every(([, options]) => !options?.method || options.method === 'GET')).toBe(true)
})
it('主体目录显示已确认母版和默认占位,点缩略图只切换主体,不重复读取所有角色图库', async () => {
const first = formFixture()
const forms = [
@@ -1326,6 +1348,11 @@ describe('工作台页面交互', () => {
await router.push('/')
wrapper = mount(ProjectsPage, { attachTo: document.body, global: { plugins: [router] } })
await flushPromises()
expect(wrapper.getComponent(NRadioGroup).props('size')).toBe('medium')
const refresh = wrapper.get('[aria-label="刷新项目"]')
expect(refresh.classes()).toContain('icon-button')
expect(refresh.find('.n-button__icon svg').exists()).toBe(true)
expect(refresh.text()).toBe('')
expect(wrapper.text()).toContain('雨夜来信')
await wrapper.get('input[aria-label="搜索项目"]').setValue('不存在的关键词')
expect(wrapper.text()).toContain('没有匹配的剧本')