Commit 746ff097 authored by 皮倩雯's avatar 皮倩雯

fix: '开启网关地图接口路径拼上pandaCore'

parent 58c0bd9e
Pipeline #64107 passed with stages
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import check from '@/components/Authorized/CheckPermissions'; import check from '@/components/Authorized/CheckPermissions';
import { matchRoutes, renderRoutes } from 'react-router-config'; import { matchRoutes, renderRoutes } from 'react-router-config';
import { Link, Switch } from 'react-router-dom'; import { Link, Switch } from 'react-router-dom';
...@@ -40,6 +40,23 @@ const BasicLayout = props => { ...@@ -40,6 +40,23 @@ const BasicLayout = props => {
: routeCopy; : routeCopy;
}) })
.filter(Boolean); .filter(Boolean);
useEffect(() => {
console.log(localStorage.getItem('panda-publish'));
if (localStorage.getItem('panda-publish') == 'getway') {
window.globalConfig = {
access_token: localStorage.getItem('token'),
hasGateWay: true,
apiGatewayDomain: `${window.location.origin}${'/PandaCore/GateWay'}`,
};
} else {
window.globalConfig = {
access_token: localStorage.getItem('token'),
hasGateWay: false,
apiGatewayDomain: `${window.location.origin}`,
};
}
}, []);
const handleMenuCollapse = () => {}; // get children authority const handleMenuCollapse = () => {}; // get children authority
// 获取url地址参数 // 获取url地址参数
const getQueryVariable = name => { const getQueryVariable = name => {
...@@ -103,9 +120,7 @@ const BasicLayout = props => { ...@@ -103,9 +120,7 @@ const BasicLayout = props => {
}} }}
{...props} {...props}
> >
<Switch> <Switch>{renderRoutes(props.route.routes)}</Switch>
{renderRoutes(props.route.routes)}
</Switch>
</ProLayout> </ProLayout>
)} )}
</> </>
......
...@@ -63,6 +63,12 @@ const GateConfig = () => { ...@@ -63,6 +63,12 @@ const GateConfig = () => {
if (checked) { if (checked) {
UpdateGeteWay({ isUsed: checked }).then(res => { UpdateGeteWay({ isUsed: checked }).then(res => {
if (res.code === 0) { if (res.code === 0) {
console.log(localStorage.getItem('token'));
window.globalConfig = {
access_token: localStorage.getItem('token'),
hasGateWay: true,
apiGatewayDomain: `${window.location.origin}${'/PandaCore/GateWay'}`,
};
setFlag(flag + 1); setFlag(flag + 1);
message.success('设置成功'); message.success('设置成功');
} else { } else {
...@@ -85,6 +91,12 @@ const GateConfig = () => { ...@@ -85,6 +91,12 @@ const GateConfig = () => {
} else { } else {
UpdateGeteWay({ isUsed: checked }).then(res => { UpdateGeteWay({ isUsed: checked }).then(res => {
if (res.code === 0) { if (res.code === 0) {
console.log(localStorage.getItem('token'));
window.globalConfig = {
access_token: localStorage.getItem('token'),
hasGateWay: false,
apiGatewayDomain: `${window.location.origin}`,
};
setFlag(flag + 1); setFlag(flag + 1);
message.success('设置成功'); message.success('设置成功');
} else { } else {
......
...@@ -84,8 +84,18 @@ const Login = props => { ...@@ -84,8 +84,18 @@ const Login = props => {
.then(res => { .then(res => {
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
localStorage.setItem('panda-publish', 'getway'); localStorage.setItem('panda-publish', 'getway');
window.globalConfig = {
access_token: localStorage.getItem('token'),
hasGateWay: true,
apiGatewayDomain: `${window.location.origin}${'/PandaCore/GateWay'}`,
};
} else { } else {
localStorage.setItem('panda-publish', ''); localStorage.setItem('panda-publish', '');
window.globalConfig = {
access_token: localStorage.getItem('token'),
hasGateWay: false,
apiGatewayDomain: `${window.location.origin}`,
};
} }
}) })
.catch(err => { .catch(err => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment