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,217 @@
/*
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 { Alert, Button, Checkbox, Modal, Tooltip, theme } from 'antd';
import { Settings } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import './column-settings.css';
const titleText = (title) =>
React.Children.toArray(title)
.map((child) =>
React.isValidElement(child) ? titleText(child.props.children) : child,
)
.join('');
const columnOptions = (columns) =>
columns.map((column) => ({
value: column.key,
label: column.label ?? titleText(column.title),
disabled: column.disabled,
}));
const selectedKeys = (options, value) =>
options
.filter((option) => value.includes(option.value))
.map((option) => option.value);
export function ColumnSettingsButton({ onClick, open = false }) {
const { t } = useTranslation();
return (
<Tooltip title={t('列设置')}>
<Button
className='table-column-settings-trigger'
type='text'
size='middle'
aria-label={t('列设置')}
aria-haspopup='dialog'
aria-expanded={open}
icon={<Settings size={16} />}
onClick={onClick}
/>
</Tooltip>
);
}
export function ColumnSettingsModal({
open,
onCancel,
columns,
value,
defaultValue,
onConfirm,
}) {
const { t } = useTranslation();
const { token } = theme.useToken();
const options = columnOptions(columns);
const [session, setSession] = useState({
open: false,
draft: [],
error: false,
});
// Snapshot on opening only: background table refreshes must not reset the draft.
if (session.open !== open) {
setSession({ open, draft: selectedKeys(options, value), error: false });
}
const draft = selectedKeys(options, session.draft);
const selectable = options.filter((option) => !option.disabled);
const checkedCount = selectable.filter((option) =>
draft.includes(option.value),
).length;
const changeDraft = (keys) => setSession({ open, draft: keys, error: false });
const confirm = () => {
if (!draft.length) {
setSession({ ...session, error: true });
return;
}
onConfirm(draft);
onCancel();
};
return (
<Modal
open={open}
title={t('列设置')}
width={520}
rootClassName='table-column-settings'
className='table-column-settings-dialog'
style={{
'--cs-theme-text': token.colorText,
'--cs-theme-border': token.colorBorderSecondary,
}}
onCancel={onCancel}
maskClosable
keyboard
footer={
<div className='table-column-settings-footer'>
<Button
onClick={() => changeDraft(selectedKeys(options, defaultValue))}
>
{t('重置')}
</Button>
<Button onClick={onCancel}>{t('取消')}</Button>
<Button type='primary' onClick={confirm}>
{t('确定')}
</Button>
</div>
}
>
<div className='table-column-settings-all'>
<Checkbox
checked={selectable.length > 0 && checkedCount === selectable.length}
indeterminate={checkedCount > 0 && checkedCount < selectable.length}
disabled={!selectable.length}
onChange={(event) =>
changeDraft(
options
.filter((option) =>
option.disabled
? draft.includes(option.value)
: event.target.checked,
)
.map((option) => option.value),
)
}
>
{t('全选')}
</Checkbox>
</div>
<Checkbox.Group
className='table-column-settings-grid'
options={options}
value={draft}
onChange={changeDraft}
/>
{session.error && (
<Alert
className='table-column-settings-error'
type='error'
showIcon
message={t('请至少保留一列')}
/>
)}
</Modal>
);
}
export function ColumnVisibilitySettings({
showColumnSelector,
setShowColumnSelector,
columns,
visibleColumns,
setVisibleColumns,
getDefaultColumnVisibility,
}) {
const defaults = getDefaultColumnVisibility();
return (
<ColumnSettingsModal
open={showColumnSelector}
onCancel={() => setShowColumnSelector(false)}
columns={columns}
value={columns
.filter((column) => visibleColumns[column.key])
.map((column) => column.key)}
defaultValue={columns
.filter((column) => defaults[column.key])
.map((column) => column.key)}
onConfirm={(keys) =>
setVisibleColumns((current) => ({
...current,
...Object.fromEntries(
columns.map((column) => [column.key, keys.includes(column.key)]),
),
}))
}
/>
);
}
export default function TableColumnSettings({
columns,
value,
defaultValue,
onChange,
}) {
const [open, setOpen] = useState(false);
return (
<>
<ColumnSettingsButton open={open} onClick={() => setOpen(true)} />
<ColumnSettingsModal
open={open}
onCancel={() => setOpen(false)}
columns={columns}
value={value}
defaultValue={defaultValue}
onConfirm={onChange}
/>
</>
);
}
@@ -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 React from 'react';
import { Button } from 'antd';
import { Search } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import './filter-search-button.css';
export default function FilterSearchButton({
loading,
htmlType = 'submit',
onClick,
}) {
const { t } = useTranslation();
return (
<Button
className='filter-search-button'
type='primary'
htmlType={htmlType}
onClick={onClick}
size='middle'
loading={loading}
icon={<Search size={14} />}
>
{t('搜索')}
</Button>
);
}
@@ -0,0 +1,46 @@
/*
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, { useLayoutEffect, useRef, useState } from 'react';
import { Empty } from 'antd';
import { useTranslation } from 'react-i18next';
import './table-empty.css';
export default function TableEmpty() {
const { t } = useTranslation();
const ref = useRef(null);
const [width, setWidth] = useState(undefined);
useLayoutEffect(() => {
const viewport = ref.current?.closest('.ant-table-container');
if (!viewport) return;
// Keep the empty state centered in the visible area of a wide, scrollable table.
const resize = () => setWidth(viewport.clientWidth || undefined);
resize();
const observer = new ResizeObserver(resize);
observer.observe(viewport);
return () => observer.disconnect();
}, []);
return (
<div ref={ref} className='table-empty-state' style={{ width }}>
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description={t('暂无数据')} />
</div>
);
}
@@ -0,0 +1,40 @@
/*
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 from 'react';
import { useTranslation } from 'react-i18next';
import './table-toolbar.css';
export function TableTitle({ children }) {
const { t } = useTranslation();
return (
<h2 className='table-toolbar-title'>
{typeof children === 'string' ? t(children) : children}
</h2>
);
}
export default function TableToolbar({ title, children }) {
return (
<div className='table-toolbar'>
<TableTitle>{title}</TableTitle>
{children && <div className='table-toolbar-actions'>{children}</div>}
</div>
);
}
@@ -0,0 +1,121 @@
.table-column-settings {
--cs-mask: rgba(0, 0, 0, 0.3);
--cs-text: rgba(0, 0, 0, 0.88);
--cs-border: #e9edf2;
--cs-space: 8px;
--cs-column-gap: 20px;
--cs-row-gap: 16px;
}
html.dark .table-column-settings-dialog {
--cs-text: var(--cs-theme-text);
--cs-border: var(--cs-theme-border);
}
.table-column-settings .ant-modal-mask {
background: var(--cs-mask);
backdrop-filter: blur(4px);
}
.table-column-settings-dialog.ant-modal {
max-width: calc(100vw - 32px);
}
.table-column-settings-dialog .ant-modal-content {
padding: 20px 24px;
border-radius: 12px;
}
.table-column-settings-dialog .ant-modal-header {
margin-bottom: var(--cs-space);
}
.table-column-settings-dialog .ant-modal-title {
color: var(--cs-text);
font-size: 16px;
font-weight: 600;
line-height: 24px;
}
.table-column-settings-dialog .ant-modal-body {
padding-top: 20px;
}
.table-column-settings-all {
padding: 14px 0;
margin-bottom: 18px;
border-bottom: 1px solid var(--cs-border);
}
.table-column-settings-grid.ant-checkbox-group {
display: grid;
width: 100%;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: var(--cs-row-gap) var(--cs-column-gap);
padding: 4px 0 12px;
}
.table-column-settings-dialog .ant-checkbox-wrapper {
min-width: 0;
margin: 0;
color: var(--cs-text);
font-size: 14px;
line-height: 22px;
}
.table-column-settings-dialog .ant-checkbox-inner {
width: 17px;
height: 17px;
border-radius: 6px;
}
.table-column-settings-dialog .ant-modal-footer {
margin-top: 12px;
}
.table-column-settings-footer {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
gap: var(--cs-space);
}
.table-column-settings-footer .ant-btn {
height: 34px;
margin: 0;
line-height: normal;
}
.table-column-settings-footer .ant-btn-default {
color: var(--cs-text);
}
.table-column-settings-error {
margin-top: var(--cs-row-gap);
}
.table-column-settings-trigger.ant-btn {
flex: 0 0 auto;
width: 34px;
height: 34px;
margin-inline-start: auto;
}
.table-column-toolbar {
display: flex;
justify-content: flex-end;
align-items: center;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 18px;
}
@media (max-width: 575px) {
.table-column-settings-grid.ant-checkbox-group {
gap: 14px 10px;
}
.table-column-settings-dialog .ant-checkbox-wrapper {
font-size: 12px;
}
}
@@ -0,0 +1,17 @@
.console-page .filter-search-button {
display: inline-flex;
align-items: center;
justify-content: center;
}
.console-page .filter-search-button > .ant-btn-icon {
display: inline-flex;
align-items: center;
justify-content: center;
}
.console-page .filter-search-button .lucide {
display: block;
width: 14px;
height: 14px;
}
@@ -0,0 +1,58 @@
/* Match the consumption record's labels, grid and action placement. */
.log-filter-grid {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 16px;
width: 100%;
}
.log-filter-wide {
grid-column: span 2;
}
.log-filter-form .ant-form-item {
min-width: 0;
margin-bottom: 0;
}
.log-filter-form .ant-form-item-label {
padding-bottom: 8px;
}
.log-filter-form .ant-form-item-label > label {
height: 21px;
color: var(--text-secondary);
font-size: 13px;
}
.log-filter-form :is(.ant-picker, .ant-select) {
width: 100%;
}
.log-filter-actions {
display: flex;
justify-content: flex-end;
flex-wrap: wrap;
gap: 10px;
}
.log-filter-content {
display: flex;
flex-direction: column;
gap: 16px;
width: 100%;
}
.console-page .console-search-card .log-filter-form {
display: block;
}
.console-page .log-filter-form .ant-form-item-label > label {
height: 21px;
font-size: 13px;
line-height: 21px;
}
@media (max-width: 1200px) {
.log-filter-grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
}
}
@media (max-width: 768px) {
.log-filter-grid {
grid-template-columns: minmax(0, 1fr);
}
.log-filter-wide {
grid-column: auto;
}
}
@@ -0,0 +1,30 @@
.ant-table-wrapper
.ant-table
.ant-table-tbody
> .ant-table-placeholder:has(.table-empty-state)
> td.ant-table-cell {
padding: 0;
height: 172px;
vertical-align: middle;
}
.ant-table-wrapper .ant-table-expanded-row-fixed:has(> .table-empty-state) {
margin: 0;
padding: 0;
}
.table-empty-state {
position: sticky;
left: 0;
display: flex;
align-items: center;
justify-content: center;
box-sizing: border-box;
height: 172px;
max-width: 100%;
}
.table-empty-state > .ant-empty,
.ant-table-wrapper .ant-table-placeholder .table-empty-state > .ant-empty {
margin: 0;
}
@@ -0,0 +1,43 @@
.table-toolbar {
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 16px;
min-height: 34px;
margin-bottom: 16px;
}
h2.table-toolbar-title {
flex-shrink: 0;
margin: 0;
color: var(--console-heading, var(--uc-heading, var(--ui-color-text-0)));
font-size: 15px;
font-weight: 600;
line-height: 1.5714;
}
.table-toolbar-actions {
display: flex;
align-items: center;
justify-content: flex-end;
flex-wrap: wrap;
gap: 8px;
margin-inline-start: auto;
}
.console-page .table-toolbar .ant-btn:not(.ant-btn-link):not(.ant-btn-text) {
min-height: var(--console-control-height);
font-size: 14px;
}
.console-list-toolbar .console-list-actions-offset {
margin-inline-start: 20px;
min-width: 0;
}
@media (max-width: 767px) {
.console-list-toolbar .console-list-actions-offset {
flex-basis: calc(100% - 20px);
}
}