feat: 合并代码后 系统设置 ui样式优化、bug修复、全局统一图标对齐等

This commit is contained in:
zhanjunhao
2026-11-10 17:27:36 +08:00
parent 43e7fbc20e
commit 6ea8a0f7c2
195 changed files with 3546 additions and 1984 deletions
+97
View File
@@ -0,0 +1,97 @@
/*
Copyright (C) 2025 QuantumNous
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
For commercial licensing, please contact support@quantumnous.com
*/
import assert from 'node:assert/strict';
import test from 'node:test';
import * as model from '../../src/pages/WebsiteSettings/model.js';
import * as richTextImages from '../../src/components/common/ui/richTextImages.js';
import { loadFrontendModule } from './frontend-module.js';
function validValues() {
return {
paidCustomers: '200+',
dailyTokens: '10亿',
costReduction: '30%',
teamMembers: '100+',
researchRatio: '70%',
headquarters: '珠海',
serviceNetwork: '全国',
businessPhone: '13800138000',
businessEmail: 'demo@example.com',
wechatQrCode: 'https://cdn.example.com/qr.png',
address: '示例地址',
insights: {
categories: [{ id: 'news', name: '新闻' }],
articles: [
{
id: 'a',
title: '标题',
category: 'news',
date: '2026-11-10',
summary: '摘要',
body: '<p>正文</p>',
related: [],
},
],
},
};
}
test('save validation requires an article even when default categories exist', () => {
assert.deepEqual(model.validateSettings(validValues()), {});
for (const insights of [
model.emptySettings().insights,
{ categories: [], articles: [] },
]) {
assert.deepEqual(model.validateSettings({ ...validValues(), insights }), {
insights: '请完善动态与洞察的配置',
});
}
const invalid = validValues();
invalid.insights.articles[0].body = '';
assert.ok(model.validateSettings(invalid).insights);
});
test('saving incomplete insights cannot send uploads or a configuration write', async () => {
const requests = [];
const api = await loadFrontendModule(
new URL('../../src/pages/WebsiteSettings/settingsApi.js', import.meta.url),
{
'../../helpers/websiteApi': {
requestWebsite: async (...args) => requests.push(args),
},
'./model': model,
'../../components/common/ui/richTextImages': richTextImages,
},
);
await assert.rejects(
api.saveWebsiteSettings(
model.serializeSettings({
...validValues(),
insights: model.emptySettings().insights,
}),
),
/请完整填写并检查官网设置/,
);
assert.deepEqual(requests, []);
await api.saveWebsiteSettings(model.serializeSettings(validValues()));
assert.equal(requests.length, 1);
assert.equal(requests[0][0], 'post');
assert.equal(requests[0][1], '/api/website/page-config');
});