feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面

This commit is contained in:
zhanjunhao
2026-11-09 21:45:37 +08:00
parent 6ad95e2baa
commit 5713d541b0
242 changed files with 9242 additions and 5043 deletions
@@ -0,0 +1,88 @@
/*
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, { useState } from 'react';
import { Button } from 'antd';
import { useTranslation } from 'react-i18next';
import { useIsMobile } from '../../hooks/common/useIsMobile';
import { ConsoleCard, ConsoleSearchBar } from './ConsolePrimitives';
import { TableTitle } from '../common/table/TableToolbar';
export default function ConsoleCollection({
children,
statsArea,
descriptionArea,
tabsArea,
actionsArea,
searchArea,
tableActions,
tableTitle,
tableActionsOffset = false,
paginationArea,
}) {
const { t } = useTranslation();
const isMobile = useIsMobile();
const [expanded, setExpanded] = useState(false);
const showSearch = !isMobile || expanded;
return (
<div className='console-collection'>
{statsArea && (
<ConsoleCard className='console-stats'>{statsArea}</ConsoleCard>
)}
{searchArea && (
<>
{isMobile && (
<Button
onClick={() => setExpanded(!expanded)}
aria-expanded={expanded}
>
{t(expanded ? '隐藏操作项' : '显示操作项')}
</Button>
)}
<ConsoleSearchBar hidden={!showSearch}>{searchArea}</ConsoleSearchBar>
</>
)}
<ConsoleCard>
{tabsArea && <div className='console-list-tabs'>{tabsArea}</div>}
{(tableTitle || descriptionArea || actionsArea || tableActions) && (
<div className='console-list-toolbar'>
{tableTitle && <TableTitle>{tableTitle}</TableTitle>}
{actionsArea && (
<div
className={`console-list-actions${tableActionsOffset ? ' console-list-actions-offset' : ''}`}
>
{actionsArea}
</div>
)}
{descriptionArea && (
<div className='console-list-description'>{descriptionArea}</div>
)}
{tableActions && (
<div className='console-list-table-actions'>{tableActions}</div>
)}
</div>
)}
<div className='console-list-content'>{children}</div>
{paginationArea && (
<div className='console-pagination'>{paginationArea}</div>
)}
</ConsoleCard>
</div>
);
}
+45
View File
@@ -0,0 +1,45 @@
/*
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 { createContext, useContext } from 'react';
import { theme } from 'antd';
export function useConsoleThemeStyle() {
const { token } = theme.useToken();
return {
'--console-surface': token.colorBgContainer,
'--console-bg': token.colorBgLayout,
'--console-heading': token.colorTextHeading,
'--console-text': token.colorText,
'--console-muted': token.colorTextSecondary,
'--console-border': token.colorBorderSecondary,
'--console-fill': token.colorFillAlter,
'--console-primary': token.colorPrimary,
};
}
export const ConsoleContext = createContext(null);
export const useConsolePage = () => useContext(ConsoleContext);
export const ConsoleSearchContext = createContext(false);
export const useConsoleControlSize = (size) =>
useContext(ConsoleSearchContext)
? 'middle'
: size === 'default'
? 'middle'
: size;
@@ -0,0 +1,51 @@
/*
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, { useId } from 'react';
import { Button } from 'antd';
import { useTranslation } from 'react-i18next';
import FilterSearchButton from '../common/table/FilterSearchButton';
import './module-alignment.css';
// Labels belong to the module; this wrapper only supplies the shared layout.
export function ConsoleFilterField({ label, children }) {
const id = useId();
return (
<div className='console-module-field'>
<label htmlFor={id}>{label}</label>
{React.isValidElement(children)
? React.cloneElement(children, { id })
: children}
</div>
);
}
export function ConsoleFilterActions({ onReset, onSearch, loading }) {
const { t } = useTranslation();
return (
<div className='console-module-filter-actions'>
<Button onClick={onReset}>{t('重置')}</Button>
<FilterSearchButton
htmlType={onSearch ? 'button' : 'submit'}
onClick={onSearch}
loading={loading}
/>
</div>
);
}
@@ -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;
}
@@ -0,0 +1,235 @@
/*
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, { forwardRef } from 'react';
import {
Alert,
Button,
Card,
Drawer,
Empty,
Form,
Modal,
Table,
Tabs,
theme,
} from 'antd';
import { useTranslation } from 'react-i18next';
import {
ConsoleSearchContext,
useConsolePage,
useConsoleThemeStyle,
} from './ConsoleContext';
const classes = (base, extra) => [base, extra].filter(Boolean).join(' ');
export function ConsoleAlert({ className, style, type = 'info', ...props }) {
const { token } = theme.useToken();
const semantic = type[0].toUpperCase() + type.slice(1);
return (
<Alert
{...props}
type={type}
showIcon
className={classes('console-alert', className)}
style={{
...style,
marginBlock: style?.marginBlock ?? '0 16px',
padding: '12px 16px',
borderRadius: token.borderRadiusLG,
background: token[`color${semantic}Bg`],
borderColor: token[`color${semantic}Border`],
color: token.colorText,
}}
/>
);
}
export const ConsoleCard = forwardRef(function ConsoleCard(
{ className, ...props },
ref,
) {
return (
<Card {...props} ref={ref} className={classes('console-card', className)} />
);
});
// Existing form adapters keep their value and submit contracts inside this layout.
export function ConsoleSearchBar({ children, className, formProps, ...props }) {
return (
<ConsoleCard
{...props}
className={classes('console-search-card', className)}
>
<ConsoleSearchContext.Provider value={true}>
{formProps ? (
<ConsoleForm {...formProps}>{children}</ConsoleForm>
) : (
children
)}
</ConsoleSearchContext.Provider>
</ConsoleCard>
);
}
export function ConsoleSearchActions({
onReset,
onSearch,
loading,
searchLabel = '搜索',
}) {
const { t } = useTranslation();
return (
<div className='console-search-actions'>
{onReset && <Button onClick={onReset}>{t('重置')}</Button>}
<Button
type='primary'
htmlType={onSearch ? 'button' : 'submit'}
onClick={onSearch}
loading={loading}
>
{t(searchLabel)}
</Button>
</div>
);
}
export const ConsoleForm = forwardRef(function ConsoleForm(
{ className, layout = 'vertical', ...props },
ref,
) {
const isSettings = useConsolePage()?.page.key === 'setting';
return (
<Form
{...props}
ref={ref}
layout={isSettings ? 'vertical' : layout}
labelCol={isSettings ? undefined : props.labelCol}
wrapperCol={isSettings ? undefined : props.wrapperCol}
labelAlign={isSettings ? 'left' : props.labelAlign}
className={classes(
isSettings ? 'console-form settings-system-form' : 'console-form',
className,
)}
/>
);
});
export const ConsoleTable = forwardRef(function ConsoleTable(
{ className, scroll, locale, size = 'middle', ...props },
ref,
) {
return (
<Table
{...props}
ref={ref}
size={size}
scroll={{ x: 'max-content', ...scroll }}
locale={{
emptyText: <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />,
...locale,
}}
className={classes('console-table', className)}
/>
);
});
export function ConsoleTabs({ className, ...props }) {
return <Tabs {...props} className={classes('console-tabs', className)} />;
}
const isFooterButton = (node) =>
React.isValidElement(node) &&
(node.type === Button || node.type?.render?.name === 'Button');
const isPrimaryAction = ({ props }) =>
props.theme === 'solid' ||
props.danger ||
props.type === 'danger' ||
(props.type === 'primary' &&
!['light', 'outline', 'borderless'].includes(props.theme));
// Reorder only groups composed entirely of buttons; preserve mixed footer content.
function normalizeFooter(footer) {
if (!footer || typeof footer === 'function') return footer;
const nodes = React.Children.toArray(footer);
if (nodes.length > 1 && nodes.every(isFooterButton)) {
return [
...nodes.filter((node) => !isPrimaryAction(node)),
...nodes.filter(isPrimaryAction),
];
}
const normalized = nodes.map((node) =>
React.isValidElement(node) && !isFooterButton(node) && node.props.children
? React.cloneElement(
node,
undefined,
normalizeFooter(node.props.children),
)
: node,
);
return Array.isArray(footer) ? normalized : normalized[0];
}
export function ConsoleModal({
rootClassName,
style,
footer,
width = 560,
...props
}) {
const themeStyle = useConsoleThemeStyle();
const isSettings = useConsolePage()?.page.key === 'setting';
return (
<Modal
{...props}
width={width}
style={{ ...themeStyle, ...style }}
footer={normalizeFooter(footer)}
rootClassName={classes(
isSettings ? 'console-overlay settings-form-dialog' : 'console-overlay',
rootClassName,
)}
/>
);
}
export function ConsoleDrawer({
rootClassName,
rootStyle,
footer,
width = 560,
...props
}) {
const themeStyle = useConsoleThemeStyle();
const isSettings = useConsolePage()?.page.key === 'setting';
return (
<Drawer
{...props}
width={width}
rootStyle={{ ...themeStyle, ...rootStyle }}
footer={normalizeFooter(footer)}
rootClassName={classes(
isSettings
? 'console-overlay console-drawer settings-form-dialog'
: 'console-overlay console-drawer',
rootClassName,
)}
/>
);
}
+446
View File
@@ -0,0 +1,446 @@
.console-page,
.console-overlay {
--console-space-1: 8px;
--console-space-2: 16px;
--console-space-3: 24px;
--console-gap: var(--console-space-2);
--console-radius: 10px;
--console-control-height: 34px;
}
.console-page {
min-width: 0;
min-height: 100dvh;
padding: calc(
var(--console-header-offset, 72px) + var(--uc-page-pad-top, 30px)
)
var(--uc-page-pad-x, 36px) var(--uc-page-pad-bottom, 36px);
background: var(--uc-page-bg, var(--console-bg));
color: var(--console-text);
}
.console-page-header {
margin-bottom: 18px;
}
.console-page .console-breadcrumb.ant-breadcrumb {
margin-bottom: var(--console-space-3);
font-size: 12px;
line-height: 18px;
}
.console-breadcrumb .ant-breadcrumb-separator {
margin-inline: 10px;
}
.console-page .console-breadcrumb :is(ol, li, a, .ant-breadcrumb-link) {
line-height: 18px;
}
.console-page-header-main {
display: flex;
align-items: flex-end;
justify-content: space-between;
flex-wrap: wrap;
gap: var(--console-space-2);
}
.console-page-heading {
min-width: 0;
}
.console-page-title {
margin: 0;
color: var(--console-heading);
font-size: 28px;
line-height: 32px;
font-weight: 650;
letter-spacing: -0.6px;
}
.console-page-description {
margin: 6px 0 0;
color: var(--console-muted);
font-size: 14px;
line-height: 22px;
}
.console-page-actions,
.console-list-actions {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: var(--console-space-1);
min-width: 0;
max-width: 100%;
}
.console-page-actions:empty {
display: none;
}
.console-page-body,
.console-content,
.console-collection {
display: flex;
flex-direction: column;
gap: var(--console-gap);
min-width: 0;
}
.console-page-body > *,
.console-page .ant-layout,
.console-page .ant-layout-content,
.console-page .ant-tabs-content-holder,
.console-page .ant-tabs-tabpane,
.console-page .ant-col,
.console-page .ant-space-item {
min-width: 0;
max-width: 100%;
}
.console-page .console-card.ant-card {
border: 1px solid var(--console-border);
border-radius: var(--console-radius);
background: var(--console-surface);
box-shadow: none;
}
.console-page .console-card > .ant-card-body {
padding: var(--console-space-3);
}
.console-page .console-card > .ant-card-head {
min-height: 56px;
padding-inline: var(--console-space-3);
border-color: var(--console-border);
font-size: 16px;
font-weight: 600;
}
.console-list-tabs,
.console-list-toolbar {
margin-bottom: var(--console-space-2);
}
.console-list-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
gap: var(--console-space-2);
flex-wrap: wrap;
}
.console-list-toolbar .console-list-actions {
flex: 1;
}
.console-list-description {
display: flex;
justify-content: flex-end;
margin-inline-start: auto;
}
.console-list-table-actions {
display: flex;
align-items: center;
justify-content: flex-end;
gap: var(--console-space-1);
margin-inline-start: auto;
}
.console-page
.console-list-toolbar
.ant-btn:not(.ant-btn-link):not(.ant-btn-text) {
min-height: var(--console-control-height);
font-size: 14px;
}
.console-page .console-search-card .usage-logs-filter-form {
border: 0;
padding: 0;
background: transparent;
}
.console-page .usage-logs-filter-title-icon {
display: none;
}
.console-task-stats {
display: flex;
justify-content: space-between;
align-items: center;
gap: var(--console-space-2);
flex-wrap: wrap;
}
.console-page .usage-record-filter-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: var(--console-space-2);
width: 100%;
}
.console-page .usage-record-filter-wide {
grid-column: span 2;
}
.console-page
.usage-record-filter-grid
:is(.ant-picker, .ant-select, .ant-input-affix-wrapper) {
width: 100%;
}
.console-page .usage-record-filter-actions {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
gap: var(--console-space-1);
width: 100%;
}
.console-pagination {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
margin-top: var(--console-space-2);
gap: var(--console-space-1);
}
:is(.console-page, .console-overlay) .console-form .ant-form-item {
margin-bottom: var(--console-space-3);
}
:is(.console-page, .console-overlay) .console-form .ant-form-item-label {
padding-bottom: var(--console-space-1);
}
:is(.console-page, .console-overlay)
.console-form
.ant-form-item-label
> label {
color: var(--console-muted);
font-size: 14px;
line-height: 22px;
}
.console-search-card[hidden] {
display: none;
}
.console-page .console-search-card .ant-form,
.console-search-fields {
display: flex;
align-items: flex-end;
flex-wrap: wrap;
gap: var(--console-space-2);
min-width: 0;
width: 100%;
}
.console-search-card .ant-select {
width: 100%;
}
.console-search-fields > .console-search-field {
flex: 1 1 200px;
min-width: 0;
}
.console-search-card .ant-form > .flex {
width: 100%;
flex-wrap: wrap;
gap: var(--console-space-2);
}
.console-page .console-search-card .usage-logs-filter-content {
width: 100%;
}
.console-page .console-search-card .ant-form-item {
margin: 0;
min-width: 0;
}
.console-search-card .console-search-actions {
display: flex;
justify-content: flex-end;
flex: 0 0 auto;
flex-wrap: wrap;
gap: var(--console-space-1);
margin-inline-start: auto;
}
.console-page .console-table .ant-table-thead > tr > th {
background: var(--console-fill);
color: var(--console-muted);
font-weight: 500;
}
.console-page .console-table .ant-table-cell {
border-color: var(--console-border);
}
.console-page .console-table .ant-table-pagination {
margin: var(--console-space-2) 0 0;
}
.console-page .console-tabs > .ant-tabs-nav {
margin-bottom: var(--console-space-2);
}
.console-page .ant-tabs-tab .lucide,
.console-page .ant-btn .lucide {
width: 16px;
height: 16px;
}
:is(.console-page, .console-overlay) .console-create-action.ant-btn {
display: inline-flex;
align-items: center;
justify-content: center;
}
:is(.console-page, .console-overlay)
.console-create-action.ant-btn
.ant-btn-icon {
display: inline-flex;
align-items: center;
justify-content: center;
}
:is(.console-page, .console-overlay)
.console-create-action.ant-btn
.ant-btn-icon
svg {
display: block;
}
.console-page .ant-alert,
.console-overlay .console-alert {
align-items: flex-start;
padding: 12px 16px;
border-radius: var(--console-radius);
font-size: 14px;
line-height: 22px;
}
:is(.console-page, .console-overlay) .ant-alert-content {
min-width: 0;
overflow-wrap: anywhere;
}
:is(.console-page, .console-overlay) .ant-alert-message,
:is(.console-page, .console-overlay) .ant-alert-description {
color: var(--console-text);
font-size: 14px;
line-height: 22px;
}
:is(.console-page, .console-overlay) .ant-alert-message {
margin-bottom: 0;
font-weight: 500;
}
:is(.console-page, .console-overlay)
.ant-alert-message
+ .ant-alert-description {
margin-top: 4px;
}
:is(.console-page, .console-overlay) .ant-alert-icon {
margin: 3px 10px 0 0;
font-size: 16px;
}
:is(.console-page, .console-overlay) .ant-alert-action {
margin-inline-start: 16px;
}
.console-page .ant-alert + .ant-alert {
margin-top: 16px;
}
.console-page .console-table .ant-btn-link {
padding-inline: var(--console-space-1);
}
.console-page .console-table .ant-empty {
margin-block: 32px;
}
.console-overlay .ant-modal-title,
.console-overlay .ant-drawer-title {
font-size: 16px;
line-height: 24px;
font-weight: 600;
}
.console-overlay .ant-drawer-body {
padding: 24px;
scrollbar-gutter: stable;
}
.console-overlay .ant-drawer-content-wrapper {
max-width: 100vw;
}
.console-overlay .ant-modal-footer,
.console-overlay .ant-drawer-footer,
.console-dialog-actions {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
gap: 8px;
}
.console-overlay .ant-modal-footer > .ant-btn + .ant-btn {
margin-inline-start: 0;
}
.console-page--canvas .console-page-body {
height: max(480px, calc(100dvh - var(--console-header-offset, 72px) - 216px));
}
.console-page .settings-page {
overflow: visible;
}
.console-page .website-settings-page {
padding: 0;
min-height: 0;
}
.console-page :is(.console-personal, .console-recharge) {
min-height: 0;
padding: 0;
background: transparent;
}
.console-page .console-personal {
--ps-header-bg: var(--console-surface);
--ps-preview-bg: var(--console-fill);
--ps-card-shadow: none;
}
.console-page .console-recharge {
--rc-wallet-bg: var(--console-surface);
--rc-order-bg: var(--console-surface);
--rc-card-shadow: none;
}
.console-page :is(.ui-personal-inner, .ui-recharge-content) {
max-width: none;
margin: 0;
padding: 0;
}
.console-page .skill-platform-page,
.console-page .expert-platform-page {
min-height: 0;
padding: 0;
background: transparent;
}
.console-page .expert-platform-shell,
.console-page .skill-platform-metrics,
.console-page .skill-platform-toolbar,
.console-page .skill-platform-grid {
max-width: none;
margin-inline: 0;
}
.console-page .skill-platform-metrics,
.console-page .skill-platform-grid,
.console-page .expert-metrics {
gap: var(--console-gap);
}
.console-page .skill-platform-metrics article,
.console-page .expert-metric,
.console-page .expert-card {
border-radius: var(--console-radius);
background: var(--console-surface);
box-shadow: none;
}
.console-chat-frame {
width: 100%;
height: 100%;
min-height: 480px;
border: 0;
border-radius: var(--console-radius);
background: var(--console-surface);
}
.console-chat-loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: var(--console-space-1);
min-height: 480px;
}
@media (max-width: 768px) {
.console-page {
--console-space-3: 16px;
padding: calc(var(--console-header-offset, 56px) + 16px) 16px 24px;
}
.console-page .console-breadcrumb.ant-breadcrumb {
margin-bottom: 24px;
}
.console-page-actions {
width: 100%;
}
.console-search-fields > :not(button),
.console-search-card .ant-form > * {
max-width: 100%;
}
.console-search-card .console-search-actions {
width: 100%;
}
.console-pagination .ant-pagination {
display: flex;
flex-wrap: wrap;
gap: 8px 0;
}
.console-page .usage-record-filter-grid {
grid-template-columns: minmax(0, 1fr);
}
.console-page .usage-record-filter-wide {
grid-column: auto;
}
}
.console-overlay .console-detail-header .ant-drawer-header-title {
flex-direction: row-reverse;
}
.console-overlay .console-detail-header .ant-drawer-close {
margin-inline: 12px 0;
}
+150
View File
@@ -0,0 +1,150 @@
/*
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
*/
// Presentation metadata only. Route guards and feature visibility remain in App/SiderBar.
export const consolePages = [
{
key: 'analytics',
menuKey: 'detail',
title: '数据看板',
description: 'analytics',
},
{ key: 'monitor', title: '监控中心', description: 'monitor' },
{ key: 'channel', title: '渠道管理', description: 'channel' },
{
key: 'token',
menuKey: 'admin-token',
title: '密钥管理',
description: 'token',
},
{ key: 'models', title: '模型管理', description: 'models' },
{ key: 'user', title: '用户管理', description: 'user' },
{ key: 'redemption', title: '兑换码管理', description: 'redemption' },
{ key: 'topup', title: '钱包管理', description: 'topup' },
{ key: 'log', title: '使用日志', description: 'log' },
{ key: 'midjourney', title: '绘图日志', description: 'midjourney' },
{ key: 'task', title: '任务日志', description: 'task' },
{ key: 'organizations', title: '企业管理', description: 'organizations' },
{ key: 'order', title: '订单管理', description: 'order' },
{ key: 'invoice', title: '发票管理', description: 'invoice' },
{ key: 'subscription', title: '会员卡管理', description: 'subscription' },
{ key: 'setting', title: '系统设置', description: 'setting' },
{ key: 'website-setting', title: '官网设置', description: 'website-setting' },
{
key: 'demo-reservations',
title: '预约演示',
description: 'demo-reservations',
},
{ key: 'personal', title: '个人设置', description: 'personal' },
{ key: 'my-commission', title: '我的提成', description: 'my-commission' },
{ key: 'partner', title: '合作伙伴', description: 'partner' },
{
key: 'skill-platform',
title: '平台 Skill 中心',
description: 'skill-platform',
},
{
key: 'expert-platform',
title: '专家与模型能力',
description: 'expert-platform',
},
{
key: 'playground',
title: '在线调试',
description: 'playground',
canvas: true,
},
{
key: 'chat',
title: '聊天',
description: 'chat',
canvas: true,
dynamicChildTitle: '详情',
},
].map((page) => ({ ...page, path: `/console/${page.key}` }));
export function isNavigationPathActive(pathname, prefix) {
if (!prefix) return false;
if (prefix === '/') return pathname === '/';
const normalized = prefix.replace(/\/+$/, '');
return pathname === normalized || pathname.startsWith(`${normalized}/`);
}
const normalizePath = (pathname) =>
(pathname || '/console').split(/[?#]/)[0].replace(/\/+$/, '') || '/';
function segmentTitle(segment) {
const actions = { edit: '编辑', new: '新建', create: '新建', detail: '详情' };
if (actions[segment]) return actions[segment];
if (/^\d+$/.test(segment)) return '详情';
try {
return decodeURIComponent(segment).replace(/[-_]/g, ' ');
} catch {
return segment;
}
}
export function resolveConsolePage(pathname, pages = consolePages) {
const path = normalizePath(pathname);
const page = [...pages]
.sort((a, b) => b.path.length - a.path.length)
.find((item) => isNavigationPathActive(path, item.path));
const root = { path: '/console', title: '控制台' };
const matched = pages
.filter((item) => isNavigationPathActive(path, item.path))
.sort((a, b) => a.path.length - b.path.length);
const breadcrumbs = [
root,
...matched.map(({ path, title }) => ({ path, title })),
];
const basePath = page?.path || root.path;
const segments = path.slice(basePath.length).split('/').filter(Boolean);
let currentPath = basePath;
for (const [index, segment] of segments.entries()) {
currentPath += `/${segment}`;
breadcrumbs.push({
path: currentPath,
title:
index === 0 && page?.dynamicChildTitle
? page.dynamicChildTitle
: segmentTitle(segment),
});
}
return {
...(page || { key: 'fallback', description: 'fallback' }),
title: breadcrumbs.at(-1).title,
path,
breadcrumbs,
};
}
export const consoleMenuPaths = Object.fromEntries(
consolePages.flatMap((page) =>
[...new Set([page.menuKey || page.key, page.key])].map((key) => [
key,
page.path,
]),
),
);
export function getConsoleMenuKeys(pathname, paths = consoleMenuPaths) {
if (!pathname) return [];
const path = normalizePath(pathname);
return Object.keys(paths).filter((key) => paths[key] === path);
}
@@ -0,0 +1,32 @@
/*
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
*/
export function toConsoleTableChange(pagination, filters, sorter, extra) {
const normalize = (value) => ({
...value,
dataIndex: value?.field,
sortOrder: value?.order,
});
return {
pagination,
filters,
sorter: Array.isArray(sorter) ? sorter.map(normalize) : normalize(sorter),
...extra,
};
}
+230
View File
@@ -0,0 +1,230 @@
.console-page .console-search-card .console-module-filter-form {
display: block;
}
.console-page .console-module-filter-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 16px;
width: 100%;
}
.console-module-field {
min-width: 0;
}
.console-page .console-module-filter-grid .ant-form-item-label > label,
.console-module-field > label {
color: var(--console-muted);
font-size: 13px;
}
.console-module-field > label {
display: block;
margin-bottom: 8px;
line-height: 22px;
}
.console-module-filter-grid .ant-input-number,
.console-module-filter-grid .ant-picker,
.console-module-filter-grid .ant-select,
.console-module-filter-grid .ant-input-affix-wrapper,
.console-module-filter-grid .ant-input {
width: 100%;
}
.console-module-filter-actions {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
gap: 8px;
margin-top: 16px;
width: 100%;
}
.console-module-row-actions {
display: inline-flex;
align-items: center;
flex-wrap: wrap;
gap: 8px;
}
.console-module-row-actions .ant-btn-link {
height: auto;
padding: 0 4px;
font-size: 13px;
}
.console-page:is(
[data-console-page='channel'],
[data-console-page='models'],
[data-console-page='user'],
[data-console-page='organizations'],
[data-console-page='order']
)
.console-table
.ant-table-thead
> tr
> th {
height: 46px;
padding-block: 0;
font-weight: 400;
}
.console-model-drawer .ant-drawer-title > .ant-space {
align-items: center;
}
.console-model-drawer .ant-drawer-title .ant-typography {
margin: 0;
}
.console-model-drawer .ant-drawer-title .ant-tag {
margin-inline-end: 0;
}
.console-model-section,
.console-channel-section {
display: flex;
align-items: center;
gap: 5px;
margin-bottom: 16px;
}
.console-model-section .ant-avatar,
.console-channel-section .ant-avatar {
flex-shrink: 0;
margin: 0;
}
.console-channel-sections > div + div {
margin-top: 10px;
}
.console-channel-sections > div > .ant-card {
margin-bottom: 0;
}
.console-channel-section .ant-avatar svg {
display: block;
width: 16px;
height: 16px;
}
.console-channel-footer .ant-btn {
display: inline-flex;
align-items: center;
justify-content: center;
}
.console-channel-drawer .ant-form-item-extra > .ant-space,
.console-channel-drawer .console-channel-key-actions,
.console-channel-drawer .console-channel-model-actions {
margin-top: 10px;
}
.console-channel-drawer .ant-divider-inner-text {
min-width: 0;
max-width: 100%;
white-space: normal;
overflow-wrap: anywhere;
}
.console-overlay .console-model-footer,
.console-overlay .console-channel-footer {
display: flex;
align-items: center;
justify-content: flex-end;
flex-wrap: wrap;
gap: 8px;
}
@media (max-width: 1100px) {
.console-page .console-module-filter-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 768px) {
.console-page .console-module-filter-grid {
grid-template-columns: minmax(0, 1fr);
}
}
.console-model-drawer .prefill-management-header .ant-drawer-header-title {
flex-direction: row-reverse;
}
.console-model-drawer .prefill-management-header .ant-drawer-close {
margin-inline: 12px 0;
}
.console-model-drawer .console-model-editor-header .ant-drawer-header-title,
.console-channel-drawer
.console-channel-editor-header
.ant-drawer-header-title {
flex-direction: row-reverse;
}
.console-model-drawer .console-model-editor-header .ant-drawer-title,
.console-channel-drawer .console-channel-editor-header .ant-drawer-title {
text-align: start;
}
.console-model-drawer .console-model-editor-header .ant-drawer-close,
.console-channel-drawer .console-channel-editor-header .ant-drawer-close {
margin-inline: 12px 0;
}
.console-model-drawer .console-model-tag-presets {
margin-top: 10px;
}
:is(.console-model-endpoints, .console-channel-drawer) .json-editor-pairs {
padding-top: 5px;
}
:is(.console-model-endpoints, .console-channel-drawer) .json-editor-pair {
align-items: flex-start;
margin-top: 0;
margin-bottom: 5px;
}
:is(.console-model-endpoints, .console-channel-drawer)
.json-editor-pair
textarea.ant-input {
text-align: start;
font: inherit;
line-height: 1.5715;
}
:is(.console-model-endpoints, .console-channel-drawer) .json-editor-add {
margin-top: 5px;
}
:is(.console-model-endpoints, .console-channel-drawer) {
--json-editor-header-padding: 8px 16px;
--json-editor-note-margin: 8px 0 0;
}
:is(.console-model-endpoints, .console-channel-drawer)
.json-editor-header
> .json-editor-tabs.ant-tabs,
:is(.console-model-endpoints, .console-channel-drawer)
.json-editor-tabs
> .ant-tabs-nav {
margin: 0;
}
:is(.console-model-endpoints, .console-channel-drawer)
.json-editor-tabs
.ant-tabs-tab {
padding-block: 8px;
}
:is(.console-model-endpoints, .console-channel-drawer)
.json-editor-tabs
> .ant-tabs-content-holder,
:is(.console-model-endpoints, .console-channel-drawer)
.json-editor-bound-field {
display: none;
}