导出参会记录
This commit is contained in:
parent
86ccca642d
commit
09aaae8274
|
|
@ -41,3 +41,9 @@ export const GetAgoraConf = () =>
|
|||
method: 'get',
|
||||
})
|
||||
|
||||
export const GetRecord = (beginTimestamp: number, endTimestamp: number, roomNum: string) =>
|
||||
request({
|
||||
url: `/home/record?beginTimestamp=${beginTimestamp}&endTimestamp=${endTimestamp}&roomNum=${roomNum}`,
|
||||
method: 'get',
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,21 @@
|
|||
import styles from '@/page/Home/Index/index.module.scss'
|
||||
import { useEffect, useState, useRef } from "react";
|
||||
import Operation from '@/components/Operation';
|
||||
import { Button, Input, Modal, Pagination, Empty, message, Popover, Popconfirm } from "antd";
|
||||
import { GetRoom, PostRoom, GetCheckoutRoomNum, GetRoomRtcToken, DeleteRoom } from '@/api/Home/Index';
|
||||
import { Button, Input, Modal, Pagination, Empty, message, Popover, Popconfirm, DatePicker } from "antd";
|
||||
import { GetRoom, PostRoom, GetCheckoutRoomNum, GetRoomRtcToken, DeleteRoom, GetRecord } from '@/api/Home/Index';
|
||||
import ImageUrl from '@/utils/package/imageUrl'
|
||||
import { ReloadOutlined } from '@ant-design/icons';
|
||||
import { ExclamationCircleFilled, ReloadOutlined } from '@ant-design/icons';
|
||||
import JoinSetting from '@/components/JoinSetting';
|
||||
import { storage } from '@/utils';
|
||||
import { PostRefresh } from '@/api/Login';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { role } from '@/config/role';
|
||||
import dayjs from 'dayjs';
|
||||
import StupWizard from '@/components/StupWizard';
|
||||
const fs = require('fs').promises;
|
||||
const { exec } = require('child_process');
|
||||
const { RangePicker } = DatePicker;
|
||||
const { confirm } = Modal;
|
||||
const Index: React.FC = () => {
|
||||
const navigate = useNavigate();
|
||||
const [list, setList] = useState({
|
||||
|
|
@ -19,12 +25,15 @@ const Index: React.FC = () => {
|
|||
pageSize: 12,
|
||||
})
|
||||
const [createRoomModal, setCreateRoomModal] = useState(false)
|
||||
const [timeSelectModal, setTimeSelectModal] = useState(false)
|
||||
const [createRoomFrom, setCreateRoomFrom] = useState<{ roomName: string, roomNum: string }>({
|
||||
roomName: "",
|
||||
roomNum: ""
|
||||
})
|
||||
const joinSettingRef = useRef<any>();
|
||||
const stupWizardRef = useRef<any>();
|
||||
const [user, setUser] = useState<any>({});
|
||||
const [currentRoomInfo, setCurrentRoomInfo] = useState<any>({});
|
||||
const userInfo = JSON.parse(storage.getItem('user') as string)
|
||||
useEffect(() => {
|
||||
setUser(userInfo)
|
||||
|
|
@ -98,6 +107,45 @@ const Index: React.FC = () => {
|
|||
data: newList
|
||||
})
|
||||
}
|
||||
|
||||
const fileUpLoad = async (data: { url: string, content: string, fileName: string }): Promise<void> => {
|
||||
const setting = await JSON.parse(storage.getItem('setting') as string)
|
||||
try {
|
||||
const response = await fetch(data.url);
|
||||
const arrayBuffer = await response.arrayBuffer();
|
||||
const buffer = Buffer.from(arrayBuffer);
|
||||
await fs.writeFile(`${setting.shareFilesPath}\\${data.fileName}`, buffer, {});
|
||||
confirm({
|
||||
title: '提示',
|
||||
icon: <ExclamationCircleFilled />,
|
||||
content: data.content,
|
||||
centered: true,
|
||||
okText: '打开文件夹',
|
||||
cancelText: '关闭',
|
||||
async onOk() {
|
||||
await fs.access(setting.shareFilesPath, fs.constants.F_OK);
|
||||
if (process.platform === 'win32') {
|
||||
exec(`explorer "${setting.shareFilesPath}"`);
|
||||
} else if (process.platform === 'darwin') {
|
||||
exec(`open "${setting.shareFilesPath}"`);
|
||||
}
|
||||
},
|
||||
onCancel() {
|
||||
}
|
||||
})
|
||||
} catch (error: any) {
|
||||
if (error.code === 'ENOENT') {
|
||||
message.error({
|
||||
content: <div>文件夹不存在 <span style={{ color: '#606fc7', cursor: 'pointer' }} onClick={() => {
|
||||
stupWizardRef.current.changeModal(4)
|
||||
}}>前往设置</span></div>
|
||||
})
|
||||
return
|
||||
} else {
|
||||
message.error(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<div className={styles.index}>
|
||||
|
|
@ -183,6 +231,7 @@ const Index: React.FC = () => {
|
|||
</Popconfirm>
|
||||
<div onClick={() => {
|
||||
changeOpen(index, false)
|
||||
setTimeSelectModal(true)
|
||||
}}>导出参会记录</div>
|
||||
<div onClick={() => {
|
||||
changeOpen(index, false)
|
||||
|
|
@ -193,6 +242,7 @@ const Index: React.FC = () => {
|
|||
trigger="click"
|
||||
open={item.open}
|
||||
onOpenChange={() => {
|
||||
setCurrentRoomInfo(list.data[index])
|
||||
changeOpen(index, true)
|
||||
}}
|
||||
>
|
||||
|
|
@ -329,7 +379,32 @@ const Index: React.FC = () => {
|
|||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
<Modal title="选择时间段" destroyOnClose={true} open={timeSelectModal} footer={null} onCancel={() => setTimeSelectModal(false)} centered width={'400px'}>
|
||||
<div>
|
||||
<RangePicker
|
||||
showTime={{ format: 'YYYY-MM-DD HH:mm:ss' }}
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
onChange={(_value, dateString) => {
|
||||
const setting = JSON.parse(storage.getItem('setting') as string)
|
||||
if (dateString.length === 2) {
|
||||
GetRecord(dayjs(dateString[0]).unix(), dayjs(dateString[1]).unix(), currentRoomInfo.roomNum).then(res => {
|
||||
if (res.code === 200) {
|
||||
const fileName = res.data.split('/').pop().split('?')[0];
|
||||
fileUpLoad({
|
||||
url: res.data,
|
||||
content: `下载参会记录成功!文件已保存至:${setting.shareFilesPath}`,
|
||||
fileName
|
||||
})
|
||||
}
|
||||
setTimeSelectModal(false)
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Modal>
|
||||
<JoinSetting ref={joinSettingRef} />
|
||||
<StupWizard ref={stupWizardRef} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue