Commit 76b86c75 authored by 邓晓峰's avatar 邓晓峰

fix: 修改静态资源问题

parent d9fe2826
function genActiveRule(routerPrefix) { export function genActiveRule(routerPrefix) {
return location => location.pathname.startsWith(routerPrefix); return location => location.pathname.startsWith(routerPrefix);
} }
export default { 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 = { module.exports = {
mock: true, mock: true,
assetsRoot: process.env.NODE_ENV !== 'production' ? proxyURL : window.location.origin,
dev: { dev: {
'/CityInterface': { '/CityInterface': {
// target: 'http://192.168.10.150:8777', target: proxyURL,
target: 'https://panda-water.cn', // target: 'https://panda-water.cn',
// target: 'http://192.168.19.102:8055', // target: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
...@@ -20,9 +24,9 @@ module.exports = { ...@@ -20,9 +24,9 @@ module.exports = {
}, },
}, },
'/cityinterface': { '/cityinterface': {
// target: 'http://192.168.10.150:8777', target: proxyURL,
// target: 'http://192.168.10.150:8050', // 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: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
...@@ -50,10 +54,11 @@ module.exports = { ...@@ -50,10 +54,11 @@ module.exports = {
}, },
}, },
'/Publish': { '/Publish': {
target: proxyURL,
// target: 'http://192.168.12.8:8098', // target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888', // target: 'http://192.168.10.20:8888',
// target: 'http://192.168.10.151:8055', // 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: 'http://192.168.19.102:8055',
// target: 'https://panda-water.com', // target: 'https://panda-water.com',
// target: 'http://192.168.10.150:8050', // target: 'http://192.168.10.150:8050',
...@@ -68,15 +73,7 @@ module.exports = { ...@@ -68,15 +73,7 @@ module.exports = {
}, },
prod: { prod: {
'/CityInterface': { '/CityInterface': {
// 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',
// target: 'http://192.168.19.103:8112',
// target: 'http://192.168.12.8:8098',
// target: 'http://192.168.10.20:8888',
changeOrigin: true, changeOrigin: true,
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
...@@ -86,13 +83,7 @@ module.exports = { ...@@ -86,13 +83,7 @@ module.exports = {
}, },
}, },
'/cityinterface': { '/cityinterface': {
// target: 'http://192.168.10.151:8055',
// 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',
// target: 'http://192.168.10.20:8888',
changeOrigin: true, changeOrigin: true,
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
...@@ -103,10 +94,6 @@ module.exports = { ...@@ -103,10 +94,6 @@ module.exports = {
}, },
'/cityjson': { '/cityjson': {
target: 'https://pv.sohu.com', 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, changeOrigin: true,
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
...@@ -116,13 +103,7 @@ module.exports = { ...@@ -116,13 +103,7 @@ module.exports = {
}, },
}, },
'/Publish': { '/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: '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, changeOrigin: true,
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
......
...@@ -34,8 +34,6 @@ app.get('*.js', (req, res, next) => { ...@@ -34,8 +34,6 @@ app.get('*.js', (req, res, next) => {
next(); next();
}); });
// Start your app. // Start your app.
app.listen(port, host, async err => { app.listen(port, host, async err => {
if (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 { useHistory, useLocation } from 'react-router-dom';
import { getKeyName } from '../../utils/utils';
const TabPanes = props => { const TabPanes = props => {
const [activeKey, setActiveKey] = useState(''); const [activeKey, setActiveKey] = useState('');
const [panes, setPanes] = useState([ const [panes, setPanes] = useState([
...@@ -24,9 +25,9 @@ const TabPanes = props => { ...@@ -24,9 +25,9 @@ const TabPanes = props => {
} = props; } = props;
const history = useHistory(); const history = useHistory();
const { pathnname, search } = useLocation(); const { pathname, search } = useLocation();
const fullPath = pathnname + search; const fullPath = pathname + search;
const storeTabs = useCallback( const storeTabs = useCallback(
ps => { ps => {
...@@ -37,6 +38,72 @@ const TabPanes = props => { ...@@ -37,6 +38,72 @@ const TabPanes = props => {
); );
const resetTabs = useCallback(() => { 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 { ...@@ -27,6 +27,7 @@ import {
VALIDATE_AUTH, VALIDATE_AUTH,
GET_MICRO_MOUNTED_STATUS, GET_MICRO_MOUNTED_STATUS,
} from './constants'; } from './constants';
const proxy = require('../../../../config/proxy');
const keywordStorage = new Storage( const keywordStorage = new Storage(
`__global_search_keywords__micro_${window.location.hostname}`, `__global_search_keywords__micro_${window.location.hostname}`,
...@@ -76,6 +77,7 @@ const appReducer = (state = initialState, action) => { ...@@ -76,6 +77,7 @@ const appReducer = (state = initialState, action) => {
// eslint-disable-next-line no-underscore-dangle // eslint-disable-next-line no-underscore-dangle
action.data, action.data,
{ {
assetsRoot: proxy.assetsRoot,
allWidgets: action.data.widgets || [], allWidgets: action.data.widgets || [],
env: process.env.NODE_ENV === 'development' ? 'daily' : 'prod', env: process.env.NODE_ENV === 'development' ? 'daily' : 'prod',
}, },
......
...@@ -33,7 +33,7 @@ import SecurityLayout from './SecurityLayout'; ...@@ -33,7 +33,7 @@ import SecurityLayout from './SecurityLayout';
import Site from './Site'; import Site from './Site';
import styles from './UserLayout.less'; import styles from './UserLayout.less';
import defaultSetting from '../../config/defaultSetting'; 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 antIcon = <LoadingOutlined style={{ fontSize: 12 }} spin />;
const baseURI = isProd const baseURI = isProd
...@@ -54,10 +54,7 @@ const noMatch = ( ...@@ -54,10 +54,7 @@ const noMatch = (
const renderIcon = (icon, size, alias) => { const renderIcon = (icon, size, alias) => {
const transformIcon = () => icon.replace(/\s*/g, ''); const transformIcon = () => icon.replace(/\s*/g, '');
const isURL = /^(http|https)/; const url = window.globalConfig.transformDevAssetsBaseURL(transformIcon())
const url = isURL.test(transformIcon())
? transformIcon()
: `${baseURI}/${alias}/${transformIcon()}`;
return ( return (
<img <img
src={url} src={url}
...@@ -75,7 +72,9 @@ const menuExtraRender = currentRoutes => { ...@@ -75,7 +72,9 @@ const menuExtraRender = currentRoutes => {
if (currentRoutes) { if (currentRoutes) {
const iconURL = const iconURL =
currentRoutes && currentRoutes.extData && currentRoutes.extData.icon currentRoutes && currentRoutes.extData && currentRoutes.extData.icon
? `${baseURI}/civweb4/${currentRoutes.extData.icon}` ? window.globalConfig.transformDevAssetsBaseURL(
currentRoutes.extData.icon,
)
: ''; : '';
return ( return (
<> <>
......
...@@ -7,7 +7,7 @@ import { ...@@ -7,7 +7,7 @@ import {
start, start,
} from 'qiankun'; } from 'qiankun';
import 'kit_logger'; import 'kit_logger';
import micorConfig from '../config/micor'; import micorConfig, { genActiveRule } from '../config/micor';
import pkg from '../package.json'; import pkg from '../package.json';
import { FILTER_FOLER_REG } from './utils/constants'; import { FILTER_FOLER_REG } from './utils/constants';
import { actionCreators } from './containers/App/store'; import { actionCreators } from './containers/App/store';
...@@ -29,8 +29,24 @@ const MICRO_STATUS = { ...@@ -29,8 +29,24 @@ const MICRO_STATUS = {
}; };
export const initMicroApps = (loader, store) => { export const initMicroApps = (loader, store) => {
/* eslint-disable */
const config = createStoreage.get('globalConfig');
const application = config.products || [];
const entrys = 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( registerMicroApps(
entrys.map(item => { entrys.map(item => {
...@@ -53,7 +69,6 @@ export const initMicroApps = (loader, store) => { ...@@ -53,7 +69,6 @@ export const initMicroApps = (loader, store) => {
], ],
beforeMount: [ beforeMount: [
app => { app => {
debugger
store.dispatch(actionCreators.updateMicroMounted(false)); store.dispatch(actionCreators.updateMicroMounted(false));
Logger.info(`[LifeCycle] before mount %c%s ${app.name}`); Logger.info(`[LifeCycle] before mount %c%s ${app.name}`);
}, },
......
...@@ -543,7 +543,7 @@ const Login = forwardRef((props, _ref) => { ...@@ -543,7 +543,7 @@ const Login = forwardRef((props, _ref) => {
> >
<img <img
role="logo" role="logo"
src={`https://panda-water.cn/web4/${props.global.logo}`} src={props.global.transformDevAssetsBaseURL(props.global.logo)}
/> />
<div <div
className={classNames( className={classNames(
......
...@@ -52,7 +52,6 @@ export function getBaseName() { ...@@ -52,7 +52,6 @@ export function getBaseName() {
} }
const cache = {}; const cache = {};
export function findPathByLeafId(leafId, nodes, path, key) { export function findPathByLeafId(leafId, nodes, path, key) {
debugger
if (path === undefined) { if (path === undefined) {
path = {}; 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