fix;优化

This commit is contained in:
uiuJun 2025-07-31 14:28:57 +08:00
parent ea64f4a95d
commit 63f0756678
5 changed files with 65 additions and 50 deletions

View File

@ -12,4 +12,5 @@ export default function MyTag({
if (!item) return <>-</>; if (!item) return <>-</>;
console.log('item', value, item); console.log('item', value, item);
return <Tag color={item.color}>{item.text}</Tag>; return <Tag color={item.color}>{item.text}</Tag>;
// return <Tag color={item.color}>{item.text}</Tag>;
} }

View File

@ -1,9 +1,8 @@
import React from 'react'; import { PlusOutlined, SettingOutlined, UserOutlined } from '@ant-design/icons';
import { Button, Card, Space, Divider } from 'antd'; import { history } from '@umijs/max';
import { PlusOutlined, UserOutlined, SettingOutlined } from '@ant-design/icons'; import { Button, Card, Divider, Space } from 'antd';
import { MyPageContainer } from './MyPageContainer'; import { MyPageContainer } from './MyPageContainer';
import { usePageTabs } from './usePageTabs'; import { usePageTabs } from './usePageTabs';
import { history } from '@umijs/max';
/** /**
* 使 * 使
@ -12,7 +11,7 @@ import { history } from '@umijs/max';
export function TabsExample() { export function TabsExample() {
const tabsApi = usePageTabs({ const tabsApi = usePageTabs({
tabKey: 'tabs-example', tabKey: 'tabs-example',
tabLabel: '标签页示例' tabLabel: '标签页示例',
}); });
const handleAddTab = (key: string, label: string, path: string) => { const handleAddTab = (key: string, label: string, path: string) => {
@ -20,7 +19,7 @@ export function TabsExample() {
key, key,
label, label,
path, path,
closable: true closable: true,
}); });
history.push(path); history.push(path);
}; };
@ -44,7 +43,9 @@ export function TabsExample() {
<Button <Button
icon={<UserOutlined />} icon={<UserOutlined />}
onClick={() => handleAddTab('user-profile', '用户详情', '/users/profile')} onClick={() =>
handleAddTab('user-profile', '用户详情', '/users/profile')
}
> >
</Button> </Button>
@ -60,21 +61,13 @@ export function TabsExample() {
<Divider /> <Divider />
<Space wrap> <Space wrap>
<Button onClick={() => tabsApi.closeOtherTabs()}> <Button onClick={() => tabsApi.closeOtherTabs()}></Button>
</Button>
<Button onClick={() => tabsApi.closeLeftTabs()}> <Button onClick={() => tabsApi.closeLeftTabs()}></Button>
</Button>
<Button onClick={() => tabsApi.closeRightTabs()}> <Button onClick={() => tabsApi.closeRightTabs()}></Button>
</Button>
<Button onClick={() => tabsApi.refreshTab()}> <Button onClick={() => tabsApi.refreshTab()}></Button>
</Button>
</Space> </Space>
</Card> </Card>
@ -82,24 +75,48 @@ export function TabsExample() {
<div style={{ lineHeight: '1.8' }}> <div style={{ lineHeight: '1.8' }}>
<h4>🎯 </h4> <h4>🎯 </h4>
<ul> <ul>
<li><strong></strong></li> <li>
<li><strong></strong></li> <strong></strong>
<li><strong></strong></li> </li>
<li><strong></strong></li> <li>
<strong></strong>
</li>
<li>
<strong></strong>
</li>
<li>
<strong></strong>
</li>
</ul> </ul>
<h4>🖱 </h4> <h4>🖱 </h4>
<ul> <ul>
<li><strong></strong></li> <li>
<li><strong></strong></li> <strong></strong>
<li><strong></strong></li> </li>
<li><strong></strong></li> <li>
<li><strong></strong></li> <strong></strong>
</li>
<li>
<strong></strong>
</li>
<li>
<strong></strong>
</li>
<li>
<strong></strong>
</li>
</ul> </ul>
<h4>💻 使</h4> <h4>💻 使</h4>
<pre style={{ background: '#f5f5f5', padding: '12px', borderRadius: '4px' }}> <pre
{`// 1. 在页面组件中使用 style={{
background: '#f5f5f5',
padding: '12px',
borderRadius: '4px',
}}
>
{`// 1. 在页面组件中使用
import { MyPageContainer, usePageTabs } from '@/common'; import { MyPageContainer, usePageTabs } from '@/common';
function YourPage() { function YourPage() {

View File

@ -154,12 +154,13 @@ export const MyColumns = {
EnumTag({ ...rest }: ReturnType): ReturnType { EnumTag({ ...rest }: ReturnType): ReturnType {
return { return {
align: 'left', align: 'left',
renderText(text: string | number) { renderText(text: any) {
const _enum = rest.valueEnum ?? {}; const _enum: any = rest?.valueEnum ?? {};
if (!_enum) return <>-</>; if (!_enum) return <>-</>;
const item = _enum[text] ?? undefined; const item = _enum[text] ?? undefined;
if (!item) return <>-</>; if (!item) return <>-</>;
return <Tag style={{ color: item?.color }}>{item.text}</Tag>; return <Tag>{item.text}</Tag>;
// return <Tag style={{ color: item?.color }}>{item.text}</Tag>;
//修改列表的标签样式 //修改列表的标签样式
}, },
...rest, ...rest,

View File

@ -27,11 +27,7 @@ export const renderTextHelper = {
let item: any = Object.values(Enums).find((data: any) => { let item: any = Object.values(Enums).find((data: any) => {
return data.value === '' + value; return data.value === '' + value;
}); });
return isColor ? ( return isColor ? <Tag>{item?.text}</Tag> : <>{item?.text}</>;
<Tag style={{ color: item?.color }}>{item?.text}</Tag>
) : (
<>{item?.text}</>
);
// return <Tag style={{ color: item.color }}>{item.text}</Tag>; // return <Tag style={{ color: item.color }}>{item.text}</Tag>;
}, },
Images(images: string[]) { Images(images: string[]) {

View File

@ -60,7 +60,7 @@ export default function ReceiptAccounts(props: MyBetaModalFormProps) {
return `${record?.is_default ? '是' : '否'} `; return `${record?.is_default ? '是' : '否'} `;
}, },
}, },
// MyColumns.UpdatedAt(), MyColumns.UpdatedAt(),
// MyColumns.CreatedAt(), // MyColumns.CreatedAt(),
MyColumns.Option({ MyColumns.Option({
render: (_, item: any, index, action) => ( render: (_, item: any, index, action) => (