feat(web): 主题皮肤系统与 LLM 设置面板重构
- useThemeSkin 重构主题皮肤应用逻辑,支持企业 AI 风格主题切换 - settingsModelHelper 新增主题与模型表字段映射,useSettings 适配 - LlmSettingsPanel/SettingsView 面板重构,支持多模型行编辑与主题区块 - settings-view.css 适配主题样式,新增 settings-theme-section 测试,更新 settings-llm-section 测试
This commit is contained in:
73
web/tests/settings-theme-section.test.mjs
Normal file
73
web/tests/settings-theme-section.test.mjs
Normal file
@@ -0,0 +1,73 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
|
||||
import * as themeSkinModel from '../src/composables/useThemeSkin.js'
|
||||
|
||||
const settingsModel = readFileSync(new URL('../src/utils/settingsModelHelper.js', import.meta.url), 'utf8')
|
||||
const settingsView = readFileSync(new URL('../src/views/SettingsView.vue', import.meta.url), 'utf8')
|
||||
const settingsStyles = readFileSync(new URL('../src/assets/styles/views/settings-view.css', import.meta.url), 'utf8')
|
||||
const aiModeStyles = readFileSync(
|
||||
new URL('../src/assets/styles/components/personal-workbench-ai-mode.css', import.meta.url),
|
||||
'utf8'
|
||||
)
|
||||
|
||||
function testAppearanceSectionIsThemeSettings() {
|
||||
assert.match(settingsModel, /id:\s*'appearance'[\s\S]*label:\s*'主题设置'/)
|
||||
assert.match(settingsModel, /id:\s*'appearance'[\s\S]*title:\s*'主题风格与界面体验'/)
|
||||
assert.match(settingsModel, /id:\s*'appearance'[\s\S]*actionLabel:\s*'保存主题设置'/)
|
||||
assert.match(settingsView, /<h4>主题风格与界面体验<\/h4>/)
|
||||
assert.doesNotMatch(settingsModel, /label:\s*'界面皮肤'/)
|
||||
assert.doesNotMatch(settingsView, /界面皮肤与企业主色/)
|
||||
}
|
||||
|
||||
function testThemeOptionsCollapseToThreeExperienceModes() {
|
||||
assert.deepEqual(
|
||||
themeSkinModel.THEME_SKIN_OPTIONS.map((theme) => theme.id),
|
||||
['vivid', 'enterprise', 'intelligent']
|
||||
)
|
||||
assert.deepEqual(
|
||||
themeSkinModel.THEME_SKIN_OPTIONS.map((theme) => theme.label),
|
||||
['动感活泼', '企业沉稳', '专业智能']
|
||||
)
|
||||
assert.equal(typeof themeSkinModel.normalizeThemeMode, 'function')
|
||||
assert.equal(themeSkinModel.normalizeThemeMode('sky'), 'vivid')
|
||||
assert.equal(themeSkinModel.normalizeThemeMode('blue'), 'vivid')
|
||||
assert.equal(themeSkinModel.normalizeThemeMode('legacy-green'), 'vivid')
|
||||
assert.equal(themeSkinModel.normalizeThemeMode('navy'), 'enterprise')
|
||||
assert.equal(themeSkinModel.normalizeThemeMode('slate'), 'enterprise')
|
||||
assert.equal(themeSkinModel.normalizeThemeMode('soft-violet'), 'intelligent')
|
||||
assert.equal(themeSkinModel.normalizeThemeMode(''), 'enterprise')
|
||||
assert.equal(themeSkinModel.normalizeThemeMode('unknown-theme'), 'enterprise')
|
||||
}
|
||||
|
||||
function testSettingsThemeCardsAvoidLegacySkinLanguage() {
|
||||
assert.match(settingsView, /theme-option-grid/)
|
||||
assert.match(settingsView, /theme-preview-panel/)
|
||||
assert.match(settingsStyles, /\.theme-option-grid/)
|
||||
assert.match(settingsStyles, /\.theme-style-preview/)
|
||||
assert.doesNotMatch(settingsView, /skin-option-grid/)
|
||||
assert.doesNotMatch(settingsStyles, /\.skin-option-grid/)
|
||||
}
|
||||
|
||||
function testEnterpriseThemeHasAiModeOverrides() {
|
||||
assert.match(aiModeStyles, /\[data-theme-mode="enterprise"\]\s+\.workbench-ai-mode\s*\{/)
|
||||
assert.match(aiModeStyles, /\[data-theme-mode="enterprise"\]\s+\.workbench-ai-mode\.has-conversation\s*\{/)
|
||||
assert.match(aiModeStyles, /\[data-theme-mode="enterprise"\]\s+\.workbench-ai-orb\s*\{/)
|
||||
assert.match(
|
||||
aiModeStyles,
|
||||
/\[data-theme-mode="enterprise"\]\s+\.workbench-ai-orb\s*\{[\s\S]*border:\s*0;[\s\S]*border-radius:\s*50%;[\s\S]*background:\s*transparent;[\s\S]*box-shadow:\s*none;/
|
||||
)
|
||||
assert.match(aiModeStyles, /\[data-theme-mode="enterprise"\]\s+\.workbench-ai-composer[\s\S]*\{/)
|
||||
assert.match(aiModeStyles, /\[data-theme-mode="enterprise"\]\s+\.workbench-ai-message\s*\{/)
|
||||
assert.match(aiModeStyles, /\[data-theme-mode="enterprise"\]\s+\.workbench-ai-thinking-panel\s*\{/)
|
||||
}
|
||||
|
||||
function run() {
|
||||
testAppearanceSectionIsThemeSettings()
|
||||
testThemeOptionsCollapseToThreeExperienceModes()
|
||||
testSettingsThemeCardsAvoidLegacySkinLanguage()
|
||||
testEnterpriseThemeHasAiModeOverrides()
|
||||
console.log('settings theme section tests passed')
|
||||
}
|
||||
|
||||
run()
|
||||
Reference in New Issue
Block a user