更改标签展示

This commit is contained in:
kilo5hz 2022-01-06 15:59:58 +08:00
parent 133481053e
commit 1eb8e263f7

View File

@ -11,6 +11,7 @@ import {
Menu, Menu,
Typography, Typography,
Input, Input,
Popover,
} from 'antd'; } from 'antd';
import { import {
ClockCircleOutlined, ClockCircleOutlined,
@ -30,7 +31,7 @@ import {
import config from '@/utils/config'; import config from '@/utils/config';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { request } from '@/utils/http'; import { request } from '@/utils/http';
import CronModal,{CronLabelModal} from './modal'; import CronModal,{ CronLabelModal } from './modal';
import CronLogModal from './logModal'; import CronLogModal from './logModal';
import cron_parser from 'cron-parser'; import cron_parser from 'cron-parser';
import { diffTime } from '@/utils/date'; import { diffTime } from '@/utils/date';
@ -77,20 +78,39 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
width: 150, width: 150,
align: 'center' as const, align: 'center' as const,
render: (text: string, record: any) => ( render: (text: string, record: any) => (
<a <>
onClick={() => { <a
goToScriptManager(record); onClick={() => {
}} goToScriptManager(record);
> }}
{record.name || record._id}{' '} >
{record.isPinned ? ( {record.name || record._id}{' '}
<span> {record.isPinned ? (
<PushpinOutlined /> <span>
</span> <PushpinOutlined />
) : ( </span>
'' ) : (
)} ''
</a> )}
</a>
<span>
{record.labels?.length > 0 && record.labels[0] !== '' ?
<Popover placement='right' trigger={isPhone ? 'click' : 'hover'}
content={
<div>
{record.labels?.map((label: string, i: number) => (
<Tag color="blue"
onClick={() => { onSearch(`label:${label}`) }}>
{label}
</Tag>
))}
</div>
}>
<Tag color="blue">{record.labels[0]}</Tag>
</Popover>
: ''}
</span>
</>
), ),
sorter: { sorter: {
compare: (a: any, b: any) => a.name.localeCompare(b.name), compare: (a: any, b: any) => a.name.localeCompare(b.name),
@ -275,26 +295,6 @@ const Crontab = ({ headerStyle, isPhone }: any) => {
</> </>
), ),
}, },
{
title: '标签',
key: 'labels',
dataIndex: 'labels',
align: 'center' as const,
width: 100,
render: (text: string, record: any) => (
<>
{record.labels?.map((label: string) => (
<Tag style={{
width: label.replace(/[^\x00-\xff]/g,"01").length < 5 ? 40:90,
overflow:'hidden',
textOverflow:'ellipsis',
}}
color="blue"
onClick={() => { onSearch(`label:${label}`) }}>{label}</Tag>
))}
</>
),
},
{ {
title: '操作', title: '操作',
key: 'action', key: 'action',