Commit 6cda9a0f authored by 邓晓峰's avatar 邓晓峰

fix: 修复运维隐藏菜单配置

parent 3bcbac2d
Pipeline #39810 passed with stages
in 24 minutes 21 seconds
......@@ -17,7 +17,7 @@ export default {
// },
{
name: 'civ_pandawork',
entry: `//${window.location.hostname}:8082/civ_pandawork`,
entry: `//${window.location.hostname}:8081/civ_pandawork`,
container: '#micro-container',
activeRule: '/civbase/civ_pandawork',
},
......
/* eslint-disable */
// 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 = 'https://work.panda-water.cn';
module.exports = {
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : './',
dev: {
......
......@@ -9,6 +9,8 @@ const { warning } = Modal;
// eslint-disable-next-line no-return-await
instanceRequest.reportCodeError = true;
instanceRequest.transformRequestURL = function(url) {
// url = url.replace(/\/GateWay/, '')
const excludeURL = ['/PandaCore/GCK/Basis/GateWayConfig', '/CityInterface/rest/services.svc/GetConfig'];
if(excludeURL.includes(url)) {
return url;
......
......@@ -87,9 +87,9 @@ const services = {
},
getUserInfo: {
url: () => window.globalConfig &&
window.globalConfig &&
window.globalConfig.hasGateWay? API.GET_GATEWAY_USER_INFO: API.GET_USER_INFO,
url: () => {
return window.globalConfig && window.globalConfig.hasGateWay? API.GET_GATEWAY_USER_INFO: API.GET_USER_INFO
},
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
......@@ -218,6 +218,31 @@ export const searchAutoCity = keywords => {
return jsonp(url, params, options);
};
export const getUserInfo = (params) => {
const url = window.globalConfig && window.globalConfig.hasGateWay? API.GET_GATEWAY_USER_INFO: API.GET_USER_INFO
return request({
url: url,
method: constants.REQUEST_METHOD_GET,
params: params,
// params: param.query,
});
}
export const getWebSiteConfig = (params) => {
const url = window.globalConfig &&
window.globalConfig &&
window.globalConfig.hasGateWay
? API.GET_WEB_SITE_CONFIG_GEWAY
: API.GET_WEB_SITE_CONFIG;
return request({
url: url,
method: constants.REQUEST_METHOD_GET,
params: params,
// params: param.query,
});
}
// 更新常用页
export const savePagePartInfo = param =>
request({
......
......@@ -33,6 +33,7 @@ import { LocaleContainer } from './locales/locale';
import { initMicroApps } from './micro';
import Login from './pages/user/login/login';
import { getToken, isString } from './utils/utils';
import { initGlobalConfig } from './initConfig'
import './utils/event';
import Cookies from 'js-cookie';
// eslint-disable-next-line no-restricted-globals
......@@ -72,121 +73,6 @@ const initLocale = () => {
};
const PRODUCT_NAME = ['civ_water', 'civ_monitor'];
const initGlobalConfig = () => {
// eslint-disable-next-line no-debugger
// eslint-disable-next-line no-undef
let config = createStoreage.get('globalConfig') || {};
store.dispatch(actionCreators.updateComplexConfig({}));
if (!getToken() || config.token == null) {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
config = {};
}
if (!params.getParams('client', window.location.search) && config) {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
}
// eslint-disable-next-line no-undef
if (!createStoreage.get('globalConfig')) {
window.createStoreage = new Storeage(namespace);
}
if (!getToken()) {
localStorage.removeItem('loginSite');
}
if (config.token !== null && Object.keys(config).length > 0) {
store.dispatch(actionCreators.getConfig(config));
// render({ appContent: '', loading: true });
initMicroApps(loader, store);
if (config.isNewYear) {
updateTheme('#ff9600');
}
} else {
appService.getWateWayConfig().then(res => {
const hasGateWay =
res && res.data && isString(res.data) ? JSON.parse(res.data) : res.data;
if (res.code === 0 && res.data === 'true') {
store.dispatch(
actionCreators.getConfig(
Object.assign({}, window.globalConfig, {
hasGateWay,
apiGatewayDomain: `${window.location.origin}/PandaCore`,
}),
),
);
}
});
// eslint-disable-next-line react-hooks/rules-of-hooks
const client = !_.isNull(params.getParams('client')) ? params.getParams('client') : Cookies.get('city') ? Cookies.get('city'): 'city';
appService
.queryConfig({
client: client,
})
.then(res => {
if (res) {
const data = res;
if (!data.client) {
data.client = params.getParams('client') || 'city';
}
// Cookies.set('city', data.client);
store.dispatch(
actionCreators.getConfig(
Object.assign({}, window.globalConfig, data),
),
);
//Cookies.set('city', params.getParams('client'))
if (data.loginTemplate === '新春 - 智联.html') {
updateTheme('#ff9600');
}
// eslint-disable-next-line no-new
if (getToken()) {
// eslint-disable-next-line no-new
new Login(
{
global: Object.assign({}, data, {
token: getToken(),
}),
// eslint-disable-next-line no-shadow
updateConfig: data =>
store.dispatch(actionCreators.getConfig(data)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout()),
},
() => {
(async () => {
(await (getToken() &&
window.globalConfig &&
window.globalConfig.token)) && initMicroApps(loader, store);
})();
},
true,
);
}
// eslint-disable-next-line no-shadow
}
return res;
})
// eslint-disable-next-line no-shadow
.then(res => {
// eslint-disable-next-line no-use-before-define
// initSensorType();
// eslint-disable-next-line no-use-before-define
// initIsMock();
render({ appContent: '', loading: true });
})
.catch(error => {
console.log(error);
store.dispatch(actionCreators.getConfigError(error));
});
}
};
const initSensorType = () => {
let filterProduct =
......@@ -223,14 +109,18 @@ const initIsMock = () => {
});
};
initGlobalConfig();
initGlobalConfig(loader, store, render);
initLocale();
window.share && window.share.event && window.share.event.on('triggerMicro', () => {
initMicroApps(loader, store);
});
event.on('event:initConfig', () => {
initGlobalConfig();
});
const unlisten = history.listen(location => {
if(location.pathname.indexOf('/civbase/user/login') > -1) {
initGlobalConfig(loader, store, render);
}
})
event.on('event:logout', () => {
store.dispatch(actionCreators.logout())
});
......@@ -204,7 +204,7 @@ export function logout(data) {
localStorage.removeItem('access_token');
// eslint-disable-next-line no-undef,no-restricted-globals
createStoreage.remove(`__PANDA_STORE__${location.hostname}`);
event.emit('event:initConfig');
return {
type: LOGINOUT,
data: {
......
import { appService } from './api';
import { initMicroApps } from './micro';
import { params, Storeage } from 'kit_utils';
import { actionCreators } from './containers/App/store';
import { getToken, isString } from './utils/utils';
const namespace = `__PANDA_STORE__${location.hostname}`;
window.createStoreage = new Storeage(namespace);
export const initGlobalConfig = (loader, store, render) => {
// eslint-disable-next-line no-debugger
// eslint-disable-next-line no-undef
let config = createStoreage.get('globalConfig') || {};
store.dispatch(actionCreators.updateComplexConfig({}));
if (!getToken() || config.token == null) {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
config = {};
}
if (!params.getParams('client', window.location.search) && config) {
// eslint-disable-next-line no-undef
createStoreage.remove(namespace);
}
// eslint-disable-next-line no-undef
if (!createStoreage.get('globalConfig')) {
window.createStoreage = new Storeage(namespace);
}
if (!getToken()) {
localStorage.removeItem('loginSite');
}
if (config.token !== null && Object.keys(config).length > 0) {
store.dispatch(actionCreators.getConfig(config));
// render({ appContent: '', loading: true });
initMicroApps(loader, store);
if (config.isNewYear) {
updateTheme('#ff9600');
}
} else {
appService.getWateWayConfig().then(res => {
const hasGateWay =
res && res.data && isString(res.data) ? JSON.parse(res.data) : res.data;
if (res.code === 0 && res.data === 'true') {
store.dispatch(
actionCreators.getConfig(
Object.assign({}, window.globalConfig, {
hasGateWay,
apiGatewayDomain: `${window.location.origin}/PandaCore`,
}),
),
);
}
});
// eslint-disable-next-line react-hooks/rules-of-hooks
const client = params.getParams('client')
appService
.queryConfig({
client: client,
})
.then(res => {
if (res) {
const data = res;
if (!data.client) {
data.client = params.getParams('client') || 'city';
}
// Cookies.set('city', data.client);
store.dispatch(
actionCreators.getConfig(
Object.assign({}, window.globalConfig, data),
),
);
//Cookies.set('city', params.getParams('client'))
if (data.loginTemplate === '新春 - 智联.html') {
updateTheme('#ff9600');
}
// eslint-disable-next-line no-new
if (getToken()) {
// eslint-disable-next-line no-new
new Login(
{
global: Object.assign({}, data, {
token: getToken(),
}),
// eslint-disable-next-line no-shadow
updateConfig: data =>
store.dispatch(actionCreators.getConfig(data)),
isInit: false,
logout: () => store.dispatch(actionCreators.logout()),
},
() => {
(async () => {
(await (getToken() &&
window.globalConfig &&
window.globalConfig.token)) && initMicroApps(loader, store);
})();
},
true,
);
}
// eslint-disable-next-line no-shadow
}
return res;
})
// eslint-disable-next-line no-shadow
.then(res => {
// eslint-disable-next-line no-use-before-define
// initSensorType();
// eslint-disable-next-line no-use-before-define
// initIsMock();
render({ appContent: '', loading: true });
})
.catch(error => {
console.log(error);
store.dispatch(actionCreators.getConfigError(error));
});
}
};
\ No newline at end of file
......@@ -3,6 +3,7 @@ import Cookies from 'js-cookie';
import { connect } from 'react-redux';
import { Redirect } from '@wisdom-utils/runtime';
import { PageLoading } from '@ant-design/pro-layout';
import { event } from 'microser-data';
import { stringify } from 'querystring';
import { getBaseName } from '../utils/utils';
import _ from 'lodash';
......@@ -32,6 +33,7 @@ class SecurityLayout extends React.Component {
this.props.updateCurrentIndex && this.props.updateCurrentIndex(0);
let client = global.client || Cookies.get('city');
client = client !== 'undefined' || !_.isNull(client) || !_.isUndefined(client) ? client: 'city';
// event.emit(?'event:initConfig');
return (
<Redirect to={`/user/login?client=${client}`} />
);
......
......@@ -6,6 +6,7 @@ import Cookies from 'js-cookie';
import sha1 from 'sha1';
import { appService } from '@/api';
import { getUserInfo, getWebSiteConfig } from '@/api/service/base'
import {
SERVICE_APP_LOGIN_MODE,
SERVICE_INTERFACE_SUCCESS_CODE,
......@@ -74,8 +75,7 @@ class Login {
const self = this;
// eslint-disable-next-line no-undef
appService
.getUserInfo({
getUserInfo({
token: this.globalConfig.token,
subOID: 'subOID',
site: this.getLocalSiteBytoken(token),
......@@ -192,8 +192,8 @@ class Login {
getWebConfig(token, getIndustry) {
const self = this;
// eslint-disable-next-line no-undef
appService
.getWebSiteConfig({
getWebSiteConfig({
client: self.globalConfig.client,
token,
'request.preventCache': Date.now(),
......@@ -242,8 +242,8 @@ class Login {
self.globalConfig.userInfo.site.length > 0
) {
// eslint-disable-next-line no-undef,no-underscore-dangle
appService
.getWebSiteConfig(
getWebSiteConfig(
{
client: self.globalConfig.client,
token,
......@@ -589,8 +589,7 @@ class Login {
const tk = response.token;
this.globalConfig.token = tk;
// eslint-disable-next-line no-undef,no-debugger
appService
.getUserInfo(
getUserInfo(
{
token: tk,
subOID: 'subOID',
......@@ -668,7 +667,7 @@ class Login {
if (self.isSignIn || !!industry) {
// eslint-disable-next-line no-undef
appService.getUserInfo(
getUserInfo(
{
token,
subOID: 'subOID',
......
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