代码优化

This commit is contained in:
vance 2022-08-16 14:46:04 +08:00
parent afcaddcc0f
commit d13aab8aa4
10 changed files with 58 additions and 95 deletions

View File

@ -6,7 +6,7 @@ import {
getOldUserData,
getTodayUserData,
getWeekUserData,
} from '@/services/DataBorad/activeanalysis';
} from '@/services/dataBorad/activeanalysis';
import MoreData from '@/pages/DataBoard/ActiveAnalysis/List/components/MoreData';
import ReactEcharts from 'echarts-for-react';
import { Card, Col, Row, Select } from 'antd';
@ -75,7 +75,7 @@ const ActiveAnalysis: React.FC = () => {
<Card style={{ width: '100%' }}>
<Row gutter={32} style={{ marginBottom: 10 }}>
<Col span={6}>
<h1>DAU</h1>
<h1></h1>
<Select
defaultValue="lucy"
value={timeType}

View File

@ -9,18 +9,12 @@ import {
getTodayUserData,
getMonthPayData,
getNewUserData,
} from '@/services/DataBorad/coredata';
} from '@/services/dataBorad/coredata';
import MoreData from '@/pages/DataBoard/ActiveAnalysis/List/components/MoreData';
import { Card, Col, Row, DatePicker, Select } from 'antd';
import { Card, Col, Row, Select } from 'antd';
const CoreData: React.FC = () => {
const tableRef = useRef<ActionType>();
const [startTimeValue, setStartTimeValue] = useState(Number);
const [endTimeValue, setEndTimeValue] = useState(Number);
const [timeType, setTimeType] = useState(TimeType.DAY);
const getTimedata = (data: any) => {
setStartTimeValue(moment(data[0]).valueOf());
setEndTimeValue(moment(data[1]).valueOf());
};
// const [date, setDate] = useState(getData);
const [userDate, setUserDate] = useState(getData(getTodayUserData));
@ -60,18 +54,16 @@ const CoreData: React.FC = () => {
{
title: '日期',
dataIndex: 'time',
hideInSearch: true,
width: '10%',
renderFormItem: (item, { type, defaultRender, ...rest }, form) => {
return (
<DatePicker.RangePicker
style={{ width: '300px' }}
format={'YYYY-MM-DD'}
onChange={(vaw: any) => {
getTimedata(vaw);
}}
/>
);
},
},
{
title: '时间',
dataIndex: 'select_time',
valueType: 'dateRange',
width: '20%',
hideInTable: true,
ellipsis: true,
},
{
title: '活跃用户数',
@ -139,8 +131,10 @@ const CoreData: React.FC = () => {
rowKey="id"
actionRef={tableRef}
request={async (params) => {
params.start_time = startTimeValue;
params.end_time = endTimeValue;
if ((params.select_time ?? '') !== '') {
params.start_time = moment(params.select_time[0]).valueOf() / 1000;
params.end_time = moment(params.select_time[1]).valueOf() / 1000;
}
return getCoreData(params);
}}
/>

View File

@ -6,13 +6,7 @@ import moment from 'moment';
import TimeType from '@/constants/enum/timeType';
const Address: React.FC = () => {
const tableRef = useRef<ActionType>();
const [startTimeValue, setStartTimeValue] = useState(Number);
const [endTimeValue, setEndTimeValue] = useState(Number);
const [timeType, setTimeType] = useState(TimeType.DAY);
const getTimedata = (data: any) => {
setStartTimeValue(moment(data[0]).valueOf());
setEndTimeValue(moment(data[1]).valueOf());
};
const columns: ProColumns<any>[] = [
{
@ -55,17 +49,14 @@ const Address: React.FC = () => {
dataIndex: 'timeData',
hideInTable: true,
width: '20%',
renderFormItem: (item, { type, defaultRender, ...rest }, form) => {
return (
<DatePicker.RangePicker
style={{ width: '300px' }}
format={'YYYY-MM-DD'}
onChange={(vaw: any) => {
getTimedata(vaw);
}}
/>
);
},
},
{
title: '时间',
dataIndex: 'select_time',
valueType: 'dateRange',
width: '20%',
hideInTable: true,
ellipsis: true,
},
{
title: '付费次数',
@ -112,12 +103,10 @@ const Address: React.FC = () => {
actionRef={tableRef}
// search={false}
request={async (params) => {
console.log(params);
params.start_time = startTimeValue;
params.end_time = endTimeValue;
console.log(params.data.timeData);
console.log(params.time_type);
if ((params.select_time ?? '') !== '') {
params.start_time = moment(params.select_time[0]).valueOf() / 1000;
params.end_time = moment(params.select_time[1]).valueOf() / 1000;
}
return getRententionData(params);
}}
/>

View File

@ -3,7 +3,7 @@ import Modal, { ModalProps } from '@/components/Modal';
import { fetchTableData } from '@/utils/table';
import Table, { ProColumns, ActionType } from '@/components/Table';
import TimeText from '@/components/Typography/TimeText';
import { getChannelData } from '@/services/DataBorad/retentionAnalysis';
import { getChannelData } from '@/services/dataBorad/retentionAnalysis';
interface TableModalPropsType extends ModalProps {
modalData: any;

View File

@ -3,21 +3,12 @@ import Table, { ProColumns, ActionType } from '@/components/Table';
import { DatePicker } from 'antd';
import moment from 'moment';
import { fetchTableData } from '@/utils/table';
import { getRententionData } from '@/services/DataBorad/retentionAnalysis';
import { getRententionData } from '@/services/dataBorad/retentionAnalysis';
import TableModal from '@/pages/DataBoard/RetentionAnalysis/List/components/TableModal';
const RetentionAnalysis = () => {
const [startTimeValue, setStartTimeValue] = useState(Number);
const [endTimeValue, setEndTimeValue] = useState(Number);
const [visible, setVisible] = useState(false);
const [requestData, setRequestData] = useState();
const getTimedata = (data) => {
setStartTimeValue(moment(data[0]).valueOf());
setEndTimeValue(moment(data[1]).valueOf());
console.log(startTimeValue, endTimeValue);
console.log(visible);
};
const sendData = (row: any) => {
setVisible(true);
setRequestData(row.time);
@ -28,17 +19,14 @@ const RetentionAnalysis = () => {
{
title: '时间',
dataIndex: 'time',
// width: '20%',
renderFormItem: (item, { type, defaultRender, ...rest }, form) => {
return (
<DatePicker.RangePicker
value={requestData}
style={{ width: '200px' }}
format={'YYYY-MM-DD'}
onChange={getTimedata}
/>
);
},
},
{
title: '时间',
dataIndex: 'select_time',
valueType: 'dateRange',
width: '20%',
hideInTable: true,
ellipsis: true,
},
{
title: '登录用户数',
@ -99,8 +87,10 @@ const RetentionAnalysis = () => {
rowKey="id"
actionRef={tableRef}
request={async (params) => {
params.start_time = startTimeValue;
params.end_time = endTimeValue;
if ((params.select_time ?? '') !== '') {
params.start_time = moment(params.select_time[0]).valueOf() / 1000;
params.end_time = moment(params.select_time[1]).valueOf() / 1000;
}
return await fetchTableData(getRententionData, params);
}}
/>

View File

@ -49,7 +49,7 @@ const AddNftContractModal = ({ onOk, onCancel, ...rest }: AddNftContractModalPro
/>
<SchemaField.Number
name="description"
title="gas费"
title=""
required
x-decorator="FormItem"
x-component="NumberPicker"

View File

@ -37,13 +37,6 @@ const Address: React.FC = () => {
rowKey="id"
actionRef={tableRef}
toolBarActions={[
{
type: 'add',
text: '添加NFT',
onConfirm: () => {
setVisible(true);
},
},
{
type: 'add',
text: '新建NFT合约',

View File

@ -3,13 +3,14 @@ import Table, { ProColumns, ActionType } from '@/components/Table';
import { message } from 'antd';
// import { fetchTableData } from '@/utils/table';
// import AddNftModal from '@/pages/Nft/NftToken/List/components/AddNftModel';
import AddNftModal from '@/pages/Nft/NftToken/List/components/AddNftModel';
import PaySelectModal from '@/widget/Work/PaySelectModal';
const Address: React.FC = () => {
const tableRef = useRef<ActionType>();
const [NftModal, setNftModal] = useState(false);
const [visible, setVisible] = useState(false);
const [payVisible, setPayVisible] = useState(false);
const columns: ProColumns<any>[] = [
{
@ -58,7 +59,7 @@ const Address: React.FC = () => {
// // return fetchTableData(, params);
// }}
/>
{/* <AddNftModal
<AddNftModal
visible={visible}
onCancel={function () {
setVisible(false);
@ -74,9 +75,9 @@ const Address: React.FC = () => {
setVisible(false);
}
}}
/> */}
/>
<PaySelectModal
visible={visible}
visible={payVisible}
onCancel={function () {
setVisible(false);
}}

View File

@ -22,7 +22,6 @@ export async function initWeb3() {
const accounts = await provider.request({
method: 'eth_requestAccounts',
});
//如果用户同意了登录请求,你就可以拿到用户的账号
web3.eth.defaultAccount = accounts[0];
return true;
} catch (reason) {

View File

@ -49,18 +49,15 @@ const PaySelectModal = ({ onOk, onCancel, ...rest }: PaySelectModalPropsType) =>
{ label: '小狐狸钱包支付', value: 2 },
]}
/>
{send == true && (
<SchemaField.String
name="key"
title="秘钥"
x-decorator="FormItem"
x-component="Input"
x-component-props={{
placeholder: '请输入秘钥,若使用小狐狸支付则不需要输入',
}}
/>
)}
<SchemaField.String
name="key"
title="秘钥"
x-decorator="FormItem"
x-component="Input"
x-component-props={{
placeholder: '请输入秘钥,若使用小狐狸支付则不需要输入',
}}
/>
</SchemaField>
</Form>
</Modal>