fix(staff)

This commit is contained in:
wang_yp 2025-03-20 22:38:13 +08:00
parent 59f71dca3d
commit fe203a6d76
3 changed files with 99 additions and 64 deletions

View File

@ -15,6 +15,7 @@ const DebounceSelect = <
label: React.ReactNode; label: React.ReactNode;
value: string | number; value: string | number;
head_img?: string; head_img?: string;
identity?: string;
} = any } = any
>({ >({
fetchOptions, fetchOptions,
@ -36,6 +37,7 @@ const DebounceSelect = <
if (fetchId !== fetchRef.current) { if (fetchId !== fetchRef.current) {
return; return;
} }
console.log(newOptions)
setOptions(newOptions); setOptions(newOptions);
setFetching(false); setFetching(false);
}); });

View File

@ -3,7 +3,6 @@ import { Store } from "antd/es/form/interface";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import { useState } from "react"; import { useState } from "react";
import "./bot.less"; import "./bot.less";
import { PhoneTwoTone } from "@ant-design/icons";
import { webRTC } from "@/util/webRtc"; import { webRTC } from "@/util/webRtc";
import DebounceSelect from "@/components/form/featch_select"; import DebounceSelect from "@/components/form/featch_select";
interface UserValue { interface UserValue {
@ -32,7 +31,7 @@ const Ec = (props: Store) => {
label: item.user_name, label: item.user_name,
value: item.identity, value: item.identity,
identity: item.identity, identity: item.identity,
head_img:item.head_img, head_img: item.head_img,
})); }));
}); });
} }
@ -63,49 +62,49 @@ const Ec = (props: Store) => {
value={value} value={value}
placeholder="输入搜索" placeholder="输入搜索"
fetchOptions={fetchUserList} fetchOptions={fetchUserList}
onChange={(newValue) => { onChange={(newValue, options) => {
setValue(newValue as UserValue[]); setValue(options as UserValue[]);
}} }}
optionRender={(item:any) => { maxCount={1}
return <Space key={item.key}> optionRender={(item: any) => {
return (
<Space key={item.key}>
<span>{item.label}</span> <span>{item.label}</span>
<img src={item.data.head_img} alt="" width={40} height={40} /> <img
src={item.data.head_img}
alt=""
width={40}
height={40}
/>
</Space> </Space>
);
}} }}
style={{ width: "100%" }} style={{ width: "100%" }}
/> />
{value.map((item: any) => { {value.map((item: any) => {
return ( return (
<div key={item.key}> <div key={item.value} style={{ marginTop: "10px" }}>
<div>{item.label}</div> <div>{item.label}</div>
<div> <div style={{ marginTop: "10px" }}>
<img
<PhoneTwoTone src={item.head_img}
style={{ fontSize: "20px" }} style={{ width: "100%" }}
onClick={(items) => { alt=""
webRTC.init(item.key);
webRTC.calls();
}}
/> />
</div> </div>
<div style={{height:"10px"}}></div>
<div
style={{ textAlign: "center" }}
onClick={(items) => {
webRTC.init(item.value);
webRTC.calls();
}}
>
</div> </div>
); <div style={{height:"10px"}}></div>
})}
</div>
</div>
<div className="ec_right">
<div style={{ display: "flex" }}>
{/* <video
id="rtcVideo"
style={{ width: "300px", height: "300px" }}
></video> */}
<video
id="remoteVideo"
style={{ width: "300px", height: "300px" }}
></video>
</div>
<p <p
className="ec_right_end" style={{ textAlign: "center" }}
onClick={() => { onClick={() => {
webRTC.close(); webRTC.close();
}} }}
@ -113,6 +112,16 @@ const Ec = (props: Store) => {
</p> </p>
</div> </div>
);
})}
</div>
</div>
<div className="ec_right">
<video
id="remoteVideo"
style={{ width: "100%", height: "90%", objectFit: "contain" }}
></video>
</div>
</div> </div>
</Modal> </Modal>
</> </>

View File

@ -1,15 +1,16 @@
import { Modal } from "antd"; import { Modal } from "antd";
import { inject, observer } from "mobx-react"; import { inject, observer } from "mobx-react";
import { useEffect, useState } from "react"; import { useEffect, useRef, useState } from "react";
import Config from "@/util/config"; import Config from "@/util/config";
import EasyPlayer from "../videoTow"; import EasyPlayer from "../videoTow";
const WhichVideo = (props) => { import { Store } from "antd/es/form/interface";
const WhichVideo = (props:Store) => {
const { homeStore } = props; const { homeStore } = props;
const [isModalOpen, setIsModalOpen] = useState<boolean>(false); const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
const [deviceList, setDeviceList] = useState<Array<any>>([]); const [deviceList, setDeviceList] = useState<Array<any>>([]);
const [channelList, setChannelList] = useState<Array<any>>([]); const [channelList, setChannelList] = useState<Array<any>>([]);
const [deviceId, setDeviceId] = useState<number>(0); const deviceId = useRef<number>(0);
const [channelId, setChannelId] = useState<number>(0); const channelId = useRef<number>(0);
const [videoUrl, setVideoUrl] = useState<string | null>(""); const [videoUrl, setVideoUrl] = useState<string | null>("");
let timer: any = null; let timer: any = null;
@ -22,14 +23,9 @@ const WhichVideo = (props) => {
let reqs = await homeStore.getChannerUrlList(id); let reqs = await homeStore.getChannerUrlList(id);
setChannelList(reqs.EasyDarwin.Body.Channels); setChannelList(reqs.EasyDarwin.Body.Channels);
}; };
const fetchUrl = async (did, cid) => {
const getUrl = async (id) => {
if (timer) {
clearInterval(timer);
}
const fetchUrl = async () => {
try { try {
const reqs = await homeStore.getChannerStrem(deviceId, id); const reqs = await homeStore.getChannerStrem(did, cid);
if (!reqs.EasyDarwin) return; if (!reqs.EasyDarwin) return;
const url = Config.videoApis + reqs.EasyDarwin.Body.URL; const url = Config.videoApis + reqs.EasyDarwin.Body.URL;
setVideoUrl(url); setVideoUrl(url);
@ -37,9 +33,14 @@ const WhichVideo = (props) => {
console.error("Error fetching video URL:", error); console.error("Error fetching video URL:", error);
} }
}; };
fetchUrl(); const getUrl = async () => {
if (timer) {
clearInterval(timer);
}
fetchUrl(deviceId.current, channelId.current);
timer = setInterval(() => { timer = setInterval(() => {
fetchUrl(); console.log();
fetchUrl(deviceId.current, channelId.current);
}, 35000); }, 35000);
}; };
useEffect(() => { useEffect(() => {
@ -62,7 +63,7 @@ const WhichVideo = (props) => {
setDeviceList([]); setDeviceList([]);
setChannelList([]); setChannelList([]);
setVideoUrl(null); setVideoUrl(null);
setChannelId(0); deviceId.current = 0;
}} }}
onOk={() => {}} onOk={() => {}}
footer={null} footer={null}
@ -72,20 +73,31 @@ const WhichVideo = (props) => {
> >
<div> <div>
<div style={{ display: "flex" }}> <div style={{ display: "flex" }}>
<div style={{ overflowY: "scroll", height: "550px" }}> <div
style={{
overflowY: "scroll",
height: "550px",
width: "240px",
border: "1px solid #ccc",
padding: "10px",
}}
>
{deviceList.map((item, index) => { {deviceList.map((item, index) => {
return ( return (
<div <div
key={index} key={index}
style={{ cursor: "pointer" }} style={{ cursor: "pointer" }}
onClick={() => { onClick={() => {
setDeviceId(item.DeviceID); deviceId.current = item.DeviceID;
getChannerList(item.DeviceID); getChannerList(item.DeviceID);
}} }}
> >
<p <p
style={{ style={{
color: deviceId === item.DeviceID ? "yellow" : "#fff", color:
deviceId.current === item.DeviceID
? "yellow"
: "#fff",
}} }}
> >
{item.DeviceName} {item.DeviceName}
@ -95,20 +107,32 @@ const WhichVideo = (props) => {
})} })}
</div> </div>
<div style={{ width: "20px" }}></div> <div style={{ width: "20px" }}></div>
<div style={{ height: "550px", overflow: "scroll" }}> <div
style={{
height: "550px",
overflow: "scroll",
width: "240px",
border: "1px solid #ccc",
marginBottom: "20px",
padding: "10px",
}}
>
{channelList.map((item, index) => { {channelList.map((item, index) => {
return ( return (
<div <div
key={index} key={index}
style={{ cursor: "pointer" }} style={{ cursor: "pointer" }}
onClick={() => { onClick={() => {
setChannelId(item.ChannelID); channelId.current = item.ChannelID;
getUrl(item.ChannelID); getUrl();
}} }}
> >
<p <p
style={{ style={{
color: channelId === item.ChannelID ? "yellow" : "#fff", color:
channelId.current === item.ChannelID
? "yellow"
: "#fff",
}} }}
> >
{item.Name} {item.Name}