|
|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
|
import { Card, Row, Col, Statistic, Button, Select, Tag, message, Spin, Alert } from 'antd';
|
|
|
|
|
import { ReloadOutlined, ArrowUpOutlined, ArrowDownOutlined, FireOutlined, AlertOutlined, RobotOutlined } from '@ant-design/icons';
|
|
|
|
|
import { Card, Row, Col, Statistic, Button, Select, Tag, message, Spin, Alert, Modal, Form, InputNumber, Switch, Checkbox } from 'antd';
|
|
|
|
|
import { ReloadOutlined, ArrowUpOutlined, ArrowDownOutlined, FireOutlined, AlertOutlined, RobotOutlined, BellOutlined } from '@ant-design/icons';
|
|
|
|
|
import { fetchFuturesOverview, fetchRiskAlerts, fetchAIMarketAnalysis, toggleWatchlist } from '../../store/futuresSlice';
|
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
|
import './Dashboard.css';
|
|
|
|
|
|
|
|
|
|
const { Option } = Select;
|
|
|
|
|
const { Item } = Form;
|
|
|
|
|
|
|
|
|
|
const Dashboard = () => {
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
@ -14,6 +15,9 @@ const Dashboard = () => {
|
|
|
|
|
const { overview, riskAlerts, aiAnalysis, loading } = useSelector(state => state.futures);
|
|
|
|
|
const [filterType, setFilterType] = useState('all');
|
|
|
|
|
const [sortBy, setSortBy] = useState('winRate');
|
|
|
|
|
const [pushModalVisible, setPushModalVisible] = useState(false);
|
|
|
|
|
const [currentFuture, setCurrentFuture] = useState(null);
|
|
|
|
|
const [pushForm] = Form.useForm();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
dispatch(fetchFuturesOverview());
|
|
|
|
|
@ -38,6 +42,19 @@ const Dashboard = () => {
|
|
|
|
|
message.success(future.isInWatchlist ? '已从自选移除' : '已添加到自选');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const openPushConfig = (future, e) => {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
setCurrentFuture(future);
|
|
|
|
|
setPushModalVisible(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const savePushConfig = (values) => {
|
|
|
|
|
console.log('消息推送配置保存:', values);
|
|
|
|
|
// 模拟保存操作
|
|
|
|
|
setPushModalVisible(false);
|
|
|
|
|
message.success('消息推送配置已保存');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getChangeColor = (changePercent) => {
|
|
|
|
|
return changePercent >= 0 ? '#52c41a' : '#ff4d4f';
|
|
|
|
|
};
|
|
|
|
|
@ -310,11 +327,148 @@ const Dashboard = () => {
|
|
|
|
|
>
|
|
|
|
|
{item.isInWatchlist ? '已添加' : '添加自选'}
|
|
|
|
|
</Button>
|
|
|
|
|
<Button
|
|
|
|
|
type="default"
|
|
|
|
|
className="push-button-new"
|
|
|
|
|
icon={<BellOutlined />}
|
|
|
|
|
onClick={(e) => openPushConfig(item, e)}
|
|
|
|
|
>
|
|
|
|
|
消息推送
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
</Col>
|
|
|
|
|
))}
|
|
|
|
|
</Row>
|
|
|
|
|
|
|
|
|
|
{/* 消息推送配置模态框 */}
|
|
|
|
|
<Modal
|
|
|
|
|
title={`${currentFuture?.name || '合约'}消息推送配置`}
|
|
|
|
|
open={pushModalVisible}
|
|
|
|
|
onCancel={() => setPushModalVisible(false)}
|
|
|
|
|
width={800}
|
|
|
|
|
footer={[
|
|
|
|
|
<Button key="cancel" onClick={() => setPushModalVisible(false)}>
|
|
|
|
|
取消
|
|
|
|
|
</Button>,
|
|
|
|
|
<Button key="save" type="primary" onClick={() => pushForm.submit()}>
|
|
|
|
|
保存配置
|
|
|
|
|
</Button>
|
|
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<Form
|
|
|
|
|
form={pushForm}
|
|
|
|
|
layout="vertical"
|
|
|
|
|
onFinish={savePushConfig}
|
|
|
|
|
initialValues={{
|
|
|
|
|
pushMethods: ['email'],
|
|
|
|
|
alertTiming: 'price',
|
|
|
|
|
priceAlert: true,
|
|
|
|
|
priceLevel: 0,
|
|
|
|
|
trendChange: true,
|
|
|
|
|
riskAlert: true,
|
|
|
|
|
aiSignal: true
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{/* 推送方式 */}
|
|
|
|
|
<Card title="推送方式" style={{ marginBottom: 16 }}>
|
|
|
|
|
<Row gutter={[16, 16]}>
|
|
|
|
|
<Col span={8}>
|
|
|
|
|
<Item label="邮箱" name="emailPush" valuePropName="checked">
|
|
|
|
|
<Switch />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={8}>
|
|
|
|
|
<Item label="微信" name="wechatPush" valuePropName="checked">
|
|
|
|
|
<Switch />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={8}>
|
|
|
|
|
<Item label="钉钉" name="dingtalkPush" valuePropName="checked">
|
|
|
|
|
<Switch />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
{/* 提醒时机 */}
|
|
|
|
|
<Card title="提醒时机" style={{ marginBottom: 16 }}>
|
|
|
|
|
<Row gutter={[16, 16]}>
|
|
|
|
|
<Col span={24}>
|
|
|
|
|
<Item label="提醒类型" name="alertTiming">
|
|
|
|
|
<Select>
|
|
|
|
|
<Option value="price">价格点位提醒</Option>
|
|
|
|
|
<Option value="trend">趋势变化提醒</Option>
|
|
|
|
|
<Option value="risk">风险预警提醒</Option>
|
|
|
|
|
<Option value="ai">AI信号提醒</Option>
|
|
|
|
|
</Select>
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
<Item label="价格点位" name="priceLevel">
|
|
|
|
|
<InputNumber
|
|
|
|
|
min={0}
|
|
|
|
|
step={10}
|
|
|
|
|
placeholder="请输入价格点位"
|
|
|
|
|
/>
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
<Item label="波动幅度(%)" name="priceChange">
|
|
|
|
|
<InputNumber
|
|
|
|
|
min={0.1}
|
|
|
|
|
max={10}
|
|
|
|
|
step={0.1}
|
|
|
|
|
placeholder="请输入波动幅度"
|
|
|
|
|
/>
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
{/* 推送内容 */}
|
|
|
|
|
<Card title="推送内容" style={{ marginBottom: 16 }}>
|
|
|
|
|
<Row gutter={[16, 8]}>
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
<Item label="价格变动" name="priceAlert" valuePropName="checked">
|
|
|
|
|
<Switch defaultChecked />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
<Item label="趋势变化" name="trendChange" valuePropName="checked">
|
|
|
|
|
<Switch defaultChecked />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
<Item label="风险预警" name="riskAlert" valuePropName="checked">
|
|
|
|
|
<Switch defaultChecked />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
<Item label="AI信号" name="aiSignal" valuePropName="checked">
|
|
|
|
|
<Switch defaultChecked />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
|
|
{/* 高级配置 */}
|
|
|
|
|
<Card title="高级配置" style={{ marginBottom: 16 }}>
|
|
|
|
|
<Row gutter={[16, 16]}>
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
<Item label="推送频率限制(分钟)" name="pushInterval">
|
|
|
|
|
<InputNumber min={1} max={60} step={1} defaultValue={5} />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col span={12}>
|
|
|
|
|
<Item label="静默时间(小时)" name="quietHours">
|
|
|
|
|
<InputNumber min={0} max={24} step={1} defaultValue={0} />
|
|
|
|
|
</Item>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
</Card>
|
|
|
|
|
</Form>
|
|
|
|
|
</Modal>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|