Commit d92c9e5c authored by 邓晓峰's avatar 邓晓峰

fix: 修复loading 加载时机

parents ef0aa0e8 d395e004
Pipeline #23273 skipped with stages
function genActiveRule(routerPrefix) {
export function genActiveRule(routerPrefix) {
return location => location.pathname.startsWith(routerPrefix);
}
export default {
......
/* eslint-disable */
// const proxyURL = process.env.NODE_ENV !== 'production' ? 'http://192.168.10.150:8777' : window.location.origin;
const proxyURL = 'https://panda-water.cn';
module.exports = {
mock: true,
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : window.location.origin,
dev: {
'/CityInterface': {
// target: 'http://192.168.10.150:8777',
target: 'https://panda-water.cn',
target: proxyURL,
// target: 'https://panda-water.cn',
// target: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com',
......@@ -20,9 +24,9 @@ module.exports = {
},
},
'/cityinterface': {
// target: 'http://192.168.10.150:8777',
target: proxyURL,
// target: 'http://192.168.10.150:8050',
target: 'https://panda-water.cn',
// target: 'https://panda-water.cn',
// target: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com',
// target: 'http://192.168.12.8:8098',
......@@ -50,11 +54,11 @@ module.exports = {
},
},
'/Publish': {
// target: 'http://192.168.10.150:8777',
target: proxyURL,
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'https://panda-water.cn',
// target: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com',
// target: 'http://192.168.10.150:8050',
......@@ -80,15 +84,7 @@ module.exports = {
},
prod: {
'/CityInterface': {
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com',
// target: 'http://192.168.10.150:8050',
// target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
......@@ -98,13 +94,7 @@ module.exports = {
},
},
'/cityinterface': {
// target: 'http://192.168.10.151:8055',
// target: 'http://192.168.10.150:8050',
target: 'https://panda-water.cn',
// target: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com',
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
......@@ -115,10 +105,6 @@ module.exports = {
},
'/cityjson': {
target: 'https://pv.sohu.com',
// target: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com',
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
......@@ -128,13 +114,7 @@ module.exports = {
},
},
'/Publish': {
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055',
target: 'https://panda-water.cn',
// target: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com',
// target: 'http://192.168.10.150:8050',
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
......
......@@ -34,8 +34,6 @@ app.get('*.js', (req, res, next) => {
next();
});
// Start your app.
app.listen(port, host, async err => {
if (err) {
......
import React, { useState, useRef, useCallback } from 'react';
import React, { useState, useRef, useCallback, useEffect } from 'react';
import { useHistory, useLocation } from 'react-router-dom';
import { getKeyName } from '../../utils/utils';
const TabPanes = props => {
const [activeKey, setActiveKey] = useState('');
const [panes, setPanes] = useState([
......@@ -24,9 +25,9 @@ const TabPanes = props => {
} = props;
const history = useHistory();
const { pathnname, search } = useLocation();
const { pathname, search } = useLocation();
const fullPath = pathnname + search;
const fullPath = pathname + search;
const storeTabs = useCallback(
ps => {
......@@ -37,6 +38,72 @@ const TabPanes = props => {
);
const resetTabs = useCallback(() => {
const initPanes = curTab.reduce((prev, next) => {});
});
const initPanes = curTab.reduce((prev, next) => {
const { title, tabKey, Content } = getKeyName(next);
return [
...prev,
{
title,
key: tabKey,
content: Content,
closable: tabKey !== 'home',
path: next,
},
];
}, []);
const { tabKey } = getKeyName(pathname);
setPanes(initPanes);
setActiveKey(tabKey);
}, [curTab, pathname]);
useEffect(() => {
resetTabs();
}, [resetTabs]);
const onChange = tabKey => {
setActiveKey(tabKey);
};
const remove = targetKey => {
const delIndex = panes.findIndex(item => item.key === targetKey);
panes.splice(delIndex, 1);
if (targetKey !== activeKey) {
const nextKey = activeKey;
setPanes(panes);
setActiveKey(nextKey);
storeTabs(panes);
return;
}
const nextPath = curTab[delIndex - 1];
const { tabKey } = getKeyName(nextPath);
if (nextPath !== '/') {
remove(tabKey);
history.push(curTab[delIndex - 2]);
} else {
history.push(nextPath);
}
setPanes(panes);
storeTabs(panes);
};
const onEdit = (targetKey, action) =>
action === 'remove' && remove(targetKey);
const onTabClick = targetKey => {
const { path } = panes.filter(item => item.key === targetKey)[0];
history.push({ pathname: path });
};
const refreshTab = () => {
setIsReload(true);
setTimeout(() => {
setIsReload(false);
}, 1000);
setStoreData('SET_RELOADPATH', pathname + search);
setTimeout(() => {
setStoreData('SET_RELOADPATH', 'null');
}, 500);
};
};
......@@ -27,6 +27,7 @@ import {
VALIDATE_AUTH,
GET_MICRO_MOUNTED_STATUS,
} from './constants';
const proxy = require('../../../../config/proxy');
const keywordStorage = new Storage(
`__global_search_keywords__micro_${window.location.hostname}`,
......@@ -76,6 +77,7 @@ const appReducer = (state = initialState, action) => {
// eslint-disable-next-line no-underscore-dangle
action.data,
{
assetsRoot: proxy.assetsRoot,
allWidgets: action.data.widgets || [],
env: process.env.NODE_ENV === 'development' ? 'daily' : 'prod',
},
......
......@@ -33,7 +33,7 @@ import SecurityLayout from './SecurityLayout';
import Site from './Site';
import styles from './UserLayout.less';
import defaultSetting from '../../config/defaultSetting';
import Login from '../pages/user/login/login';
// import Login from '../pages/user/login/login';
const antIcon = <LoadingOutlined style={{ fontSize: 12 }} spin />;
const baseURI = isProd
......@@ -54,10 +54,7 @@ const noMatch = (
const renderIcon = (icon, size, alias) => {
const transformIcon = () => icon.replace(/\s*/g, '');
const isURL = /^(http|https)/;
const url = isURL.test(transformIcon())
? transformIcon()
: `${baseURI}/${alias}/${transformIcon()}`;
const url = window.globalConfig.transformDevAssetsBaseURL(transformIcon())
return (
<img
src={url}
......@@ -75,7 +72,9 @@ const menuExtraRender = currentRoutes => {
if (currentRoutes) {
const iconURL =
currentRoutes && currentRoutes.extData && currentRoutes.extData.icon
? `${baseURI}/civweb4/${currentRoutes.extData.icon}`
? window.globalConfig.transformDevAssetsBaseURL(
currentRoutes.extData.icon,
)
: '';
return (
<>
......
......@@ -7,7 +7,7 @@ import {
start,
} from 'qiankun';
import 'kit_logger';
import micorConfig from '../config/micor';
import micorConfig, { genActiveRule } from '../config/micor';
import pkg from '../package.json';
import { FILTER_FOLER_REG } from './utils/constants';
import { actionCreators } from './containers/App/store';
......@@ -29,9 +29,28 @@ const MICRO_STATUS = {
};
export const initMicroApps = (loader, store) => {
<<<<<<< HEAD
console.log(window.globalConfig);
=======
/* eslint-disable */
const config = createStoreage.get('globalConfig');
const application = config.products || [];
>>>>>>> d395e004dcda0c599173220f273809c42294cca2
const entrys =
process.env.NODE_ENV !== 'production' ? micorConfig.dev : micorConfig.prod;
process.env.NODE_ENV !== 'production'
? micorConfig.dev
: (application && Array.isArray(application) && application.length > 0 ) ? application.map(item => {
item.name = item.PackageName;
item.entry = item.RouteUrl.replace(
// eslint-disable-next-line no-template-curly-in-string
'localhost:${port}',
window.location.host,
);
item.container = '#micro-container';
item.activeRule = genActiveRule(`/civbase/${item.PackageName}`);
item.props = JSON.parse(item.DefaultSetting);
return item;
}): micorConfig.prod;
registerMicroApps(
entrys.map(item => {
......@@ -55,6 +74,10 @@ export const initMicroApps = (loader, store) => {
],
beforeMount: [
app => {
<<<<<<< HEAD
store.dispatch(actionCreators.updateMicroMounted(false));
=======
>>>>>>> 0e8f6915ac6e5dc6a04d3511197675755ca3bc00
Logger.info(`[LifeCycle] before mount %c%s ${app.name}`);
},
],
......
......@@ -545,7 +545,7 @@ const Login = forwardRef((props, _ref) => {
>
<img
role="logo"
src={`https://panda-water.cn/web4/${props.global.logo}`}
src={props.global.transformDevAssetsBaseURL(props.global.logo)}
/>
<div
className={classNames(
......
......@@ -53,7 +53,6 @@ export function getBaseName() {
}
const cache = {};
export function findPathByLeafId(leafId, nodes, path, key) {
debugger
if (path === undefined) {
path = {};
}
......
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