fix(amap):core

This commit is contained in:
wang_yp 2024-10-31 16:50:55 +08:00
parent 622bc2ea8b
commit bb81cda972
9 changed files with 250 additions and 299 deletions

View File

@ -1,10 +1,10 @@
import { Outlet } from "react-router"; import { Outlet } from "react-router";
import MapUtl from "./components/map/mapUtil"; import MapUtl from "./components/map/mapUtil";
import { useEffect } from "react"; import SocketService from "./util/socket";
// import SocketService from "./util/socket"; const socketService = SocketService.getInstance();
// const socketService = SocketService.getInstance();
const onMessage = (e: any) => { const onMessage = (e: any) => {
let data = JSON.parse(e); let data = JSON.parse(e);
console.log(data)
if (data.type === "accpt") { if (data.type === "accpt") {
let body = JSON.parse(data.content.body); let body = JSON.parse(data.content.body);
MapUtl.addMaker({ MapUtl.addMaker({
@ -23,9 +23,19 @@ const onMessage = (e: any) => {
}); });
maker?.setPosition([body.long, body.lat]); maker?.setPosition([body.long, body.lat]);
} }
else if (data.type === "move") {
let maker: any = null;
let body = JSON.parse(data.content.body);
MapUtl.makerList?.forEach((e) => {
if (e.userIdentity === body?.user_identity) {
maker = e.marker;
}
});
maker?.setPosition([body.long, body.lat]);
}
}; };
// socketService.on("message", onMessage); socketService.on("message", onMessage);
const App = () => { const App = () => {
return ( return (
<> <>

View File

@ -48,7 +48,7 @@ const Ec = (props: Store) => {
{userList.map((item: any) => { {userList.map((item: any) => {
return ( return (
<div key={item.account}> <div key={item.account}>
<div>{item.account} : 线</div> <div>{item.user_name} : 线</div>
<p></p> <p></p>
<div> <div>

View File

@ -23,7 +23,6 @@ export const columns: ColumnsType<UserDataType> = [
]; ];
export const defaultConfig = [ export const defaultConfig = [
{ {
type: FormType.input, type: FormType.input,
label: "法规标题", label: "法规标题",
@ -31,21 +30,26 @@ export const defaultConfig = [
value: "", value: "",
rules: [{ required: true, message: "请输入法规标题!" }], rules: [{ required: true, message: "请输入法规标题!" }],
}, },
{
type: FormType.inputNumber,
label: "等级排序",
name: "level",
value: 1,
},
{ {
type: FormType.input, type: FormType.input,
label: "法规副标题", label: "法规副标题",
name: "sub_title", name: "sub_title",
value: "", value: "",
rules: [{ required: true, message: "请输入法规副标题!" }],
}, },
{ {
type: "editor", type: FormType.editor,
label: "内容", label: "内容",
name: "content", name: "content",
value: "", value: "",
rules: [{ required: true, message: "请填写内容" }], rules: [{ required: true, message: "请填写内容" }],
}, },
{ {
type: "upload", type: "upload",
label: "附件图片", label: "附件图片",

View File

@ -7,17 +7,7 @@ import SimpleForm from "@/components/form/simple_form";
import React from "react"; import React from "react";
import { columns, defaultCatConfig } from "./dict_column"; import { columns, defaultCatConfig } from "./dict_column";
const { Option } = Select; const { Option } = Select;
const list = [
{ id: 1, name: "婚姻" },
{ id: 2, name: "政治面貌" },
{ id: 3, name: "文化程度" },
{ id: 4, name: "民族" },
{ id: 5, name: "单位性质" },
{ id: 6, name: "服役军兵种" },
{ id: 7, name: "军衔" },
{ id: 8, name: "技术职称" },
{ id: 9, name: "职务级别" },
];
const Dict = (props: Store) => { const Dict = (props: Store) => {
const { sysStore } = props; const { sysStore } = props;
const [isModalOpen, setIsModalOpen] = useState<boolean>(false); const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
@ -130,7 +120,7 @@ const Dict = (props: Store) => {
<> <>
<Form.Item key="drop_type" label="类型" name="drop_type" rules={[]}> <Form.Item key="drop_type" label="类型" name="drop_type" rules={[]}>
<Select placeholder=""> <Select placeholder="">
{list?.map((v: any) => { {sysStore.list?.map((v: any) => {
return ( return (
<Option key={v.id} value={v.id}> <Option key={v.id} value={v.id}>
{v.name} {v.name}

View File

@ -2,8 +2,7 @@ import { FormType } from "@/components/form/interface";
import { UserDataType } from "@/model/userModel"; import { UserDataType } from "@/model/userModel";
import { ColumnsType } from "antd/lib/table"; import { ColumnsType } from "antd/lib/table";
import { Image } from "antd"; import { Image } from "antd";
export const defaultConfig =(team,per)=> export const defaultConfig = (team, per) => [
[
{ {
type: FormType.input, type: FormType.input,
label: "用户名", label: "用户名",
@ -16,14 +15,8 @@ export const defaultConfig =(team,per)=>
label: "性别", label: "性别",
name: "sex", name: "sex",
radioData: [ radioData: [
{ { key: "男", val: 1 },
key: "男", { key: "女", val: 2 },
val: 1,
},
{
key: "女",
val: 2,
},
], ],
value: 0, value: 0,
rules: [{ required: true, message: "请选择性别" }], rules: [{ required: true, message: "请选择性别" }],
@ -145,7 +138,6 @@ export const defaultConfig =(team,per)=>
], ],
rules: [{ required: true, message: "单位类型不能为空" }], rules: [{ required: true, message: "单位类型不能为空" }],
}, },
{ {
type: FormType.radio, type: FormType.radio,
label: "民兵类型", label: "民兵类型",
@ -212,72 +204,6 @@ export const defaultConfig =(team,per)=>
name: "email", name: "email",
value: "", value: "",
}, },
{
type: FormType.radio,
label: "积极力量",
name: "a_member",
value: 1,
radioData: [
{
key: "是",
val: 1,
},
{
key: "否",
val: 2,
},
],
},
{
type: FormType.radio,
label: "专业队伍",
name: "p_team",
value: 1,
radioData: [
{
key: "是",
val: 1,
},
{
key: "否",
val: 2,
},
],
},
{
type: FormType.radio,
label: "是否为社干力量",
name: "c_member",
value: 2,
radioData: [
{
key: "是",
val: 1,
},
{
key: "否",
val: 2,
},
],
},
{
type: FormType.radio,
label: "三方力量",
name: "o_member",
value: 2,
radioData: [
{
key: "是",
val: 1,
},
{
key: "否",
val: 2,
},
],
},
{ {
type: FormType.textarea, type: FormType.textarea,
label: "描述", label: "描述",

View File

@ -29,6 +29,17 @@ class SysStore extends BaseStore<TagDataType> {
this.bannerList = res.data.record this.bannerList = res.data.record
} }
bannerList: Array<any> = [] bannerList: Array<any> = []
list: Array<any> = [
{ id: 1, name: "婚姻" },
{ id: 2, name: "政治面貌" },
{ id: 3, name: "文化程度" },
{ id: 4, name: "民族" },
{ id: 5, name: "单位性质" },
{ id: 6, name: "服役军兵种" },
{ id: 7, name: "军衔" },
{ id: 8, name: "技术职称" },
{ id: 9, name: "职务级别" },
];
} }
export const sysStore = new SysStore() export const sysStore = new SysStore()

View File

@ -1,12 +1,11 @@
class Config { class Config {
// static baseUrl = "https://rw.quwanya.cn/"; static baseUrl = "https://rw.quwanya.cn/";
static uploadUrl = "https://rw.quwanya.cn/"; static uploadUrl = "https://rw.quwanya.cn/";
// static ws = "wss://rw.quwanya.cn/wsadmin?id=admin"; static ws = "ws://rw.quwanya.cn:12214/wsadmin?id=admin";
static rtc = "wss://rw.quwanya.cn/ws"; static rtc = "wss://rw.quwanya.cn/ws";
static ws = "ws://127.0.0.1:12214/ws?id=admin"; // static ws = "ws://127.0.0.1:12214/ws?id=admin";
static baseUrl = "http://127.0.0.1:12214/"; // static baseUrl = "http://127.0.0.1:12214/";
// static uploadUrl = "http://127.0.0.1:12214/"; // static uploadUrl = "http://127.0.0.1:12214/";
} }
export default Config; export default Config;

View File

@ -61,7 +61,7 @@ export type AutoReconnectOptions = boolean | {
} }
} }
public hert() { public hert() {
this.times = setInterval(() => this.send({"type":"heartbeat"}), 3000) this.times = setInterval(() => this.send({ type: "heartbeat", data: {} }), 3000)
} }
private shouldReconnect(): boolean { private shouldReconnect(): boolean {
if (typeof this.autoReconnect === 'boolean') { if (typeof this.autoReconnect === 'boolean') {
@ -142,4 +142,3 @@ export type AutoReconnectOptions = boolean | {
} }
export default SocketService export default SocketService

View File

@ -1,5 +1,6 @@
import Config from "./config"; import Config from "./config";
import SocketService from "./socket";
class WebRtc { class WebRtc {
private mediaStream: MediaStream | Blob | null = null; private mediaStream: MediaStream | Blob | null = null;
@ -17,57 +18,52 @@ class WebRtc {
})) }))
} }
async init() { async init() {
this.ws = new WebSocket(Config.rtc)
this.ws.addEventListener('open', this.open);
let that = this;
this.createOffer() this.createOffer()
this.ws.onmessage = function (evt) { // this.ws.onmessage = function (evt) {
let msg = JSON.parse(evt.data) // let msg = JSON.parse(evt.data)
if (!msg) { // if (!msg) {
return console.log('failed to parse msg') // return console.log('failed to parse msg')
} // }
switch (msg.type) { // switch (msg.type) {
case 'offer': // case 'offer':
let offer = msg.data.description // let offer = msg.data.description
that.pee?.setRemoteDescription(offer) // that.pee?.setRemoteDescription(offer)
that.pee?.createAnswer().then(answer => { // that.pee?.createAnswer().then(answer => {
that.pee?.setLocalDescription(answer) // that.pee?.setLocalDescription(answer)
that.ws?.send(JSON.stringify({ // that.ws?.send(JSON.stringify({
type: 'answer', data: { // type: 'answer', data: {
'to': msg.data.from, // 'to': msg.data.from,
'from': "31283192", // 'from': "31283192",
'description': { 'sdp': answer.sdp, 'type': answer.type }, // 'description': { 'sdp': answer.sdp, 'type': answer.type },
'session_id': msg.data.from + "-31283192", // 'session_id': msg.data.from + "-31283192",
} // }
})) // }))
}) // })
return // return
case 'candidate': // case 'candidate':
let candidate = msg.data.candidate // let candidate = msg.data.candidate
if (!candidate) { // if (!candidate) {
return console.log('failed to parse candidate') // return console.log('failed to parse candidate')
} // }
that.pee?.addIceCandidate(candidate) // that.pee?.addIceCandidate(candidate)
break; // break;
case "answer": // case "answer":
that.pee?.setRemoteDescription(msg.data.description) // that.pee?.setRemoteDescription(msg.data.description)
break; // break;
case "bye": // case "bye":
that.pee?.close() // that.pee?.close()
that.close() // that.close()
break; // break;
} // }
} // }
} }
async createOffer() { async createOffer() {
var url = var url =
'http://rw.quwanya.cn:12217/api/turn?service=turn&username=flutter-webrtc'; 'https://rw.quwanya.cn/api/turn?service=turn&username=flutter-webrtc';
fetch(url) fetch(url)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
const configuration = { const configuration = {
iceServers: [ iceServers: [
{ {
@ -79,15 +75,18 @@ class WebRtc {
} }
this.gets(configuration) this.gets(configuration)
}) })
try {
} catch (error) {
console.log(error);
} }
// 设置远程offer
setRemoteDes(answer) {
this.pee?.setRemoteDescription(answer)
}
addCandidate(candidate) {
if (!candidate) {
return console.log('failed to parse candidate')
}
this.pee?.addIceCandidate(candidate)
} }
async gets(configuration) { async gets(configuration) {
console.log(configuration);
const peerConnection = new RTCPeerConnection(configuration); const peerConnection = new RTCPeerConnection(configuration);
this.pee = peerConnection this.pee = peerConnection
// 获取远方流添加到页面播放 // 获取远方流添加到页面播放
@ -123,10 +122,10 @@ class WebRtc {
that.ws?.send(JSON.stringify({ that.ws?.send(JSON.stringify({
type: "offer", "data": { type: "offer", "data": {
"to": userId, "to": userId,
"from": "31283192", "from": "admin",
"description": offer, "description": offer,
"media": "video", "media": "video",
"session_id": userId + "-31283192", "session_id": userId + "-admin",
} }
})) }))
}).catch(function (error) { }).catch(function (error) {
@ -150,20 +149,33 @@ class WebRtc {
} }
} }
calls(userId) { calls(userId) {
this.sendOffer(userId) this.sendOffer("admin123")
if (this.video) { if (this.video) {
this.video.srcObject = this.mediaStream; this.video.srcObject = this.mediaStream;
this.video.autoplay = true; this.video.autoplay = true;
} }
} }
// 发送本地offer
setIceOffer(offer, toid) {
this.pee?.setRemoteDescription(offer)
this.pee?.createAnswer().then(answer => {
this.pee?.setLocalDescription(answer)
SocketService.getInstance().send({
type: 'answer', data: {
'to': toid,
'from': "admin",
'description': { 'sdp': answer.sdp, 'type': answer.type },
'session_id': toid + "-admin",
}
})
})
}
close() { close() {
this.video?.pause(); this.video?.pause();
this.pee?.close(); this.pee?.close();
this.ws?.send(JSON.stringify({ this.ws?.send(JSON.stringify({
"type": "bye", "data": { "type": "bye", "data": {
"session_id": this.userToId + "31283192", "session_id": this.userToId + "admin",
"to": this.userToId "to": this.userToId
} }
} }