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

fix: 修复无限嵌套路由渲染

parent 8917bfef
Pipeline #35010 passed with stages
in 58 minutes 12 seconds
This diff was suppressed by a .gitattributes entry.
...@@ -90,6 +90,16 @@ module.exports = { ...@@ -90,6 +90,16 @@ module.exports = {
'/CityTemp': '/CityTemp', '/CityTemp': '/CityTemp',
}, },
}, },
'/civweb4': {
target: proxyURL,
changeOrigin: true,
headers: {
'Access-Control-Allow-Origin': '*',
},
pathRewrite: {
'/civweb4': '/civweb4',
},
},
'/web4': { '/web4': {
target: proxyURL, target: proxyURL,
changeOrigin: true, changeOrigin: true,
...@@ -97,7 +107,7 @@ module.exports = { ...@@ -97,7 +107,7 @@ module.exports = {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
}, },
pathRewrite: { pathRewrite: {
'/web4': '/web4', 'web4': 'web4',
}, },
} }
}, },
......
...@@ -65,7 +65,7 @@ const defaultConfig = { ...@@ -65,7 +65,7 @@ const defaultConfig = {
edge: 13, edge: 13,
ios: 10, ios: 10,
ie: 11, ie: 11,
}, }
}; };
module.exports = options => { module.exports = options => {
const chainConfig = new Config(); const chainConfig = new Config();
...@@ -76,7 +76,7 @@ module.exports = options => { ...@@ -76,7 +76,7 @@ module.exports = options => {
const isProd = process.env.NODE_ENV === 'production'; const isProd = process.env.NODE_ENV === 'production';
const disableCompress = process.env.COMPRESS === 'none'; const disableCompress = process.env.COMPRESS === 'none';
const isWebpack5 = webpack.version.startsWith('5'); const isWebpack5 = webpack.version.startsWith('5');
const cwd = process.cwd();
const devtool = options.devtool || false; const devtool = options.devtool || false;
chainConfig.devtool( chainConfig.devtool(
...@@ -86,9 +86,9 @@ module.exports = options => { ...@@ -86,9 +86,9 @@ module.exports = options => {
: devtool || 'cheap-module-source-map' : devtool || 'cheap-module-source-map'
: devtool, : devtool,
); );
const mfsu = defineConfig.mfsu;
const useHash = defineConfig.hash && isProd; const useHash = defineConfig.hash && isProd;
const absOutputPath = process.env.npm_config_releasepath const absOutputPath = process.env.npm_config_releasepath
? path.resolve( ? path.resolve(
process.env.npm_config_releasepath, process.env.npm_config_releasepath,
...@@ -100,7 +100,7 @@ module.exports = options => { ...@@ -100,7 +100,7 @@ module.exports = options => {
.path(absOutputPath) .path(absOutputPath)
.filename(useHash ? `[name].[contenthash:8].js` : `[name].js`) .filename(useHash ? `[name].[contenthash:8].js` : `[name].js`)
.chunkFilename( .chunkFilename(
useHash ? `[name].[contenthash:8].async.js` : `[name].chunk.js`, useHash ? `[name].[contenthash:8].async.js` : `[name].js`,
) )
.publicPath(`/${pkg.name.toLocaleLowerCase()}/`) .publicPath(`/${pkg.name.toLocaleLowerCase()}/`)
.futureEmitAssets(true) .futureEmitAssets(true)
...@@ -173,6 +173,7 @@ module.exports = options => { ...@@ -173,6 +173,7 @@ module.exports = options => {
{ libraryName: 'antd-mobile', libraryDirectory: 'es', style: true }, { libraryName: 'antd-mobile', libraryDirectory: 'es', style: true },
]), ]),
}); });
let babelOpts = { let babelOpts = {
sourceType: 'unambiguous', sourceType: 'unambiguous',
babelrc: false, babelrc: false,
...@@ -187,10 +188,17 @@ module.exports = options => { ...@@ -187,10 +188,17 @@ module.exports = options => {
chainConfig.module chainConfig.module
.rule('js') .rule('js')
.test(/\.(js|mjs|jsx|ts|tsx)$/) .test(/\.(js|mjs|jsx|ts|tsx)$/)
.exclude.add(/node_modules/) .include
.add([
cwd,
...(process.env.APP_ROOT ? [process.cwd()] : [])
]).end()
.exclude
.add(/node_modules/)
.add(/\.mfsu/)
.end() .end()
.use('babel-loader') .use('babel-loader')
.loader(require.resolve('babel-loader')) .loader(require.resolve('@umijs/deps/compiled/babel-loader'))
.options(babelOpts); .options(babelOpts);
if (defineConfig.extraBabelIncludes) { if (defineConfig.extraBabelIncludes) {
...@@ -214,6 +222,8 @@ module.exports = options => { ...@@ -214,6 +222,8 @@ module.exports = options => {
}); });
} }
const staticDir = mfsu ? 'mf-static' : 'static';
chainConfig.module chainConfig.module
.rule('images') .rule('images')
.test(/\.(png|jpe?g|gif|webp|ico)(\?.*)?$/) .test(/\.(png|jpe?g|gif|webp|ico)(\?.*)?$/)
...@@ -221,17 +231,28 @@ module.exports = options => { ...@@ -221,17 +231,28 @@ module.exports = options => {
.loader(require.resolve('url-loader')) .loader(require.resolve('url-loader'))
.options({ .options({
limit: defineConfig.inlineLimit || 10000, limit: defineConfig.inlineLimit || 10000,
name: 'static/[name].[hash:8].[ext]', name: `${staticDir}/[name].[hash:8].[ext]`,
// require 图片的时候不用加 .default // require 图片的时候不用加 .default
esModule: false, esModule: false,
fallback: { fallback: {
loader: require.resolve('file-loader'), loader: require.resolve('file-loader'),
options: { options: {
name: 'static/[name].[hash:8].[ext]', name: `${staticDir}/[name].[hash:8].[ext]`,
esModule: false, esModule: false,
}, },
}, },
}); });
chainConfig.module
.rule('avif')
.test(/\.(avif)(\?.*)?$/)
.use('file-loader')
.loader(require.resolve('file-loader'))
.options({
name: `${staticDir}/[name].[hash:8].[ext]`,
esModule: false,
});
chainConfig.module chainConfig.module
.rule('svg') .rule('svg')
...@@ -239,7 +260,7 @@ module.exports = options => { ...@@ -239,7 +260,7 @@ module.exports = options => {
.use('file-loader') .use('file-loader')
.loader(require.resolve('@umijs/deps/compiled/file-loader')) .loader(require.resolve('@umijs/deps/compiled/file-loader'))
.options({ .options({
name: 'static/[name].[hash:8].[ext]', name: `${staticDir}/[name].[hash:8].[ext]`,
esModule: false, esModule: false,
}) })
.end(); .end();
...@@ -250,7 +271,7 @@ module.exports = options => { ...@@ -250,7 +271,7 @@ module.exports = options => {
.use('file-loader') .use('file-loader')
.loader(require.resolve('file-loader')) .loader(require.resolve('file-loader'))
.options({ .options({
name: 'static/[name].[hash:8].[ext]', name: `${staticDir}/[name].[hash:8].[ext]`,
esModule: false, esModule: false,
}); });
...@@ -270,6 +291,15 @@ module.exports = options => { ...@@ -270,6 +291,15 @@ module.exports = options => {
.use('raw-loader') .use('raw-loader')
.loader(require.resolve('raw-loader')); .loader(require.resolve('raw-loader'));
if(defineConfig.workerLoader) {
chainConfig.module
.rule('worker')
.test(/.*worker.(ts|js)/)
.use('worker-loader')
.loader(require.resolve('worker-loader'))
.options(defineConfig.workerLoader);
}
css({ css({
type: 'csr', type: 'csr',
config: defineConfig, config: defineConfig,
...@@ -369,7 +399,7 @@ module.exports = options => { ...@@ -369,7 +399,7 @@ module.exports = options => {
.plugin('replaceTheme') .plugin('replaceTheme')
.use(ThemeColorReplacer, [themePluginOption]); .use(ThemeColorReplacer, [themePluginOption]);
const cwd = process.cwd();
const copyPatterns = [ const copyPatterns = [
fs.existsSync(path.join(process.cwd(), 'public')) && { fs.existsSync(path.join(process.cwd(), 'public')) && {
from: path.join(cwd, 'public'), from: path.join(cwd, 'public'),
...@@ -514,7 +544,14 @@ module.exports = options => { ...@@ -514,7 +544,14 @@ module.exports = options => {
} }
if (process.env.PROGRESS !== 'none') { if (process.env.PROGRESS !== 'none') {
chainConfig.plugin('progress').use(require.resolve('webpackbar')); chainConfig.plugin('progress').use(require.resolve('webpackbar'), [
mfsu ? {
name: 'MFSU',
color: '#facc00'
}: defineConfig.ssr ? {
name: type === 'ssr' ? 'Server': 'Client'
}: {}
]);
} }
if (process.env.FRIENDLY_ERROR !== 'none') { if (process.env.FRIENDLY_ERROR !== 'none') {
...@@ -578,20 +615,6 @@ module.exports = options => { ...@@ -578,20 +615,6 @@ module.exports = options => {
}, },
]); ]);
} }
if(defineConfig.esbuild) {
const { target = 'es2015' } = defineConfig.esbuild || {};
const optsMap = {
['csr']: {
minify: true,
target
}
};
const opt = optsMap['csr'];
chainConfig.optimization.minimize = true;
chainConfig.optimization.minimizer = [new ESBuildMinifyPlugin(opt)];
chainConfig.plugin('es-build').use(new ESBuildPlugin())
}
}, },
); );
...@@ -607,9 +630,24 @@ module.exports = options => { ...@@ -607,9 +630,24 @@ module.exports = options => {
}); });
} }
if(defineConfig.esbuild) {
const { target = 'es2015' } = defineConfig.esbuild || {};
const optsMap = {
['csr']: {
minify: true,
target
}
};
const opt = optsMap['csr'];
chainConfig.optimization.minimize = true;
chainConfig.optimization.minimizer = [new ESBuildMinifyPlugin(opt)];
chainConfig.plugin('es-build').use(new ESBuildPlugin())
}
if (defineConfig.chainWebpack) { if (defineConfig.chainWebpack) {
defineConfig.chainWebpack(chainConfig, { defineConfig.chainWebpack(chainConfig, {
type: 'csr', type: 'csr',
// mfsu,
env: process.env, env: process.env,
webpack, webpack,
createCSSRule: createCSSRuleFn, createCSSRule: createCSSRuleFn,
...@@ -647,6 +685,34 @@ module.exports = options => { ...@@ -647,6 +685,34 @@ module.exports = options => {
entry.push(require.resolve('./runtimePublicPathEntry')); entry.push(require.resolve('./runtimePublicPathEntry'));
} }
// const nodeLibs = require('node-libs-browser');
// const ProvidePlugin = webpack.ProvidePlugin;
// if(isWebpack5) {
// // ret.plugins.push({
// // new ProvidePlugin({
// // process: nodeLibs['process']
// // })
// // });
// // ret.plugins.push({
// // new ProvidePlugin({
// // Buffer: ['buffer', 'Buffer'],
// // })
// // });
// ret.resolve.fallback = {
// ...ret.resolve.fallback,
// ...Object.keys(nodeLibs).reduce((memo, key) => {
// if(nodeLibs[key]) {
// memo[key] = nodeLibs[key]
// } else {
// memo[key] = false
// };
// return memo
// }, {}),
// http: false,
// https: false,
// }
// }
ret = { ret = {
...ret, ...ret,
// mode: options.mode, // mode: options.mode,
......
...@@ -14,8 +14,38 @@ module.exports = require('./webpack.base.babel')({ ...@@ -14,8 +14,38 @@ module.exports = require('./webpack.base.babel')({
path.join(process.cwd(), 'src/app.js'), // Start with js/app.js path.join(process.cwd(), 'src/app.js'), // Start with js/app.js
], ],
optimization: { optimization: {
namedModules: true,
namedChunks: true,
runtimeChunk: {
name: "runtime",
},
splitChunks: { splitChunks: {
chunks: 'all', name: false,
chunks: "all", // all(全部), async(异步的模块),initial(同步的模块)
minSize: 20000, // 表示文件大于1k的时候才对它进行打包
minChunks: 2, // 当某个模块满足minChunks引用次数时,才会被打包。
maxAsyncRequests: 5, // 在打包某个模块的时候,最多分成5个chunk,多余的会合到最后一个chunk中
maxInitialRequests: Infinity,
automaticNameDelimiter: "~", // 当vendors或者default中的filename不填时,打包出来的文件名就会带~
cacheGroups: {
default: false,
vendors: {
// 将从node_modules中引入的模块统一打包到common.js文件中
name: "common",
chunks: "all",
minChunks: 2,
test: /[\\/]node_modules[\\/]/,
},
styles: {
// css统一打包到common.css文件中
name: "common",
chunks: "all",
minChunks: 2,
test: /\.(css|less|scss|stylus)$/,
enforce: true,
priority: 50,
},
},
}, },
}, },
plugins: [ plugins: [
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
"pinyin-match": "^1.1.1", "pinyin-match": "^1.1.1",
"promise.prototype.finally": "^3.1.2", "promise.prototype.finally": "^3.1.2",
"prop-types": "15.7.2", "prop-types": "15.7.2",
"qiankun": "^2.4.10", "qiankun": "^2.4.28",
"qrcode.react": "^1.0.0", "qrcode.react": "^1.0.0",
"react": "16.12.0", "react": "16.12.0",
"react-dom": "16.12.0", "react-dom": "16.12.0",
......
// @ts-ignore
/* eslint-disable */
import { request } from '@wisdom-utils/utils';
/** 获取是否启用网关配置 GET /GateWayConfig */
export async function GateWayConfig(options) {
return request('/GateWayConfig', {
method: 'GET',
...(options || {}),
});
}
/** 根据配置项名称查询配置_系统信息数据 GET /SysConfiguration */
export async function SysConfiguration(params, options) {
return request('/SysConfiguration', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
// @ts-ignore
/* eslint-disable */
import { request } from '@wisdom-utils/utils';
/** 数据库测试连接 GET /DBManager/ConnectionTest */
export async function ConnectionTest(params, options) {
return request('/DBManager/ConnectionTest', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 删除数据库连接 GET /DBManager/DeleteConnection */
export async function DeleteConnection(params, options) {
return request('/DBManager/DeleteConnection', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 修改数据库连接描述信息 GET /DBManager/UpdateConnDesc */
export async function UpdateConnDesc(params, options) {
return request('/DBManager/UpdateConnDesc', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 保存数据库连接 GET /DBManager/SaveConnection */
export async function SaveConnection(params, options) {
return request('/DBManager/SaveConnection', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 获取数据库连接记录 GET /DBManager/GetConnRecord */
export async function GetConnRecord(options) {
return request('/DBManager/GetConnRecord', {
method: 'GET',
...(options || {}),
});
}
/** 获取数据库配置 GET /DBManager/GetDataBaseConfig */
export async function GetDataBaseConfig(options) {
return request('/DBManager/GetDataBaseConfig', {
method: 'GET',
...(options || {}),
});
}
/** 获取数据库列表 GET /DBManager/GetDataBaseList */
export async function GetDataBaseList(params, options) {
return request('/DBManager/GetDataBaseList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
// @ts-ignore
/* eslint-disable */
import { request } from '@wisdom-utils/utils';
/** 单文件上传 POST /FileCenter/UploadSingleFile */
export async function UploadSingleFile(body, options) {
const formData = new FormData();
Object.keys(body).forEach(ele => {
const item = body[ele];
if (item !== undefined && item !== null) {
form.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
}
});
return request('/FileCenter/UploadSingleFile', {
method: 'POST',
data: formData,
...(options || {}),
});
}
/** 获取文件路径 moduleName 可选 CityTemp\icon\androidMenu\menuNew\logo\menu 支持多选用逗号隔开 GET /FileCenter/GetFileUrls */
export async function GetFileUrls(params, options) {
return request('/FileCenter/GetFileUrls', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 保存小程序apk文件 POST /FileCenter/SaveMobileApk */
export async function SaveMobileApk(body, options) {
const formData = new FormData();
Object.keys(body).forEach(ele => {
const item = body[ele];
if (item !== undefined && item !== null) {
form.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
}
});
return request('/FileCenter/SaveMobileApk', {
method: 'POST',
data: formData,
...(options || {}),
});
}
/** 获取移动应用上传apk信息 GET /FileCenter/GetMobileFiles */
export async function GetMobileFiles(params, options) {
return request('/FileCenter/GetMobileFiles', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
// @ts-ignore
/* eslint-disable */
import { request } from '@wisdom-utils/utils';
/** 获取服务调用日志明细 POST /LogCenter/GetOMSLog */
export async function GetOMSLog(body, options) {
return request('/LogCenter/GetOMSLog', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 平均耗时排名统计 POST /LogCenter/TopConsumeList */
export async function TopConsumeList(body, options) {
return request('/LogCenter/TopConsumeList', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 调用频次排名统计 POST /LogCenter/TopCountList */
export async function TopCountList(body, options) {
return request('/LogCenter/TopCountList', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 服务访问量统计 按每分/每5分/每小时/每天 POST /LogCenter/TrafficStatistics */
export async function TrafficStatistics(body, options) {
return request('/LogCenter/TrafficStatistics', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 获取运维登录日志 POST /LogCenter/GetLoginLog */
export async function GetLoginLog(body, options) {
return request('/LogCenter/GetLoginLog', {
method: 'POST',
data: body,
...(options || {}),
});
}
// @ts-ignore
/* eslint-disable */
import { request } from '@wisdom-utils/utils';
/** 登录 POST /OMSLogin */
export async function OMSLogin(body, options) {
const formData = new FormData();
Object.keys(body).forEach(ele => {
const item = body[ele];
if (item !== undefined && item !== null) {
form.append(ele, typeof item === 'object' ? JSON.stringify(item) : item);
}
});
return request('/OMSLogin', {
method: 'POST',
data: formData,
...(options || {}),
});
}
// @ts-ignore
/* eslint-disable */
import { request } from '@wisdom-utils/utils';
/** 获取小程序配置,网站配置和菜单树 userMode 必填 super 或 admin 或common GET /PlatformCenter/MiniAppModuleTree */
export async function MiniAppModuleTree(params, options) {
return request('/PlatformCenter/MiniAppModuleTree', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** web配置 userMode 必填 super 或 admin 或common GET /PlatformCenter/WebModuleTree */
export async function WebModuleTree(params, options) {
return request('/PlatformCenter/WebModuleTree', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 获取手持菜单配置 userMode 必填 super 或 admin 或common GET /PlatformCenter/MobileModuleTree */
export async function MobileModuleTree(params, options) {
return request('/PlatformCenter/MobileModuleTree', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 角色管理获取应用类别 GET /PlatformCenter/GetWebConfigTypes */
export async function GetWebConfigTypes(options) {
return request('/PlatformCenter/GetWebConfigTypes', {
method: 'GET',
...(options || {}),
});
}
/** 删除小程序菜单和角色 GET /PlatformCenter/DeleteMiniMenu */
export async function DeleteMiniMenu(params, options) {
return request('/PlatformCenter/DeleteMiniMenu', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 获取网站配置信息 GET /PlatformCenter/GetWebSiteConfig */
export async function GetWebSiteConfig(params, options) {
return request('/PlatformCenter/GetWebSiteConfig', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 获取当前解决方案名称 GET /PlatformCenter/GetSolutionList */
export async function GetSolutionList(options) {
return request('/PlatformCenter/GetSolutionList', {
method: 'GET',
...(options || {}),
});
}
// @ts-ignore
/* eslint-disable */
import { request } from '@wisdom-utils/utils';
/** 根据机构id获取子机构及所有机构下用户 GET /UserCenter/GroupUserList */
export async function GroupUserList(params, options) {
return request('/UserCenter/GroupUserList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 角色列表按产品分组 GET /UserCenter/RoleGroupList */
export async function RoleGroupList(params, options) {
return request('/UserCenter/RoleGroupList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 修改用户密码 POST /UserCenter/UpdateUserPassword */
export async function UpdateUserPassword(body, options) {
return request('/UserCenter/UpdateUserPassword', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 批量删除用户 GET /UserCenter/DeleteUsers */
export async function DeleteUsers(params, options) {
return request('/UserCenter/DeleteUsers', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 批量设置设置用户角色关联关系 GET /UserCenter/SetUserRoleMap */
export async function SetUserRoleMap(params, options) {
return request('/UserCenter/SetUserRoleMap', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 用户批量更改机构 GET /UserCenter/ModifyUserRole */
export async function ModifyUserRole(params, options) {
return request('/UserCenter/ModifyUserRole', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 分页获取机构列表及用户信息 POST /UserCenter/GroupUserPagingList */
export async function GroupUserPagingList(body, options) {
return request('/UserCenter/GroupUserPagingList', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 获取所有机构列表 GET /UserCenter/GetAllGroup */
export async function GetAllGroup(options) {
return request('/UserCenter/GetAllGroup', {
method: 'GET',
...(options || {}),
});
}
/** 获取某个机构下所有用户列表 GET /UserCenter/GetStationUserList */
export async function GetStationUserList(params, options) {
return request('/UserCenter/GetStationUserList', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 获取产品列表 POST /UserCenter/ProductList */
export async function ProductList(body, options) {
return request('/UserCenter/ProductList', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 修改单个产品 POST /UserCenter/ModifyProduct */
export async function ModifyProduct(body, options) {
return request('/UserCenter/ModifyProduct', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 删除单个产品 GET /UserCenter/DelProduct */
export async function DelProduct(params, options) {
return request('/UserCenter/DelProduct', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
// @ts-ignore
/* eslint-disable */
import { request } from '@wisdom-utils/utils';
/** 根据title获取网站配置 GET /WebSite/GetWebsite */
export async function GetWebsite(params, options) {
return request('/WebSite/GetWebsite', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 添加网站配置 POST /WebSite/AddWebsite */
export async function AddWebsite(body, options) {
return request('/WebSite/AddWebsite', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 修改网站配置 POST /WebSite/EditWebsite */
export async function EditWebsite(body, options) {
return request('/WebSite/EditWebsite', {
method: 'POST',
data: body,
...(options || {}),
});
}
/** 删除网站配置 GET /WebSite/DeleteWebsite */
export async function DeleteWebsite(params, options) {
return request('/WebSite/DeleteWebsite', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
/** 根据client获取网站配置 GET /WebSite/GetConfig */
export async function GetConfig(params, options) {
return request('/WebSite/GetConfig', {
method: 'GET',
params: {
...params,
},
...(options || {}),
});
}
// @ts-ignore
/* eslint-disable */
// API 更新时间:
// API 唯一标识:
import * as ConfigCenter from './ConfigCenter';
import * as DBManager from './DBManager';
import * as FileCenter from './FileCenter';
import * as LogCenter from './LogCenter';
import * as Login from './Login';
import * as PlatformCenter from './PlatformCenter';
import * as UserCenter from './UserCenter';
import * as WebSite from './WebSite';
export default {
ConfigCenter,
DBManager,
FileCenter,
LogCenter,
Login,
PlatformCenter,
UserCenter,
WebSite,
};
import React from 'react'; import React, { Suspense } from 'react';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { renderRoutes } from 'react-router-config'; import { RouteWithSubRoutes, renderRoutes } from '../../utils/routes';
import BootPage from '../../pages/bootpage';
import { import {
Router, Router,
Switch, Switch,
} from '@wisdom-utils/runtime'; } from '@wisdom-utils/runtime';
import { dyRoutes } from '../../routes/config'; import { dyRoutes } from '../../routes/config';
import { Route } from 'react-router-dom';
const pkg = require('../../../package.json'); const pkg = require('../../../package.json');
const config = require('../../../config/config'); const config = require('../../../config/config');
const defaultSetting = config.layout; const defaultSetting = config.layout;
function App(props) { function App(props) {
const { routes } = dyRoutes(props.menu);
return ( return (
<> <>
<Helmet <Helmet
...@@ -36,9 +35,12 @@ function App(props) { ...@@ -36,9 +35,12 @@ function App(props) {
</Helmet> </Helmet>
<Router basename={config.base || pkg.name.toLocaleLowerCase() || ''}> <Router basename={config.base || pkg.name.toLocaleLowerCase() || ''}>
<Switch> <Switch>
{renderRoutes(dyRoutes(props.menu || []).routes)} {
<Route path="/industry" component={BootPage}></Route> routes.map((route, key) => (
{/* <Redirect to="/notFound" /> */} <RouteWithSubRoutes key={key} {...route} />
))
// resultRoutes
}
</Switch> </Switch>
</Router> </Router>
</> </>
......
...@@ -19,13 +19,14 @@ import { ...@@ -19,13 +19,14 @@ import {
Menu, Menu,
Tooltip Tooltip
} from 'antd'; } from 'antd';
import { RouteWithSubRoutes, renderRoutes } from '../utils/routes';
import Icon from '@ant-design/icons'; import Icon from '@ant-design/icons';
import { store } from 'microser-data'; import { store } from 'microser-data';
import classNames from 'classnames'; import classNames from 'classnames';
import { ReactSVG } from 'react-svg' import { ReactSVG } from 'react-svg'
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { Router, Switch } from '@wisdom-utils/runtime';
import RightContent from '@/components/GlobalHeader/ExtendRightContent'; import RightContent from '@/components/GlobalHeader/ExtendRightContent';
import Panel from '@/components/SliderPanel/MinPanel'; import Panel from '@/components/SliderPanel/MinPanel';
import { actionCreators } from '@/containers/App/store'; import { actionCreators } from '@/containers/App/store';
...@@ -437,7 +438,6 @@ const BasicLayout = props => { ...@@ -437,7 +438,6 @@ const BasicLayout = props => {
} }
const logo = props.global.get('bannerLogo')? window.globalConfig.transformDevAssetsBaseURL(props.global.get('bannerLogo')): defaultSetting.logo; const logo = props.global.get('bannerLogo')? window.globalConfig.transformDevAssetsBaseURL(props.global.get('bannerLogo')): defaultSetting.logo;
return ( return (
<SecurityLayout loading> <SecurityLayout loading>
...@@ -597,7 +597,15 @@ const BasicLayout = props => { ...@@ -597,7 +597,15 @@ const BasicLayout = props => {
<div className='ant-pro-grid-content'> <div className='ant-pro-grid-content'>
<div className="ant-pro-grid-content-children"> <div className="ant-pro-grid-content-children">
<div className={layoutStyles['ant-pro-page-container-children-content']}> <div className={layoutStyles['ant-pro-page-container-children-content']}>
<div id="micro-container" className="subapp-container" style={{height: '90.4vh', position: 'relative', top: '59px'}}/>
{
<div id="micro-container" className="subapp-container" style={{height: '90.4vh', position: 'relative', top: '59px'}}>
<Switch>
{props.routes && renderRoutes(props.routes, [])}
</Switch>
</div>
}
</div> </div>
</div> </div>
</div> </div>
......
...@@ -149,15 +149,18 @@ export const initMicroApps = (loader, store) => { ...@@ -149,15 +149,18 @@ export const initMicroApps = (loader, store) => {
defaultApp(); defaultApp();
addGlobalUncaughtErrorHandler(event => { addGlobalUncaughtErrorHandler(event => {
const { error } = event; // const { error } = event;
console.log(event); // console.log("error", event);
const reson = 'Failed to fetch'; // const reson = 'Failed to fetch';
if ( // if (
error && // error &&
error.message.indexOf(MICRO_STATUS.LOADING_SOURCE_CODE) && // error.message.indexOf(MICRO_STATUS.LOADING_SOURCE_CODE) &&
error.message.indexOf(reson) // error.message.indexOf(reson)
) { // ) {
// window.history.pushState({message: '应用服务请求异常,请检查应用配置'}, null, '/civbase/500') // // window.history.pushState({message: '应用服务请求异常,请检查应用配置'}, null, '/civbase/500')
// }
if(event.type === 'error') {
window.history.pushState({message: '应用服务请求异常,请检查应用配置'}, null, '/civbase/404')
} }
}); });
}; };
......
...@@ -29,7 +29,25 @@ export const dyRoutes = routes => { ...@@ -29,7 +29,25 @@ export const dyRoutes = routes => {
{ {
path: '/', path: '/',
component: BasicLayout, component: BasicLayout,
routes: dyRoutes, routes: [
...dyRoutes,
{
path: '/404',
component: dynamic({
loader: () =>
import(/* webpackChunkName: 'p__404' */ '../pages/exception/404'),
loading: LoadingComponent,
}),
},
{
path: '/500',
component: dynamic({
loader: () =>
import(/* webpackChunkName: 'p__500' */ '../pages/exception/500'),
loading: LoadingComponent,
}),
},
],
}, },
process.env.NODE_ENV === 'development' && { process.env.NODE_ENV === 'development' && {
...@@ -43,22 +61,6 @@ export const dyRoutes = routes => { ...@@ -43,22 +61,6 @@ export const dyRoutes = routes => {
loading: LoadingComponent, loading: LoadingComponent,
}), }),
}, },
{
path: '/404',
component: dynamic({
loader: () =>
import(/* webpackChunkName: 'p__404' */ '../pages/exception/404'),
loading: LoadingComponent,
}),
},
{
path: '/500',
component: dynamic({
loader: () =>
import(/* webpackChunkName: 'p__500' */ '../pages/exception/500'),
loading: LoadingComponent,
}),
},
], ],
}; };
}; };
import { transformURL } from './utils'; import { transformURL } from './utils';
import {
Route,
} from '@wisdom-utils/runtime';
export const isURL = function(url) { export const isURL = function(url) {
// eslint-disable-next-line no-useless-escape // eslint-disable-next-line no-useless-escape
...@@ -140,4 +143,34 @@ export const generFlatRoutes = (widgets, parent, subSystem) => { ...@@ -140,4 +143,34 @@ export const generFlatRoutes = (widgets, parent, subSystem) => {
return simpleNormalizeChildren(flatMenu); return simpleNormalizeChildren(flatMenu);
}; };
export function RouteWithSubRoutes(route) {
return (
<Route path={route.path} render={props => {
return <route.component {...props} route={route} routes={route.routes} params={route.params} />;
}
} />)
};
export function renderRoutes(routes, result = []) {
if(!routes) {
result = [];
}
for(let i = 0; i < routes.length; i++) {
const route = routes[i];
result.push(<RouteWithSubRoutes key={i} {...route}/>)
if(route.routes && Array.isArray(route.routes) && route.routes.length > 0) {
renderRoutes(route.routes);
}
}
// return routes.map((route, key) => {
// if(route.routes && Array.isArray(route.routes) && route.routes.length > 0) {
// renderRoutes(route.routes);
// }
// return <RouteWithSubRoutes key={key} {...route}/>
// });
return result;
}
export default generRotes; export default generRotes;
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