增加相关方端不允许访问的判断和Websocket打完包地址不对的bug

master
LiuJiaNan 2026-08-07 21:48:02 +08:00
parent c08a767e58
commit 6f7c2fe61c
2 changed files with 12 additions and 2 deletions

View File

@ -5,6 +5,7 @@ import autoFit from "autofit.js";
import { useMemo, useReducer, useRef, useState } from "react";
import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery";
import { NS_BI_MARK, NS_BI_MARK_INFO, NS_BI_STATISTICS } from "~/enumerate/namespace";
import { closeWindow } from "~/utils";
import BottomUtils from "./components/BottomUtils";
import CenterUtils from "./components/CenterUtils";
import Content from "./components/Content";
@ -83,7 +84,12 @@ function Map(props) {
setTimeout(() => {
if (window.sessionStorage.getItem("token")) {
props.getCorpInfo().then(({ data }) => {
if ([0, 1, 6].includes(data?.type)) {
if ([3, 4, 5].includes(data?.type)) {
// eslint-disable-next-line no-alert
alert("您当前登录的账号没有权限访问此页面");
closeWindow();
}
else if ([0, 1, 6].includes(data?.type)) {
const id = data.id;
const name = data.corpName;
const longitude = data.longitude;

View File

@ -8,7 +8,11 @@ export default function usePeoplePosition(mapMethods, currentBranchOffice, onPeo
const points = useRef([]);
const wsProtocol = window.location.protocol === "https:" ? "wss:" : "ws:";
const wsUrl = `${wsProtocol}//${process.env.app.API_HOST.replace(/^https?:\/\//, "")}/personnelPosition/ws/location?corpinfoId=${currentBranchOffice}`;
// 生产环境的接口地址由 index.html 在运行时注入 window.process不能使用会在打包阶段被替换的 process.env。
const apiHost = window.process.env.app.API_HOST
.replace(/^https?:\/\//, "")
.replace(/\/$/, "");
const wsUrl = `${wsProtocol}//${apiHost}/personnelPosition/ws/location?corpinfoId=${currentBranchOffice}`;
const onMessage = async (message) => {
const data = JSON.parse(message.data);