diff --git a/src/components/layout/layout_config.ts b/src/components/layout/layout_config.ts index b329485..6abdbee 100644 --- a/src/components/layout/layout_config.ts +++ b/src/components/layout/layout_config.ts @@ -81,7 +81,7 @@ export const items = [ { label: `部门管理`, key: "/admin/dep" }, { label: "系统设置", key: "/admin/sys/setting" }, { label: "光荣牌审核", key: "/admin/sys/gp" }, - { label: "评优审核", key: "/admin/sys/gp" }, + { label: "评优审核", key: "/admin/sys/exce_compet" }, ], }, ]; \ No newline at end of file diff --git a/src/components/map/mapUtil.ts b/src/components/map/mapUtil.ts index c2842ab..1b06b2e 100644 --- a/src/components/map/mapUtil.ts +++ b/src/components/map/mapUtil.ts @@ -10,6 +10,7 @@ class MapUtl { static addMaker(data: any) { const { lng, lat, title, users } = data; + if (MapUtl.loadMap === null) return; const marker = new MapUtl.loadMap.Marker({ position: new MapUtl.loadMap.LngLat(lng, lat), title: title, diff --git a/src/pages/exce_compet/index.tsx b/src/pages/exce_compet/index.tsx new file mode 100644 index 0000000..4437953 --- /dev/null +++ b/src/pages/exce_compet/index.tsx @@ -0,0 +1,53 @@ +import BTable from "@/components/b_table"; +import { UserDataType } from "@/model/userModel"; +import { Button } from "antd"; +import { Store } from "antd/es/form/interface"; +import { ColumnsType } from "antd/lib/table"; +import { inject, observer } from "mobx-react"; +import { useEffect } from "react"; + +const ExceCompet = (props: Store) => { + const { exceCompetStore } = props; + useEffect(() => { + exceCompetStore.getlist(); + }, [exceCompetStore]); + const columns: ColumnsType = [ + { title: "评优标题", dataIndex: "title" }, + { title: "内容", dataIndex: "content" }, + { + title: "评优申请人", + dataIndex: "users", + render: (users) => {users?.user_name} + }, + { title: "申请积分", dataIndex: "reviewer_score" }, + { title: "申请时间", dataIndex: "created_at" }, + { title: "描述", dataIndex: "desc" }, + { title: "审核状态", dataIndex: "status" }, + { title: "审核人", dataIndex: "reviewer_identity" }, + { + title: "操作", + dataIndex: "id", + render: (any, record) => ( + + ), + }, + ]; + return ( +
+ +
+ ); +}; +export default inject("exceCompetStore")(observer(ExceCompet)); diff --git a/src/pages/home/home.tsx b/src/pages/home/home.tsx index 45a8fda..467f839 100644 --- a/src/pages/home/home.tsx +++ b/src/pages/home/home.tsx @@ -48,7 +48,7 @@ const Home = observer(() => {
-
diff --git a/src/pages/home/homeBottom/ec.tsx b/src/pages/home/homeBottom/ec.tsx index aa4eee0..19ac6eb 100644 --- a/src/pages/home/homeBottom/ec.tsx +++ b/src/pages/home/homeBottom/ec.tsx @@ -20,9 +20,7 @@ const Ec = (props: Store) => { console.log(error); } }; - const callphone = (record: any) => { - webRTC.calls(record.value); - }; + const [value, setValue] = useState([]); async function fetchUserList(username: string): Promise { return usrStore.serchUser(username).then((res) => { @@ -73,8 +71,8 @@ const Ec = (props: Store) => { { - webRTC.init(); - callphone(item); + webRTC.init(item.key); + webRTC.calls(); }} />
diff --git a/src/pages/home/video.tsx b/src/pages/home/video.tsx index 2618e3d..2dd302b 100644 --- a/src/pages/home/video.tsx +++ b/src/pages/home/video.tsx @@ -10,7 +10,7 @@ const videoJsOptions = { fluid: true, sources: [ { - src: "http://183.221.86.205:18000/hls/stream_1_0/playlist.m3u8", + src: "https://sprh.hswzct.cn:4443/hls/stream_1_0/playlist.m3u8", type: "application/x-mpegURL", }, ], diff --git a/src/router/routers/home_router.tsx b/src/router/routers/home_router.tsx index c4c83d4..abf7bab 100644 --- a/src/router/routers/home_router.tsx +++ b/src/router/routers/home_router.tsx @@ -26,6 +26,7 @@ import GloryPlaque from "@/pages/glory_plaque"; import Grid from "@/pages/grid"; import Community from "@/pages/community"; import PatrolBrigade from "@/pages/patrolBrigade"; +import ExceCompet from "@/pages/exce_compet"; export const homeRouter = [ { path: "/", @@ -148,6 +149,7 @@ export const homeRouter = [ index: true, element: , }, + { path: "/admin/whse", element: , @@ -178,6 +180,11 @@ export const homeRouter = [ index: true, element: , }, + { + path: "/admin/sys/exce_compet", + index: true, + element: , + }, ], }, ], diff --git a/src/store/exce_compet.ts b/src/store/exce_compet.ts new file mode 100644 index 0000000..e43459b --- /dev/null +++ b/src/store/exce_compet.ts @@ -0,0 +1,26 @@ +import { action, makeObservable } from "mobx"; +// 档案 +import BaseStore from "./baseStore"; +import { TagDataType } from "@/model/userModel"; +import baseHttp from "@/service/base"; + +class ExceCompetConfig { + static LIST: string = "exceCompet/list" + static ADD: string = "exceCompet" + static DELETE: string = "exceCompet" + static EDIT: string = "exceCompet" +} +class ExceCompetStore extends BaseStore { + constructor() { + super(ExceCompetConfig) + makeObservable(this, { + save: action + }) + } + + async save(id: string, list: Array) { + return await baseHttp.post(ExceCompetConfig.ADD +"/"+ id, {"list":list}); + } +} +export const exceCompetStore = new ExceCompetStore() + diff --git a/src/store/index.ts b/src/store/index.ts index 8f54a49..23ae437 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -25,6 +25,7 @@ import gpStore from './gp'; import { communityStore } from './community'; import { gridStore } from './grid'; import { patrolBrigadeStore } from './patrol_brigade'; +import { exceCompetStore } from './exce_compet'; @@ -55,7 +56,8 @@ const store = { gpStore, gridStore, communityStore, - patrolBrigadeStore + patrolBrigadeStore, + exceCompetStore }; export default store; \ No newline at end of file diff --git a/src/test_socke.html b/src/test_socke.html index 239548c..5e8dd0a 100644 --- a/src/test_socke.html +++ b/src/test_socke.html @@ -25,11 +25,11 @@ \ No newline at end of file diff --git a/src/util/socket.ts b/src/util/socket.ts index 146ca18..1cdb9b6 100644 --- a/src/util/socket.ts +++ b/src/util/socket.ts @@ -61,7 +61,7 @@ export type AutoReconnectOptions = boolean | { } } public hert(){ - this.times = setInterval(() => this.send({"type":"heartbeat"}), 3000) + this.times = setInterval(() => this.send({"type":"heartbeat","data":{}}), 10000) } private shouldReconnect(): boolean { if (typeof this.autoReconnect === 'boolean') { diff --git a/src/util/webRtc.ts b/src/util/webRtc.ts index 431583f..42e6b3b 100644 --- a/src/util/webRtc.ts +++ b/src/util/webRtc.ts @@ -1,5 +1,6 @@ import SocketService from "./socket"; +import baseHttp from "@/service/base"; class WebRtc { private mediaStream: MediaStream | Blob | null = null; @@ -7,167 +8,162 @@ class WebRtc { private ws: SocketService | null = null; private video: HTMLVideoElement | null = null; private userToId: string = ""; - open = () => { - this.ws?.send(JSON.stringify({ - type: "new", "data": { - "name": "admin", - "id": "31283192", - "user_agent": "flutter-webrtc/js" - } - })) - } - async init() { + async init(userId) { + this.userToId = userId this.ws = SocketService.getInstance(); this.ws.on("message", this.onMessage); - this.createOffer() + } onMessage = (e: any) => { - let that = this; - let msg = JSON.parse(e.data) + let msg = JSON.parse(e) if (!msg) { return console.log('failed to parse msg') } switch (msg.type) { case 'offer': - let offer = msg.data.description - that.pee?.setRemoteDescription(offer) - that.pee?.createAnswer().then(answer => { - that.pee?.setLocalDescription(answer) - that.ws?.send(JSON.stringify({ - type: 'answer', data: { - 'to': msg.data.from, - 'from': "31283192", - 'description': { 'sdp': answer.sdp, 'type': answer.type }, - 'session_id': msg.data.from + "-31283192", + let offer = msg.content.body.description; + this.pee?.setRemoteDescription(offer) + this.pee?.createAnswer().then(answer => { + this.pee?.setLocalDescription(answer) + this.ws?.send({ + type: 'answer', + data: { + to: msg.content.body.from, + from: "admin", + description: { 'sdp': answer.sdp, 'type': answer.type }, + session_id: msg.content.body.from + "-admin", } - })) + }) }) - return - + break; + case "read": + this.sendOffer() + break; case 'candidate': - let candidate = msg.data.candidate + let candidate = msg.content.body.description if (!candidate) { return console.log('failed to parse candidate') } - that.pee?.addIceCandidate(candidate) + this.pee?.addIceCandidate(candidate) break; case "answer": - that.pee?.setRemoteDescription(msg.data.description) + this.pee?.setRemoteDescription(msg.content.body.description) break; case "bye": - that.pee?.close() - that.close() + this.close() break; } } async createOffer() { - var url = - 'http://rw.quwanya.cn:12217/api/turn?service=turn&username=flutter-webrtc'; - fetch(url) - .then(response => response.json()) - .then(data => { - const configuration = { - iceServers: [ - { - urls: data.uris[0], - "username": data.username, - "credential": data.password - }, - ] - } - this.gets(configuration) - }) - try { - - } catch (error) { - console.log(error); + let basData =await baseHttp.get('/public/webRtcConfig', { service: "11", username: "admin" }) + const configuration = { + iceServers: [ + { + urls: basData.data.credential.uris, + username: basData.data.credential.username, + credential: basData.data.credential.password, + ttl:basData.data.credential.ttl + }, + ] } + this.gets(configuration) } async gets(configuration) { - console.log(configuration); - const peerConnection = new RTCPeerConnection(configuration); - this.pee = peerConnection + this.pee = new RTCPeerConnection(configuration); // 获取远方流添加到页面播放 - peerConnection.ontrack = event => { - const remoteVideo = document.querySelector('#remoteVideo') as HTMLVideoElement; - remoteVideo.autoplay = true - remoteVideo.controls = true - remoteVideo.srcObject = event.streams[0]; - console.log(event); - - event.track.onmute = function () { - remoteVideo.play() + this.pee.ontrack = event => { + const re = document.querySelector('#remoteVideo') as HTMLVideoElement; + re.autoplay = true + re.controls = true + console.log(event.streams[0]) + re.srcObject = event.streams[0]; + event.track.onmute = function (event) { + re.play() + } + event.streams[0].onremovetrack = ({ track }) => { + if (re.parentNode) { + re.parentNode.removeChild(re) + } } }; - await this.getMedia(peerConnection) - - peerConnection.onicecandidate = e => { + this.pee.onicecandidate = e => { if (!e.candidate) { return } - this.ws?.send(JSON.stringify({ type: 'candidate', data: e })) + this.ws?.send({ + type: "candidate", data: { + to: this.userToId, + from: "admin", + description: e.candidate, + media: "video", + session_id: this.userToId + "-admin", + } + }) } + this.ws?.send({ + type: "call", + data: { + to: this.userToId, + from: "admin", + description: "call", + media: "video", + session_id: this.userToId + "-admin", + } + }) } - sendOffer(userId) { + sendOffer() { let that = this; - that.userToId = userId; - that.video = document.getElementById('rtcVideo') as HTMLVideoElement; - if (that.pee?.connectionState === "closed") { - that.createOffer() - } that.pee?.createOffer().then(function (offer) { that.pee?.setLocalDescription(offer); - that.ws?.send(JSON.stringify({ - type: "offer", "data": { - "to": userId, - "from": "31283192", - "description": offer, - "media": "video", - "session_id": userId + "-31283192", + that.ws?.send({ + type: "offer", + data: { + to: that.userToId, + from: "admin", + description: offer, + media: "video", + session_id: that.userToId + "-admin", } - })) + }) }).catch(function (error) { // 错误处理 console.error(error); }); } - addIceCandidate(candidate) { - this.pee?.addIceCandidate(candidate) - } - async getMedia(pee: RTCPeerConnection) { + async getMedia() { try { + this.video = document.getElementById('rtcVideo') as HTMLVideoElement; const stream = await navigator.mediaDevices.getUserMedia({ video: true, audio: true }); this.mediaStream = stream; - stream.getTracks().forEach(track => pee.addTrack(track, stream)) + stream.getTracks().forEach(track => this.pee?.addTrack(track, stream)) + if (this.video) { + this.video.srcObject = this.mediaStream; + this.video.autoplay = true; + } } catch (error) { console.log(error); } } - calls(userId) { - this.sendOffer(userId) - if (this.video) { - this.video.srcObject = this.mediaStream; - this.video.autoplay = true; - } + async calls() { + await this.createOffer() + await this.getMedia() } - - close() { this.video?.pause(); this.pee?.close(); - this.ws?.send(JSON.stringify({ - "type": "bye", "data": { - "session_id": this.userToId + "31283192", - "to": this.userToId - } - } - )); + // this.ws?.send({ + // type: "bye", + // data: { + // session_id: this.userToId + "admin", + // to: this.userToId, + // from: "admin" + // } + // }); (this.mediaStream as MediaStream)?.getTracks().forEach(track => track.stop()); - this.ws?.close() } }