Commit 57fe70d2 authored by 邓晓峰's avatar 邓晓峰

fix: 修复client标识

parent 4db244ba
Pipeline #38825 passed with stages
in 12 minutes 51 seconds
/* eslint-disable */ /* eslint-disable */
// const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin; // const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin;
const proxyURL = 'https://mis.panda-water.cn'; const proxyURL = 'http://192.168.10.152:8076';
module.exports = { module.exports = {
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './', assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './',
dev: { dev: {
......
...@@ -124,7 +124,7 @@ const initGlobalConfig = () => { ...@@ -124,7 +124,7 @@ const initGlobalConfig = () => {
// eslint-disable-next-line react-hooks/rules-of-hooks // eslint-disable-next-line react-hooks/rules-of-hooks
appService appService
.queryConfig({ .queryConfig({
client: params.getParams('client') || Cookies.get('city') || 'city', client: params.getParams('client') || 'city',
}) })
.then(res => { .then(res => {
if (res) { if (res) {
...@@ -132,7 +132,7 @@ const initGlobalConfig = () => { ...@@ -132,7 +132,7 @@ const initGlobalConfig = () => {
if (!data.client) { if (!data.client) {
data.client = params.getParams('client') || 'city'; data.client = params.getParams('client') || 'city';
} }
Cookies.set('city', Cookies.get('city')); // Cookies.set('city', Cookies.get('city'));
store.dispatch( store.dispatch(
actionCreators.getConfig( actionCreators.getConfig(
Object.assign({}, window.globalConfig, data), Object.assign({}, window.globalConfig, data),
......
...@@ -11,7 +11,7 @@ import { ...@@ -11,7 +11,7 @@ import {
Upload, Upload,
} from 'antd'; } from 'antd';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import Cookies from 'js-cookie';
import { import {
FormattedMessage, FormattedMessage,
useIntl, useIntl,
...@@ -61,7 +61,6 @@ class AvatarDropdown extends React.Component { ...@@ -61,7 +61,6 @@ class AvatarDropdown extends React.Component {
} }
} }
loginout = event => { loginout = event => {
debugger
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
this.props.logout(); this.props.logout();
if ( if (
...@@ -71,7 +70,10 @@ class AvatarDropdown extends React.Component { ...@@ -71,7 +70,10 @@ class AvatarDropdown extends React.Component {
window.location.href = `${window.location.origin}/#login`; window.location.href = `${window.location.origin}/#login`;
return false; return false;
} }
window.location.reload(); // console.log(this.props)
// this.props.history.push('/login')
// window.location.reload();
//
}; };
getRoles = () => { getRoles = () => {
......
...@@ -105,7 +105,7 @@ const SearchPanel = props => { ...@@ -105,7 +105,7 @@ const SearchPanel = props => {
} }
const goFeature = (path, rect, value) => { const goFeature = (path, rect, value) => {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
debugger
value = value || props.value; value = value || props.value;
const findKeywordIndex = const findKeywordIndex =
recentKeywords.length > 0 recentKeywords.length > 0
......
...@@ -177,6 +177,8 @@ export function logout(data) { ...@@ -177,6 +177,8 @@ export function logout(data) {
Cookies.set(window.globalConfig.client, '', { Cookies.set(window.globalConfig.client, '', {
path: '/', path: '/',
}); });
window.globalConfig.token = null;
window.globalConfig.access_token = null
} }
Cookies.set('token', '', { Cookies.set('token', '', {
......
...@@ -106,7 +106,10 @@ const appReducer = (state = initialState, action) => { ...@@ -106,7 +106,10 @@ const appReducer = (state = initialState, action) => {
modulePkg[item.PackageName] = item; modulePkg[item.PackageName] = item;
}); });
const generMenu = generRoutes(config.widgets || [], null, 0, modulePkg); const generMenu = generRoutes(config.widgets || [], null, 0, modulePkg);
const flatMenu = generFlatRoutes(generMenu || [], null, null, modulePkg); let flatMenu = [];
if(generMenu) {
flatMenu = generFlatRoutes(generMenu || [], null, null, modulePkg);
}
const home = flatMenu.find(item => { const home = flatMenu.find(item => {
let path = item.path.split("|"); let path = item.path.split("|");
...@@ -119,7 +122,6 @@ const appReducer = (state = initialState, action) => { ...@@ -119,7 +122,6 @@ const appReducer = (state = initialState, action) => {
let currentMenuIndex = 0; let currentMenuIndex = 0;
if(home) { if(home) {
console.log("home", home);
const parent = home.level >= 2 ? home.parent.parent: home.level >= 3 ? home.parent.parent.parent: home.parent; const parent = home.level >= 2 ? home.parent.parent: home.level >= 3 ? home.parent.parent.parent: home.parent;
if(parent) { if(parent) {
...@@ -139,7 +141,7 @@ const appReducer = (state = initialState, action) => { ...@@ -139,7 +141,7 @@ const appReducer = (state = initialState, action) => {
Cookies.set('city', Cookies.get('city') || window.globalConfig.client); Cookies.set('city', Cookies.get('city') || window.globalConfig.client);
return state.merge({ return state.merge({
globalConfig: config, globalConfig: config,
menu: generMenu, menu: generMenu || [],
flatMenu, flatMenu,
currentMenu: generMenu && generMenu[state.currentMenuIndex], currentMenu: generMenu && generMenu[state.currentMenuIndex],
}); });
......
import React from 'react'; import React from 'react';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Redirect } from 'react-router-dom'; import { Redirect } from '@wisdom-utils/runtime';
import { PageLoading } from '@ant-design/pro-layout'; import { PageLoading } from '@ant-design/pro-layout';
import { stringify } from 'querystring'; import { stringify } from 'querystring';
import { getBaseName } from '../utils/utils'; import { getBaseName } from '../utils/utils';
import _ from 'lodash';
class SecurityLayout extends React.Component { class SecurityLayout extends React.Component {
state = { state = {
...@@ -19,25 +20,33 @@ class SecurityLayout extends React.Component { ...@@ -19,25 +20,33 @@ class SecurityLayout extends React.Component {
} }
render() { render() {
const { isReady } = this.state; const { isReady } = this.state;
const { children, global, loading } = this.props; const { children, global, loading } = this.props;
const isLogin = Cookies.get('token') !== null && global.token !== null; const isLogin = Cookies.get('token') !== null && global.token !== null;
const queryString = stringify({ // const queryString = stringify({
redirect: window.location.href, // redirect: window.location.href,
}); // });
if ((!isLogin && loading) || !isReady) { if(_.isNull(global.token) || (global.hasGateWay && _.isNull(global.access_token))) {
return <PageLoading />;
}
if (
!isLogin &&
window.location.pathname !== `/${getBaseName()}/user/login`
) {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0); this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
return ( return (
<Redirect to={`/user/login?client=${global.client}&${queryString}`} /> <Redirect to={`/user/login?client=${global.client}`} />
); );
} }
if ((!isLogin && loading) || !isReady) {
return <PageLoading />;
}
// if (
// !isLogin &&
// window.location.pathname !== `/${getBaseName()}/user/login`
// ) {
// this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
// return (
// <Redirect to={`/user/login?client=${global.client}&${queryString}`} />
// );
// }
return children; return children;
} }
} }
......
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