feat: 完善官网配置、预约管理与文章编辑
This commit is contained in:
@@ -16,26 +16,20 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import React, { useContext, useEffect, useState, useRef } from 'react';
|
||||
import { Banner, Button, Card, Checkbox, Form, Spin } from '@douyinfe/semi-ui';
|
||||
import { API, isRoot, showError, showSuccess } from '../../../helpers';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { DELEGATABLE_SETTING_TABS } from '../../../constants/settingTabs';
|
||||
|
||||
const OPTION_KEY = 'AdminDelegatedSettingTabs';
|
||||
|
||||
function parseTabs(raw) {
|
||||
if (!raw) return [];
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
return Array.isArray(parsed) ? parsed : [];
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
import {
|
||||
ADMIN_DELEGATION_OPTIONS,
|
||||
ADMIN_DELEGATION_OPTION_KEY as OPTION_KEY,
|
||||
} from '../../../constants/settingTabs';
|
||||
import { parseAdminDelegation } from '../../../helpers/adminDelegation';
|
||||
import { StatusContext } from '../../../context/Status';
|
||||
|
||||
export default function SettingsAdminDelegation(props) {
|
||||
const { t } = useTranslation();
|
||||
const [statusState, statusDispatch] = useContext(StatusContext);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [selected, setSelected] = useState([]);
|
||||
const [savedRaw, setSavedRaw] = useState('');
|
||||
@@ -44,7 +38,7 @@ export default function SettingsAdminDelegation(props) {
|
||||
useEffect(() => {
|
||||
const raw = props.options?.[OPTION_KEY] ?? '';
|
||||
setSavedRaw(raw);
|
||||
const tabs = parseTabs(raw);
|
||||
const tabs = parseAdminDelegation(raw);
|
||||
setSelected(tabs);
|
||||
refForm.current?.setValues({ [OPTION_KEY]: tabs });
|
||||
}, [props.options]);
|
||||
@@ -56,7 +50,7 @@ export default function SettingsAdminDelegation(props) {
|
||||
|
||||
function onSubmit() {
|
||||
const value = JSON.stringify(selected);
|
||||
if (value === JSON.stringify(parseTabs(savedRaw))) {
|
||||
if (value === JSON.stringify(parseAdminDelegation(savedRaw))) {
|
||||
showSuccess(t('保存成功'));
|
||||
return;
|
||||
}
|
||||
@@ -65,6 +59,11 @@ export default function SettingsAdminDelegation(props) {
|
||||
.then((res) => {
|
||||
const { success, message } = res.data;
|
||||
if (success) {
|
||||
setSavedRaw(value);
|
||||
statusDispatch({
|
||||
type: 'set',
|
||||
payload: { ...statusState?.status, [OPTION_KEY]: value },
|
||||
});
|
||||
showSuccess(t('保存成功'));
|
||||
props.refresh?.();
|
||||
} else {
|
||||
@@ -91,7 +90,7 @@ export default function SettingsAdminDelegation(props) {
|
||||
<Banner
|
||||
type='warning'
|
||||
description={t(
|
||||
'勾选后,普通管理员(非超级管理员)将能够看到并编辑这些系统设置 Tab。请谨慎下放含密钥的页面(如系统设置、支付设置、数据安全)。未勾选的 Tab 仍仅超级管理员可见。',
|
||||
'勾选后,普通管理员(非超级管理员)将能够访问对应的系统设置 Tab 或管理页面,菜单同步按权限显示。请谨慎下放含密钥的页面(如系统设置、支付设置、数据安全)。未勾选的项目仍仅超级管理员可访问。',
|
||||
)}
|
||||
bordered
|
||||
fullMode={false}
|
||||
@@ -102,9 +101,15 @@ export default function SettingsAdminDelegation(props) {
|
||||
field={OPTION_KEY}
|
||||
noLabel
|
||||
direction='horizontal'
|
||||
onChange={(value) => setSelected(value)}
|
||||
onChange={(value) => {
|
||||
const unknown = parseAdminDelegation(savedRaw).filter(
|
||||
(key) =>
|
||||
!ADMIN_DELEGATION_OPTIONS.some((item) => item.key === key),
|
||||
);
|
||||
setSelected([...new Set([...unknown, ...value])]);
|
||||
}}
|
||||
>
|
||||
{DELEGATABLE_SETTING_TABS.map((tab) => (
|
||||
{ADMIN_DELEGATION_OPTIONS.map((tab) => (
|
||||
<Checkbox key={tab.key} value={tab.key}>
|
||||
{t(tab.labelKey)}
|
||||
</Checkbox>
|
||||
|
||||
@@ -404,7 +404,7 @@ export default function SettingsHeaderNavModules(props) {
|
||||
minHeight: '80px',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
hoverable
|
||||
shadows='hover'
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
@@ -558,7 +558,7 @@ export default function SettingsHeaderNavModules(props) {
|
||||
minHeight: '80px',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
hoverable
|
||||
shadows='hover'
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
@@ -636,7 +636,7 @@ export default function SettingsHeaderNavModules(props) {
|
||||
minHeight: '80px',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
hoverable
|
||||
shadows='hover'
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
||||
@@ -168,7 +168,7 @@ export default function SettingsOrgUserNavModules(props) {
|
||||
minHeight: '64px',
|
||||
}}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
hoverable
|
||||
shadows='hover'
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
|
||||
@@ -695,7 +695,7 @@ export default function SettingsSidebarModulesAdmin(props) {
|
||||
<Col key={module.key} xs={24} sm={12} md={8} lg={6} xl={6}>
|
||||
<Card
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
hoverable
|
||||
shadows='hover'
|
||||
style={{
|
||||
opacity: sectionConfig.enabled ? 1 : 0.5,
|
||||
transition: 'opacity 0.2s',
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
showError,
|
||||
showSuccess,
|
||||
showWarning,
|
||||
toBoolean,
|
||||
} from '../../../helpers';
|
||||
|
||||
// InputNumber 清空时 onChange 会收到 ''/null,parseInt 得到 NaN,
|
||||
@@ -76,12 +77,11 @@ export default function SettingsSkillInject(props) {
|
||||
useEffect(() => {
|
||||
const currentInputs = {};
|
||||
for (const key in DEFAULTS) {
|
||||
currentInputs[key] = Object.prototype.hasOwnProperty.call(
|
||||
props.options,
|
||||
key,
|
||||
)
|
||||
const value = Object.prototype.hasOwnProperty.call(props.options, key)
|
||||
? props.options[key]
|
||||
: DEFAULTS[key];
|
||||
currentInputs[key] =
|
||||
typeof DEFAULTS[key] === 'boolean' ? toBoolean(value) : value;
|
||||
}
|
||||
setInputs(currentInputs);
|
||||
setInputsRow(structuredClone(currentInputs));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -22,6 +22,7 @@ import { Layout, TabPane, Tabs } from '@douyinfe/semi-ui';
|
||||
import { useNavigate, useLocation } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { getDelegatedSettingTabs } from '../../helpers/adminDelegation';
|
||||
import {
|
||||
ALWAYS_ADMIN_VISIBLE_TABS,
|
||||
ROOT_ONLY_SETTING_TABS,
|
||||
@@ -264,13 +265,9 @@ const Setting = () => {
|
||||
}
|
||||
|
||||
// 解析 root 配置的「下放给普通管理员」tab 列表
|
||||
let delegatedTabs = [];
|
||||
try {
|
||||
const raw = statusState?.status?.AdminDelegatedSettingTabs;
|
||||
if (raw) delegatedTabs = JSON.parse(raw);
|
||||
} catch (e) {
|
||||
delegatedTabs = [];
|
||||
}
|
||||
const delegatedTabs = getDelegatedSettingTabs(
|
||||
statusState?.status?.AdminDelegatedSettingTabs,
|
||||
);
|
||||
|
||||
// 可见性过滤:root 看全部;普通管理员看「会员管理 + 被下放的 tab」;其余看不到。
|
||||
if (!isRoot()) {
|
||||
|
||||
Reference in New Issue
Block a user