feat: 完善官网配置、预约管理与文章编辑
This commit is contained in:
@@ -17,13 +17,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import React, {
|
||||
useContext,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Card,
|
||||
@@ -136,7 +130,8 @@ const TOKEN_GROUPS = [
|
||||
{
|
||||
key: 'bg',
|
||||
labelKey: '页面背景晕染(大面积底色 / 光晕)',
|
||||
descKey: '影响 user-center、experience 等页面的整页背景渲染与动态光晕,不影响按钮气泡',
|
||||
descKey:
|
||||
'影响 user-center、experience 等页面的整页背景渲染与动态光晕,不影响按钮气泡',
|
||||
},
|
||||
{
|
||||
key: 'accent',
|
||||
@@ -286,7 +281,8 @@ export default function SettingsTheme(props) {
|
||||
() => ({ ...getEffectivePreset(selectedPreset).dark, ...customDark }),
|
||||
[selectedPreset, customDark, presetOverridesState],
|
||||
);
|
||||
const effectivePalette = colorMode === 'light' ? effectiveLight : effectiveDark;
|
||||
const effectivePalette =
|
||||
colorMode === 'light' ? effectiveLight : effectiveDark;
|
||||
|
||||
// 任何编辑都即时前端预览(不写 cache)。
|
||||
// 注意:必须等首次 props 解析完成再开启预览,否则挂载瞬间会用 default state
|
||||
@@ -553,10 +549,9 @@ export default function SettingsTheme(props) {
|
||||
setPresetOverrides(payload);
|
||||
setPresetOverridesState(nextOverrides);
|
||||
setPresetDraft({});
|
||||
applyTheme(
|
||||
JSON.stringify({ preset: editingPresetKey }),
|
||||
{ persist: false },
|
||||
);
|
||||
applyTheme(JSON.stringify({ preset: editingPresetKey }), {
|
||||
persist: false,
|
||||
});
|
||||
statusDispatch({
|
||||
type: 'set',
|
||||
payload: { ...(statusState?.status || {}), theme_presets: payload },
|
||||
@@ -624,9 +619,11 @@ export default function SettingsTheme(props) {
|
||||
const cleanLight = sanitizeImportedTokens(cfg.lightTokens);
|
||||
const cleanDark = sanitizeImportedTokens(cfg.darkTokens);
|
||||
const droppedLight =
|
||||
Object.keys(cfg.lightTokens || {}).length - Object.keys(cleanLight).length;
|
||||
Object.keys(cfg.lightTokens || {}).length -
|
||||
Object.keys(cleanLight).length;
|
||||
const droppedDark =
|
||||
Object.keys(cfg.darkTokens || {}).length - Object.keys(cleanDark).length;
|
||||
Object.keys(cfg.darkTokens || {}).length -
|
||||
Object.keys(cleanDark).length;
|
||||
setSelectedPreset(presetKey);
|
||||
setCustomLight(cleanLight);
|
||||
setCustomDark(cleanDark);
|
||||
@@ -769,9 +766,7 @@ export default function SettingsTheme(props) {
|
||||
colorMode={colorMode}
|
||||
setColorMode={setColorMode}
|
||||
palette={effectivePalette}
|
||||
customOverrides={
|
||||
colorMode === 'light' ? customLight : customDark
|
||||
}
|
||||
customOverrides={colorMode === 'light' ? customLight : customDark}
|
||||
onChange={handleTokenChange}
|
||||
onResetToken={handleTokenReset}
|
||||
onCopyToOther={handleCopyToOther}
|
||||
@@ -863,7 +858,7 @@ function PresetGrid({
|
||||
return (
|
||||
<Col key={key} xs={24} sm={12} md={8}>
|
||||
<Card
|
||||
hoverable
|
||||
shadows='hover'
|
||||
onClick={() => onSelect(key)}
|
||||
style={{
|
||||
cursor: 'pointer',
|
||||
@@ -926,7 +921,10 @@ function PresetGrid({
|
||||
)}
|
||||
</Title>
|
||||
{isSaved && (
|
||||
<Text size='small' style={{ color: 'var(--semi-color-primary)' }}>
|
||||
<Text
|
||||
size='small'
|
||||
style={{ color: 'var(--semi-color-primary)' }}
|
||||
>
|
||||
{t('已应用')}
|
||||
</Text>
|
||||
)}
|
||||
@@ -1015,19 +1013,13 @@ function PresetTemplateEditor({
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', gap: 8, marginTop: 16, alignItems: 'center' }}>
|
||||
<Button
|
||||
type='primary'
|
||||
theme='solid'
|
||||
loading={saving}
|
||||
onClick={onSave}
|
||||
>
|
||||
<div
|
||||
style={{ display: 'flex', gap: 8, marginTop: 16, alignItems: 'center' }}
|
||||
>
|
||||
<Button type='primary' theme='solid' loading={saving} onClick={onSave}>
|
||||
{t('保存预设模板')}
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!isEdited || saving}
|
||||
onClick={onRestore}
|
||||
>
|
||||
<Button disabled={!isEdited || saving} onClick={onRestore}>
|
||||
{t('恢复此预设出厂')}
|
||||
</Button>
|
||||
</div>
|
||||
@@ -1053,7 +1045,14 @@ function CustomEditor({
|
||||
return (
|
||||
<>
|
||||
{/* 基础预设选择(决定未覆盖 token 的兜底值) */}
|
||||
<div style={{ marginBottom: 12, display: 'flex', alignItems: 'center', gap: 8 }}>
|
||||
<div
|
||||
style={{
|
||||
marginBottom: 12,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 8,
|
||||
}}
|
||||
>
|
||||
<Text type='secondary' size='small'>
|
||||
{t('基础预设:')}
|
||||
</Text>
|
||||
@@ -1115,7 +1114,9 @@ function CustomEditor({
|
||||
<Button
|
||||
size='small'
|
||||
onClick={onDeriveToDark}
|
||||
title={t('按 deriveDarkTokens 规则自动调亮,与编辑预设模板的派生逻辑一致')}
|
||||
title={t(
|
||||
'按 deriveDarkTokens 规则自动调亮,与编辑预设模板的派生逻辑一致',
|
||||
)}
|
||||
>
|
||||
{t('派生到深色(自动调亮)')}
|
||||
</Button>
|
||||
@@ -1148,7 +1149,13 @@ function GroupedTokenList({ palette, isCustomOf, onChange, onReset, t }) {
|
||||
}}
|
||||
>
|
||||
<div style={{ marginBottom: 6, padding: '0 4px' }}>
|
||||
<div style={{ fontSize: 12, fontWeight: 600, color: 'var(--semi-color-text-1)' }}>
|
||||
<div
|
||||
style={{
|
||||
fontSize: 12,
|
||||
fontWeight: 600,
|
||||
color: 'var(--semi-color-text-1)',
|
||||
}}
|
||||
>
|
||||
{t(g.labelKey)}
|
||||
</div>
|
||||
<Text type='tertiary' size='small' style={{ fontSize: 11 }}>
|
||||
@@ -1186,7 +1193,12 @@ function TokenRow({ label, desc, value, isCustom, onChange, onReset }) {
|
||||
const alphaPct = valid ? Math.round(c.alpha() * 100) : 100;
|
||||
|
||||
// colord.toHex():alpha=1 → 6 位,alpha<1 → 8 位,天然兼容存储格式
|
||||
const emit = (hex, pct) => onChange(colord(hex).alpha(pct / 100).toHex());
|
||||
const emit = (hex, pct) =>
|
||||
onChange(
|
||||
colord(hex)
|
||||
.alpha(pct / 100)
|
||||
.toHex(),
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
@@ -1259,7 +1271,11 @@ function TokenRow({ label, desc, value, isCustom, onChange, onReset }) {
|
||||
step={1}
|
||||
value={alphaPct}
|
||||
onChange={(e) => emit(rgbHex, Number(e.target.value))}
|
||||
style={{ flex: 1, accentColor: 'var(--brand-primary)', cursor: 'pointer' }}
|
||||
style={{
|
||||
flex: 1,
|
||||
accentColor: 'var(--brand-primary)',
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
aria-label={`${label} alpha`}
|
||||
/>
|
||||
<span
|
||||
|
||||
Reference in New Issue
Block a user