💥 feat(模块): copy提示
This commit is contained in:
@ -1,10 +1,12 @@
|
|||||||
import type { ActionType, ProColumns, ProFormInstance } from '@ant-design/pro-components';
|
import type { ActionType, ProColumns, ProFormInstance } from '@ant-design/pro-components';
|
||||||
import { ModalForm, PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
|
import { ModalForm, PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
|
||||||
|
import { message, Typography } from 'antd';
|
||||||
import '@umijs/max';
|
import '@umijs/max';
|
||||||
import { Select } from 'antd';
|
import { Select } from 'antd';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import React, { useRef, useState } from 'react';
|
import React, { useCallback, useRef, useState } from 'react';
|
||||||
|
|
||||||
|
const { Text } = Typography;
|
||||||
import { TIME_FORMAT } from '@/constants/global';
|
import { TIME_FORMAT } from '@/constants/global';
|
||||||
import { getPublisherList, updatePublisherInfo } from '@/services/list';
|
import { getPublisherList, updatePublisherInfo } from '@/services/list';
|
||||||
|
|
||||||
@ -35,12 +37,37 @@ const PRIORITY_OPTIONS = [
|
|||||||
{ label: '正常处理', value: 2 },
|
{ label: '正常处理', value: 2 },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
const COPY_TIMES = '__copy_times__';
|
||||||
|
const COPY_EXP = '__copy_exp__';
|
||||||
const TableList: React.FC = () => {
|
const TableList: React.FC = () => {
|
||||||
const [updateModalOpen, handleUpdateModalOpen] = useState<boolean>(false);
|
const [updateModalOpen, handleUpdateModalOpen] = useState<boolean>(false);
|
||||||
const [currentRow, setCurrentRow] = useState<API.PublisherListItem>();
|
const [currentRow, setCurrentRow] = useState<API.PublisherListItem>();
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
const formRef = useRef<ProFormInstance>();
|
const formRef = useRef<ProFormInstance>();
|
||||||
|
|
||||||
|
const handleCopy = useCallback(() => {
|
||||||
|
const storedTimes = localStorage.getItem(COPY_TIMES);
|
||||||
|
const copyExp = localStorage.getItem(COPY_EXP);
|
||||||
|
|
||||||
|
const now = Date.now();
|
||||||
|
let currentTimes = 0;
|
||||||
|
|
||||||
|
if (!copyExp || now >= parseInt(copyExp, 10)) {
|
||||||
|
currentTimes = 1;
|
||||||
|
|
||||||
|
const tomorrow = new Date();
|
||||||
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||||
|
tomorrow.setHours(0, 0, 0, 0);
|
||||||
|
|
||||||
|
localStorage.setItem(COPY_EXP, tomorrow.getTime().toString());
|
||||||
|
} else {
|
||||||
|
currentTimes = parseInt(storedTimes || '0', 10) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
localStorage.setItem(COPY_TIMES, `${currentTimes}`);
|
||||||
|
message.success(`今天已复制${currentTimes}次`);
|
||||||
|
}, []);
|
||||||
|
|
||||||
const columns: ProColumns<API.PublisherListItem>[] = [
|
const columns: ProColumns<API.PublisherListItem>[] = [
|
||||||
{
|
{
|
||||||
title: '发布人昵称',
|
title: '发布人昵称',
|
||||||
@ -52,7 +79,17 @@ const TableList: React.FC = () => {
|
|||||||
title: '发布人ID',
|
title: '发布人ID',
|
||||||
dataIndex: 'blPublisherId',
|
dataIndex: 'blPublisherId',
|
||||||
valueType: 'textarea',
|
valueType: 'textarea',
|
||||||
copyable: true,
|
render(blPublisherId) {
|
||||||
|
return (
|
||||||
|
<Text
|
||||||
|
copyable={{
|
||||||
|
onCopy: handleCopy,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{blPublisherId}
|
||||||
|
</Text>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '优先级',
|
title: '优先级',
|
||||||
|
|||||||
Reference in New Issue
Block a user