feat: 完善官网配置、预约管理与文章编辑

This commit is contained in:
zhanjunhao
2026-10-31 19:02:58 +08:00
parent 7b80c3bbb3
commit 1bf13bc226
54 changed files with 4898 additions and 203 deletions
+2 -5
View File
@@ -77,7 +77,6 @@ const printConsoleWelcome = (status) => {
};
const PageLayout = () => {
console.log('[PageLayout] Component rendering...');
const [userState, userDispatch] = useContext(UserContext);
const [statusState, statusDispatch] = useContext(StatusContext);
const isMobile = useIsMobile();
@@ -96,7 +95,8 @@ const PageLayout = () => {
const shouldInnerPadding =
location.pathname.includes('/console') &&
!location.pathname.startsWith('/console/chat') &&
location.pathname !== '/console/playground';
location.pathname !== '/console/playground' &&
location.pathname !== '/console/website-setting';
const isConsoleRoute = location.pathname.startsWith('/console');
const showSider = isConsoleRoute && (!isMobile || drawerOpen);
@@ -226,10 +226,8 @@ const PageLayout = () => {
};
const loadStatus = async () => {
console.log('[PageLayout] Loading status from API...');
try {
const res = await API.get('/api/status');
console.log('[PageLayout] API response received:', res.data);
const { success, data } = res.data;
if (success) {
statusDispatch({ type: 'set', payload: data });
@@ -243,7 +241,6 @@ const PageLayout = () => {
if (data.theme_config !== undefined) {
applyTheme(data.theme_config);
}
console.log('[PageLayout] Status loaded successfully');
} else {
console.error('[PageLayout] API returned success=false');
showError('Unable to connect to server');
+47 -13
View File
@@ -27,6 +27,11 @@ import { useSidebar } from '../../hooks/common/useSidebar';
import { useMinimumLoadingTime } from '../../hooks/common/useMinimumLoadingTime';
import { isAdmin, isRoot, showError } from '../../helpers';
import { StatusContext } from '../../context/Status';
import { UserContext } from '../../context/User';
import {
canAccessDelegatedAdminPage,
getDelegatedSettingTabs,
} from '../../helpers/adminDelegation';
import SkeletonWrapper from './components/SkeletonWrapper';
import { CLOUD_BRAIN_UI_ENABLED } from '../../config/cloudBrainUi';
@@ -42,6 +47,8 @@ const routerMap = {
log: '/console/log',
midjourney: '/console/midjourney',
setting: '/console/setting',
'website-setting': '/console/website-setting',
'demo-reservations': '/console/demo-reservations',
about: '/about',
detail: '/console',
pricing: '/market',
@@ -75,16 +82,13 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
} = useSidebar();
const [statusState] = useContext(StatusContext);
const [userState] = useContext(UserContext);
const delegatedPermissions = statusState?.status?.AdminDelegatedSettingTabs;
// 系统设置 tab 权限下放:普通管理员在被下放了至少一个 tab 时,才显示「系统设置」入口
const delegatedSettingTabs = useMemo(() => {
try {
const raw = statusState?.status?.AdminDelegatedSettingTabs;
const parsed = raw ? JSON.parse(raw) : [];
return Array.isArray(parsed) ? parsed : [];
} catch (e) {
return [];
}
}, [statusState?.status?.AdminDelegatedSettingTabs]);
const delegatedSettingTabs = useMemo(
() => getDelegatedSettingTabs(delegatedPermissions),
[delegatedPermissions],
);
const canAccessSetting =
isRoot() || (isAdmin() && delegatedSettingTabs.length > 0);
@@ -284,10 +288,31 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
to: '/setting',
className: canAccessSetting ? '' : 'tableHiddle',
},
{
text: t('官网设置'),
itemKey: 'website-setting',
className: isAdmin() ? '' : 'tableHiddle',
},
{
text: t('预约演示'),
itemKey: 'demo-reservations',
className: isAdmin() ? '' : 'tableHiddle',
},
];
// 根据配置过滤项目
const filteredItems = items.filter((item) => {
if (
(item.itemKey === 'website-setting' ||
item.itemKey === 'demo-reservations') &&
!canAccessDelegatedAdminPage(
userState?.user?.role,
delegatedPermissions,
item.itemKey,
)
) {
return false;
}
if (
!CLOUD_BRAIN_UI_ENABLED &&
(item.itemKey === 'skill-platform' ||
@@ -315,7 +340,16 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
});
return filteredItems;
}, [isAdmin(), isRoot(), t, isModuleVisible, canAccessSetting]);
}, [
isAdmin(),
isRoot(),
t,
isModuleVisible,
canAccessSetting,
delegatedSettingTabs,
delegatedPermissions,
userState?.user?.role,
]);
const chatMenuItems = useMemo(() => {
const items = [
@@ -597,8 +631,8 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
</>
)}
{/* 管理员区域 - 只在管理员时显示且配置允许时显示 */}
{isAdmin() && hasSectionVisibleModules('admin') && (
{/* 管理员区域:按角色、权限下放及菜单配置过滤。 */}
{isAdmin() && (
<>
<Divider className='sidebar-divider' />
<div>
@@ -637,7 +671,7 @@ const SiderBar = ({ onNavigate = () => {}, forceExpanded = false }) => {
/>
}
onClick={toggleCollapsed}
icononly={collapsed}
aria-label={collapsed ? t('展开侧边栏') : t('收起侧边栏')}
style={
collapsed
? { width: 36, height: 24, padding: 0 }
@@ -52,7 +52,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Title
active
style={{ width: isMobile ? 40 : width, height }}
/>
}
@@ -71,7 +70,7 @@ const SkeletonWrapper = ({
loading={true}
active
placeholder={
<Skeleton.Avatar active size='extra-small' className='shadow-sm' />
<Skeleton.Avatar size='extra-small' className='shadow-sm' />
}
/>
<div className='ml-1.5 mr-1'>
@@ -80,7 +79,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Title
active
style={{ width: isMobile ? 15 : width, height: 12 }}
/>
}
@@ -98,7 +96,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Image
active
className={`absolute inset-0 !rounded-full ${className}`}
style={{ width: '100%', height: '100%' }}
/>
@@ -113,7 +110,7 @@ const SkeletonWrapper = ({
<Skeleton
loading={true}
active
placeholder={<Skeleton.Title active style={{ width, height: 24 }} />}
placeholder={<Skeleton.Title style={{ width, height: 24 }} />}
/>
);
};
@@ -125,7 +122,7 @@ const SkeletonWrapper = ({
<Skeleton
loading={true}
active
placeholder={<Skeleton.Title active style={{ width, height }} />}
placeholder={<Skeleton.Title style={{ width, height }} />}
/>
</div>
);
@@ -139,10 +136,7 @@ const SkeletonWrapper = ({
loading={true}
active
placeholder={
<Skeleton.Title
active
style={{ width, height, borderRadius: 9999 }}
/>
<Skeleton.Title style={{ width, height, borderRadius: 9999 }} />
}
/>
</div>
@@ -164,7 +158,7 @@ const SkeletonWrapper = ({
loading={true}
active
placeholder={
<Skeleton.Avatar active size='extra-small' shape='square' />
<Skeleton.Avatar size='extra-small' shape='square' />
}
/>
</div>
@@ -174,7 +168,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Title
active
style={{ width: width || 80, height: height || 14 }}
/>
}
@@ -192,7 +185,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Title
active
style={{ width: width || 60, height: height || 12 }}
/>
}
@@ -217,7 +209,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Avatar
active
shape='square'
style={{ width: ICON_SIZE, height: ICON_SIZE }}
/>
@@ -230,10 +221,7 @@ const SkeletonWrapper = ({
loading={true}
active
placeholder={
<Skeleton.Title
active
style={{ width: labelWidth, height: TEXT_HEIGHT }}
/>
<Skeleton.Title style={{ width: labelWidth, height: TEXT_HEIGHT }} />
}
/>
);
@@ -269,7 +257,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Avatar
active
shape='square'
style={{ width: ICON_SIZE, height: ICON_SIZE }}
/>
@@ -284,22 +271,22 @@ const SkeletonWrapper = ({
{Array(2)
.fill(null)
.map((_, i) => (
<CollapsedRow keyPrefix='c-chat' index={i} />
<CollapsedRow key={i} keyPrefix='c-chat' index={i} />
))}
{Array(5)
.fill(null)
.map((_, i) => (
<CollapsedRow keyPrefix='c-console' index={i} />
<CollapsedRow key={i} keyPrefix='c-console' index={i} />
))}
{Array(2)
.fill(null)
.map((_, i) => (
<CollapsedRow keyPrefix='c-personal' index={i} />
<CollapsedRow key={i} keyPrefix='c-personal' index={i} />
))}
{Array(5)
.fill(null)
.map((_, i) => (
<CollapsedRow keyPrefix='c-admin' index={i} />
<CollapsedRow key={i} keyPrefix='c-admin' index={i} />
))}
</div>
);
@@ -329,7 +316,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Title
active
style={{ width: sec.titleWidth, height: TITLE_HEIGHT }}
/>
}
@@ -350,7 +336,6 @@ const SkeletonWrapper = ({
active
placeholder={
<Skeleton.Title
active
style={{ width: sec.titleWidth, height: TITLE_HEIGHT }}
/>
}
@@ -82,19 +82,21 @@ const LanguageSelector = ({ currentLang, onLanguageChange, t }) => {
</Dropdown.Menu>
}
>
<Button
icon={<Globe size={20} />}
aria-label={t('common.changeLanguage')}
theme='borderless'
type='tertiary'
className='!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95'
style={{
color:
actualTheme === 'dark'
? 'rgba(243,244,246,0.9)'
: 'rgba(75,85,99,1)',
}}
/>
<span className='inline-flex'>
<Button
icon={<Globe size={20} />}
aria-label={t('common.changeLanguage')}
theme='borderless'
type='tertiary'
className='!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95'
style={{
color:
actualTheme === 'dark'
? 'rgba(243,244,246,0.9)'
: 'rgba(75,85,99,1)',
}}
/>
</span>
</Dropdown>
);
};
@@ -133,19 +133,21 @@ const MobileNavMenu = ({ mainNavLinks, userState, t }) => {
</Dropdown.Menu>
}
>
<Button
theme='borderless'
type='tertiary'
aria-label={t('主导航')}
aria-haspopup='menu'
aria-expanded={visible}
icon={<Compass size={16} />}
className='!ml-1 !px-2 !h-8 max-w-[9rem] !rounded-xl !text-current hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-all !duration-200 active:!scale-95 [&_.semi-button-content]:min-w-0'
>
<span className='ml-1 text-[13px] font-semibold truncate'>
{activeItem ? activeItem.text : t('导航')}
</span>
</Button>
<span className='inline-flex'>
<Button
theme='borderless'
type='tertiary'
aria-label={t('主导航')}
aria-haspopup='menu'
aria-expanded={visible}
icon={<Compass size={16} />}
className='!ml-1 !px-2 !h-8 max-w-[9rem] !rounded-xl !text-current hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !transition-all !duration-200 active:!scale-95 [&_.semi-button-content]:min-w-0'
>
<span className='ml-1 text-[13px] font-semibold truncate'>
{activeItem ? activeItem.text : t('导航')}
</span>
</Button>
</span>
</Dropdown>
);
};
+16 -13
View File
@@ -251,19 +251,22 @@ const ThemeToggle = ({ theme, onThemeToggle, t }) => {
</Dropdown.Menu>
}
>
<Button
icon={currentButtonIcon}
aria-label={t('切换主题')}
theme='borderless'
type='tertiary'
className='!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95'
style={{
color:
actualTheme === 'dark'
? 'rgba(243,244,246,0.9)'
: 'rgba(75,85,99,1)',
}}
/>
{/* Semi can resolve a DOM trigger directly without findDOMNode. */}
<span className='inline-flex'>
<Button
icon={currentButtonIcon}
aria-label={t('切换主题')}
theme='borderless'
type='tertiary'
className='!w-8 !h-8 sm:!w-9 sm:!h-9 !flex !items-center !justify-center hover:!bg-brand/10 dark:hover:!bg-brand/15 hover:!text-brand-deep dark:hover:!text-brand-from !rounded-full !transition-all !duration-200 hover:!scale-[1.08] active:!scale-95'
style={{
color:
actualTheme === 'dark'
? 'rgba(243,244,246,0.9)'
: 'rgba(75,85,99,1)',
}}
/>
</span>
</Dropdown>
);
};
+35 -33
View File
@@ -300,41 +300,43 @@ const UserArea = ({
</Dropdown.Menu>
}
>
<Button
theme='borderless'
type='tertiary'
className='flex items-center gap-2 !pl-1.5 !pr-2.5 !py-1.5 !h-10 !rounded-full hover:!bg-brand/10 dark:hover:!bg-brand/15 !bg-transparent !transition-all !duration-200 hover:!-translate-y-0.5 group'
>
<div className='relative'>
<Avatar
size='small'
src={avatarUrl}
color={stringToColor(displayName)}
className='!w-7 !h-7 !text-xs ring-2 ring-white dark:ring-gray-800 group-hover:!ring-brand/40 dark:group-hover:!ring-brand/50 transition-all'
>
{displayName[0].toUpperCase()}
</Avatar>
{/* 在线状态点 */}
<span className='absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 bg-emerald-500 border-2 border-white dark:border-gray-800 rounded-full' />
</div>
<span className='hidden md:flex flex-col items-start'>
<Typography.Text
className='!text-sm !font-medium !leading-none'
<span className='inline-flex'>
<Button
theme='borderless'
type='tertiary'
className='flex items-center gap-2 !pl-1.5 !pr-2.5 !py-1.5 !h-10 !rounded-full hover:!bg-brand/10 dark:hover:!bg-brand/15 !bg-transparent !transition-all !duration-200 hover:!-translate-y-0.5 group'
>
<div className='relative'>
<Avatar
size='small'
src={avatarUrl}
color={stringToColor(displayName)}
className='!w-7 !h-7 !text-xs ring-2 ring-white dark:ring-gray-800 group-hover:!ring-brand/40 dark:group-hover:!ring-brand/50 transition-all'
>
{displayName[0].toUpperCase()}
</Avatar>
{/* 在线状态点 */}
<span className='absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 bg-emerald-500 border-2 border-white dark:border-gray-800 rounded-full' />
</div>
<span className='hidden md:flex flex-col items-start'>
<Typography.Text
className='!text-sm !font-medium !leading-none'
style={{
color: isDark ? 'rgba(243,244,246,0.9)' : 'rgba(55,65,81,1)',
}}
>
{displayName}
</Typography.Text>
</span>
<ChevronDown
size={14}
style={{
color: isDark ? 'rgba(243,244,246,0.9)' : 'rgba(55,65,81,1)',
color: isDark ? 'rgba(209,213,219,1)' : 'rgba(156,163,175,1)',
}}
>
{displayName}
</Typography.Text>
</span>
<ChevronDown
size={14}
style={{
color: isDark ? 'rgba(209,213,219,1)' : 'rgba(156,163,175,1)',
}}
className='group-hover:!opacity-80 transition-colors'
/>
</Button>
className='group-hover:!opacity-80 transition-colors'
/>
</Button>
</span>
</Dropdown>
);
} else {