feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
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 React, { useMemo, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { Breadcrumb } from 'antd';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
ConsoleContext,
|
||||
useConsolePage,
|
||||
useConsoleThemeStyle,
|
||||
} from './ConsoleContext';
|
||||
import { resolveConsolePage } from './consoleRoutes';
|
||||
import './console.css';
|
||||
|
||||
export default function ConsolePageContainer({ children }) {
|
||||
const { pathname } = useLocation();
|
||||
const { t } = useTranslation();
|
||||
const themeStyle = useConsoleThemeStyle();
|
||||
const page = useMemo(() => resolveConsolePage(pathname), [pathname]);
|
||||
const [actionsTarget, setActionsTarget] = useState(null);
|
||||
const context = useMemo(
|
||||
() => ({ page, actionsTarget }),
|
||||
[page, actionsTarget],
|
||||
);
|
||||
|
||||
return (
|
||||
<ConsoleContext.Provider value={context}>
|
||||
<main
|
||||
className={`console-page${page.canvas ? ' console-page--canvas' : ''}`}
|
||||
data-console-page={page.key}
|
||||
style={themeStyle}
|
||||
>
|
||||
<header className='console-page-header'>
|
||||
<Breadcrumb
|
||||
className='console-breadcrumb'
|
||||
items={page.breadcrumbs.map((item, index) => ({
|
||||
key: item.path,
|
||||
title:
|
||||
index === page.breadcrumbs.length - 1 ? (
|
||||
<span aria-current='page'>{t(item.title)}</span>
|
||||
) : (
|
||||
<Link to={item.path}>{t(item.title)}</Link>
|
||||
),
|
||||
}))}
|
||||
/>
|
||||
<div className='console-page-header-main'>
|
||||
<div className='console-page-heading'>
|
||||
<h1 className='console-page-title'>{t(page.title)}</h1>
|
||||
<p className='console-page-description'>
|
||||
{t(`consoleUi.descriptions.${page.description}`)}
|
||||
</p>
|
||||
</div>
|
||||
<div className='console-page-actions' ref={setActionsTarget} />
|
||||
</div>
|
||||
</header>
|
||||
<div className='console-page-body'>{children}</div>
|
||||
</main>
|
||||
</ConsoleContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function ConsolePageActions({ children }) {
|
||||
const context = useConsolePage();
|
||||
if (!context) return <>{children}</>;
|
||||
return context.actionsTarget
|
||||
? createPortal(children, context.actionsTarget)
|
||||
: null;
|
||||
}
|
||||
Reference in New Issue
Block a user