diff --git a/src/pages/Container/Map/index.js b/src/pages/Container/Map/index.js index 500e087..9f8d894 100644 --- a/src/pages/Container/Map/index.js +++ b/src/pages/Container/Map/index.js @@ -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; diff --git a/src/pages/Container/Map/js/usePeoplePosition.js b/src/pages/Container/Map/js/usePeoplePosition.js index 1e50a55..5f16a52 100644 --- a/src/pages/Container/Map/js/usePeoplePosition.js +++ b/src/pages/Container/Map/js/usePeoplePosition.js @@ -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);