feat(react-web-next): 新增.editorconfig和.prettierrc配置文件,添加public/.gitkeep占位文件
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import React from 'react';
|
||||
|
||||
/**
|
||||
* 页面动作栏容器:统一按钮间距、两侧分布布局。
|
||||
* - left: 左侧节点(常放主要操作)
|
||||
* - right: 右侧节点(常放过滤器、视图切换等)
|
||||
*/
|
||||
export interface ActionBarProps {
|
||||
left?: React.ReactNode;
|
||||
right?: React.ReactNode;
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const ActionBar: React.FC<ActionBarProps> = ({ left, right, style, className }) => {
|
||||
return (
|
||||
<div
|
||||
className={["gf-action-bar", className].filter(Boolean).join(' ')}
|
||||
style={style}
|
||||
>
|
||||
<div className="gf-action-bar-left">{left}</div>
|
||||
<div className="gf-action-bar-right">{right}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ActionBar;
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
import React from 'react';
|
||||
import { Card } from 'antd';
|
||||
import type { CardProps } from 'antd';
|
||||
|
||||
/**
|
||||
* 玻璃质感卡片:在 Antd Card 基础上增加统一的现代化样式。
|
||||
*/
|
||||
const GlassCard: React.FC<CardProps> = ({ className, children, ...rest }) => {
|
||||
const cls = ['modern-card', className].filter(Boolean).join(' ');
|
||||
return (
|
||||
<Card className={cls} {...rest}>
|
||||
{children}
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
|
||||
export default GlassCard;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import React from 'react';
|
||||
import { Button } from 'antd';
|
||||
import type { ButtonProps } from 'antd';
|
||||
|
||||
/**
|
||||
* 渐变主按钮:在 Antd Button 基础上提供更亮丽的渐变样式。
|
||||
* - 默认 type=primary,支持透传所有 ButtonProps。
|
||||
* - 通过 className="gf-gradient-btn" 统一样式,也可与 ghost/danger 等属性叠加。
|
||||
*/
|
||||
const GradientButton: React.FC<ButtonProps> = ({ className, type = 'primary', children, ...rest }) => {
|
||||
const cls = ['gf-gradient-btn', className].filter(Boolean).join(' ');
|
||||
return (
|
||||
<Button type={type} className={cls} {...rest}>
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default GradientButton;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import React from 'react';
|
||||
import { Statistic } from 'antd';
|
||||
|
||||
export interface KPIStatProps {
|
||||
title: React.ReactNode;
|
||||
value: number | string;
|
||||
suffix?: React.ReactNode;
|
||||
color?: string; // 左侧高亮条与图标色
|
||||
icon?: React.ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* KPIStat:统一的指标卡片内容块,建议搭配 GlassCard 使用。
|
||||
*/
|
||||
const KPIStat: React.FC<KPIStatProps> = ({ title, value, suffix, color = '#667eea', icon }) => {
|
||||
return (
|
||||
<div style={{ textAlign: 'center', borderLeft: `4px solid ${color}`, background: 'var(--bg-card)' }}>
|
||||
<div style={{ color, fontSize: 24, marginBottom: 8 }}>{icon}</div>
|
||||
<Statistic
|
||||
title={title}
|
||||
value={value}
|
||||
suffix={suffix}
|
||||
valueStyle={{ color: 'var(--text-primary)', fontSize: 28, fontWeight: 'bold' }}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default KPIStat;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import React from 'react';
|
||||
import { PageContainer } from '@ant-design/pro-components';
|
||||
|
||||
/**
|
||||
* PageHeaderPlus:美化后的页面容器。保留 PageContainer 能力,增强标题与背景视觉。
|
||||
*/
|
||||
export interface PageHeaderPlusProps {
|
||||
title?: React.ReactNode;
|
||||
subTitle?: React.ReactNode;
|
||||
extra?: React.ReactNode;
|
||||
children?: React.ReactNode;
|
||||
}
|
||||
|
||||
const PageHeaderPlus: React.FC<PageHeaderPlusProps> = ({ title, subTitle, extra, children }) => {
|
||||
return (
|
||||
<PageContainer
|
||||
header={{
|
||||
title: (
|
||||
<span
|
||||
style={{
|
||||
color: 'var(--text-primary)',
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</span>
|
||||
),
|
||||
subTitle,
|
||||
}}
|
||||
extra={extra}
|
||||
>
|
||||
{children}
|
||||
</PageContainer>
|
||||
);
|
||||
};
|
||||
|
||||
export default PageHeaderPlus;
|
||||
@@ -0,0 +1,60 @@
|
||||
import React from 'react';
|
||||
import { QueryFilter } from '@ant-design/pro-components';
|
||||
import TenantSelector from '@/components/ui/TenantSelector';
|
||||
import { tenantApi } from '@/services/tenant';
|
||||
|
||||
export interface SearchBarPlusProps {
|
||||
// QueryFilter 透传属性(常用)
|
||||
defaultCollapsed?: boolean;
|
||||
split?: boolean;
|
||||
span?: number | { xs?: number; sm?: number; md?: number; lg?: number; xl?: number; xxl?: number };
|
||||
form?: any;
|
||||
onFinish?: (values: Record<string, any>) => Promise<any> | void;
|
||||
// 子节点:放置各业务查询项(ProForm* 或 Form.Item 均可)
|
||||
children?: React.ReactNode;
|
||||
// 是否显示租户筛选(默认显示)
|
||||
showTenant?: boolean;
|
||||
// 租户变化回调:用于触发表格 reload 等
|
||||
onTenantChanged?: (tenantId: string, includeChildren: boolean) => void;
|
||||
// 租户筛选放置位置:start 放在最前,end 放在最后(默认 start)
|
||||
tenantPosition?: 'start' | 'end';
|
||||
}
|
||||
|
||||
const SearchBarPlus: React.FC<SearchBarPlusProps> = ({
|
||||
defaultCollapsed,
|
||||
split,
|
||||
span,
|
||||
form,
|
||||
onFinish,
|
||||
children,
|
||||
showTenant = true,
|
||||
onTenantChanged,
|
||||
tenantPosition = 'start',
|
||||
}) => {
|
||||
const handleFinish = async (values: Record<string, any>) => {
|
||||
try {
|
||||
if (showTenant && values && values.tenantId) {
|
||||
await tenantApi.switchTenant(values.tenantId);
|
||||
}
|
||||
onTenantChanged?.(values?.tenantId, !!values?.includeChildren);
|
||||
} finally {
|
||||
await onFinish?.(values);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<QueryFilter
|
||||
defaultCollapsed={defaultCollapsed}
|
||||
split={split}
|
||||
span={span as any}
|
||||
form={form}
|
||||
onFinish={handleFinish}
|
||||
>
|
||||
{showTenant && tenantPosition === 'start' ? <TenantSelector /> : null}
|
||||
{children}
|
||||
{showTenant && tenantPosition === 'end' ? <TenantSelector /> : null}
|
||||
</QueryFilter>
|
||||
);
|
||||
};
|
||||
|
||||
export default SearchBarPlus;
|
||||
@@ -0,0 +1,64 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Form, TreeSelect, Checkbox } from 'antd';
|
||||
import { tenantApi, TenantTreeNode } from '@/services/tenant';
|
||||
|
||||
export interface TenantSelectorProps {
|
||||
// 字段名可自定义;默认与后端接口约定一致
|
||||
nameTenant?: string; // 默认 'tenantId'
|
||||
nameIncludeChildren?: string; // 默认 'includeChildren'
|
||||
labelTenant?: React.ReactNode;
|
||||
labelIncludeChildren?: React.ReactNode;
|
||||
}
|
||||
|
||||
const toTreeData = (nodes: TenantTreeNode[] = []): any[] =>
|
||||
nodes.map((n) => ({
|
||||
title: n.tenantName,
|
||||
value: n.tenantId,
|
||||
key: n.tenantId,
|
||||
children: n.children ? toTreeData(n.children) : undefined,
|
||||
}));
|
||||
|
||||
const TenantSelector: React.FC<TenantSelectorProps> = ({
|
||||
nameTenant = 'tenantId',
|
||||
nameIncludeChildren = 'includeChildren',
|
||||
labelTenant = '租户',
|
||||
labelIncludeChildren = '包含子租户',
|
||||
}) => {
|
||||
const [tree, setTree] = useState<TenantTreeNode[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const [treeRes] = await Promise.all([
|
||||
tenantApi.getAccessibleTenants(),
|
||||
]);
|
||||
if (treeRes?.success) setTree(treeRes.data || []);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
})();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form.Item name={nameTenant} label={labelTenant}>
|
||||
<TreeSelect
|
||||
style={{ minWidth: 260 }}
|
||||
treeDefaultExpandAll
|
||||
loading={loading}
|
||||
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
||||
placeholder="选择租户(含子租户)"
|
||||
treeData={toTreeData(tree)}
|
||||
allowClear
|
||||
/>
|
||||
</Form.Item>
|
||||
<Form.Item name={nameIncludeChildren} label={labelIncludeChildren} valuePropName="checked" initialValue={true}>
|
||||
<Checkbox>包含子租户</Checkbox>
|
||||
</Form.Item>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default TenantSelector;
|
||||
@@ -0,0 +1,27 @@
|
||||
import React from 'react';
|
||||
import { Button, Tooltip } from 'antd';
|
||||
import { MoonOutlined, SunOutlined } from '@ant-design/icons';
|
||||
import type { ThemeMode } from '@/theme';
|
||||
|
||||
export interface ThemeSwitchProps {
|
||||
mode: ThemeMode;
|
||||
onToggle: () => void;
|
||||
}
|
||||
|
||||
const ThemeSwitch: React.FC<ThemeSwitchProps> = ({ mode, onToggle }) => {
|
||||
return (
|
||||
<Tooltip title={mode === 'dark' ? '切换为亮色' : '切换为暗色'}>
|
||||
<Button
|
||||
type="text"
|
||||
onClick={onToggle}
|
||||
icon={mode === 'dark' ? <SunOutlined /> : <MoonOutlined />}
|
||||
style={{ color: 'var(--text-primary)' }}
|
||||
>
|
||||
{mode === 'dark' ? '亮色' : '暗色'}
|
||||
</Button>
|
||||
</Tooltip>
|
||||
);
|
||||
};
|
||||
|
||||
export default ThemeSwitch;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 210 KiB |
@@ -0,0 +1,7 @@
|
||||
export { default as GradientButton } from './GradientButton';
|
||||
export { default as ActionBar } from './ActionBar';
|
||||
export { default as GlassCard } from './GlassCard';
|
||||
export { default as PageHeaderPlus } from './PageHeaderPlus';
|
||||
export { default as KPIStat } from './KPIStat';
|
||||
export { default as ThemeSwitch } from './ThemeSwitch';
|
||||
export { default as SearchBarPlus } from './SearchBarPlus';
|
||||
Reference in New Issue
Block a user