Phase 007: migrate every remaining view from naive-ui to Arco Design Vue

The project now has exactly one UI library. Every naive-ui component in
packages/client/src is replaced by its Arco equivalent across 24 views and
roughly 80 components, and naive-ui is dropped from package.json along with
its transitive vueuc / @css-render / vdirs / seemly dependencies.

The migration is rendering-layer only. No store logic, no API contract, and
no /chat-run payload was touched.

Three classes of leftover were invisible to `grep naive-ui` and are now
covered by tests/client/no-naive-ui.test.ts, which asserts all three:
  - dead .n-* class names in style blocks
  - dead --n-* custom properties
  - naive-ui in package.json

Notable behavioural traps handled along the way, recorded in
docs/arco-migration-rules.md:
  - a-input-password defaults to masked; passing default-visibility="false"
    would have exposed API keys in clear text
  - a-upload fires a real XHR unless auto-upload is false
  - nested Trigger components fight over the first element child, so the
    group-chat settings dropdown was flattened
  - Arco renders tooltip default-slot text inline, which was silently
    collapsing the chat and group-chat toolbars
This commit is contained in:
2026-10-18 22:57:25 +08:00
parent c3eeea4187
commit 836d0228d2
115 changed files with 4067 additions and 3891 deletions
+7 -19
View File
@@ -2,6 +2,7 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { defineComponent } from 'vue'
import { flushPromises, mount } from '@vue/test-utils'
import ArcoVue from '@arco-design/web-vue'
const mockUsageStore = vi.hoisted(() => ({
isLoading: false,
@@ -29,22 +30,6 @@ vi.mock('vue-i18n', () => ({
}),
}))
vi.mock('naive-ui', () => ({
NButton: defineComponent({
name: 'NButton',
props: {
loading: Boolean,
type: String,
secondary: Boolean,
quaternary: Boolean,
size: String,
ariaPressed: [Boolean, String],
},
emits: ['click'],
template: '<button class="n-button-stub" :data-type="type" :aria-pressed="ariaPressed" @click="$emit(\'click\')"><slot /></button>',
}),
}))
vi.mock('@/components/hermes/usage/StatCards.vue', () => ({
default: defineComponent({ name: 'StatCards', template: '<section class="stat-cards-stub" />' }),
}))
@@ -74,14 +59,14 @@ describe('UsageView period selector', () => {
})
it('loads the default 30-day period on mount', async () => {
mount(UsageView)
mount(UsageView, { global: { plugins: [ArcoVue] } })
await flushPromises()
expect(mockUsageStore.loadSessions).toHaveBeenCalledWith(30)
})
it('lets users switch usage statistics between common dashboard periods', async () => {
const wrapper = mount(UsageView)
const wrapper = mount(UsageView, { global: { plugins: [ArcoVue] } })
const periodButtons = wrapper.findAll('.period-option')
expect(periodButtons.map(button => button.text())).toEqual(['7d', '30d', '90d', '365d'])
@@ -89,8 +74,11 @@ describe('UsageView period selector', () => {
await periodButtons[0].trigger('click')
expect(mockUsageStore.loadSessions).toHaveBeenLastCalledWith(7)
expect(periodButtons[0].attributes('data-type')).toBe('primary')
// Arco expresses the button variant through classes, not a data-type attribute.
expect(periodButtons[0].classes()).toContain('arco-btn-secondary')
expect(periodButtons[1].classes()).toContain('arco-btn-text')
expect(periodButtons[0].attributes('aria-pressed')).toBe('true')
expect(periodButtons[1].attributes('aria-pressed')).toBe('false')
await wrapper.find('.refresh-button').trigger('click')
expect(mockUsageStore.loadSessions).toHaveBeenLastCalledWith(7)