模拟回放

This commit is contained in:
谢思 2023-02-20 10:00:28 +08:00
parent 4dbad9644c
commit 5b2788c596
2 changed files with 36 additions and 3 deletions

View File

@ -139,6 +139,11 @@ function Introduce({ form, match, history, current_user }) {
type: "play"
}).then(response=>{
if(response && response.code ==="000"){
if(response.result.error){
message.error(response.result.error);
setSimulateUploading(false);
return
}
setTimeout(() => { window.open(response.result.live_url);})
}
setSimulateUploading(false);

View File

@ -24,6 +24,8 @@ function Introduce(props) {
const [recordDetail1, setRecordDetail1] = useState(undefined);
const [recordDetail2, setRecordDetail2] = useState(undefined);
const [recordDetail3, setRecordDetail3] = useState(undefined);
const [simulateIndex, setSimulateIndex] = useState(undefined);
const [simulateUploading, setSimulateUploading] = useState(false);
useEffect(()=>{
simulatedMatchList({
@ -134,7 +136,7 @@ function Introduce(props) {
dataIndex: 'status',
key: 2,
render: (text, record, index) => {
return text === 'finished' ? <Tag color="#87d068">已完成</Tag> : text === "running" ? <Tag color="volcano">运行中</Tag> : <Tag color="#f50">未完成</Tag>
return text === 'finished' ? <Tag color="#87d068">已完成</Tag> : text === "running" ? <Tag color="volcano">运行中</Tag> : text === "failed" ? <Tag color="red">&nbsp;&nbsp;</Tag> : <Tag color="#f50">未完成</Tag>
}
},
{
@ -142,6 +144,9 @@ function Introduce(props) {
dataIndex: 'score',
key: 3,
align: 'center',
render: (text) => {
return text || '--'
}
},
{
title: '操作',
@ -151,7 +156,7 @@ function Introduce(props) {
render: (text, record, index) => {
return <Fragment>
<Button onClick={()=>{gradeDetail(text)}} disabled={record.status !== "finished"}>查看详情</Button>
<Button className="ml20" onClick={()=>{analogPlayback(text)}}>模拟回放</Button>
<Button className="ml20" onClick={()=>{analogPlayback(text)}} disabled={record.status !== "finished"} loading={(simulateIndex === text) && simulateUploading}>模拟回放</Button>
</Fragment>
}
},
@ -246,13 +251,36 @@ function Introduce(props) {
//
function analogPlayback(id){
setSimulateIndex(id);
setSimulateUploading(true);
matchReplay({
index: repoId,
user_id: user_id+"",
match_id: id,
sign: encryptionuserId(user_id)
}).then(res=>{
console.log('res', res);
if(res && res.code === "000"){
generateVirtualliveRoomkey({
id: user_id+"",
match_id: id,
index: repoId,
sign: encryptionuserId(user_id),
type: "replay"
}).then(response=>{
if(response && response.code ==="000"){
if(response.result.error){
message.error(response.result.error);
setSimulateUploading(false);
return
}
setTimeout(() => { window.open(response.result.live_url);})
}
setSimulateUploading(false);
})
}else{
setSimulateUploading(false);
message.error(res.msg);
}
})
}