初始化 antd-pro
This commit is contained in:
121
admin-web/config/config.js
Normal file
121
admin-web/config/config.js
Normal file
@@ -0,0 +1,121 @@
|
||||
// https://umijs.org/config/
|
||||
import os from 'os';
|
||||
import pageRoutes from './router.config';
|
||||
import webpackPlugin from './plugin.config';
|
||||
import defaultSettings from '../src/defaultSettings';
|
||||
import slash from 'slash2';
|
||||
|
||||
const { pwa, primaryColor } = defaultSettings;
|
||||
const { NODE_ENV, APP_TYPE, TEST } = process.env;
|
||||
|
||||
const plugins = [
|
||||
[
|
||||
'umi-plugin-react',
|
||||
{
|
||||
antd: true,
|
||||
dva: {
|
||||
hmr: true,
|
||||
},
|
||||
locale: {
|
||||
enable: true, // default false
|
||||
default: 'zh-CN', // default zh-CN
|
||||
baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
|
||||
},
|
||||
dynamicImport: {
|
||||
loadingComponent: './components/PageLoading/index',
|
||||
webpackChunkName: true,
|
||||
level: 3,
|
||||
},
|
||||
pwa: pwa
|
||||
? {
|
||||
workboxPluginMode: 'InjectManifest',
|
||||
workboxOptions: {
|
||||
importWorkboxFrom: 'local',
|
||||
},
|
||||
}
|
||||
: {},
|
||||
...(!TEST && os.platform() === 'darwin'
|
||||
? {
|
||||
dll: {
|
||||
include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
|
||||
exclude: ['@babel/runtime'],
|
||||
},
|
||||
hardSource: false,
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
],
|
||||
];
|
||||
|
||||
// 针对 preview.pro.ant.design 的 GA 统计代码
|
||||
// 业务上不需要这个
|
||||
if (APP_TYPE === 'site') {
|
||||
plugins.push([
|
||||
'umi-plugin-ga',
|
||||
{
|
||||
code: 'UA-72788897-6',
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
export default {
|
||||
// add for transfer to umi
|
||||
plugins,
|
||||
define: {
|
||||
APP_TYPE: APP_TYPE || '',
|
||||
},
|
||||
treeShaking: true,
|
||||
targets: {
|
||||
ie: 11,
|
||||
},
|
||||
// 路由配置
|
||||
routes: pageRoutes,
|
||||
// Theme for antd
|
||||
// https://ant.design/docs/react/customize-theme-cn
|
||||
theme: {
|
||||
'primary-color': primaryColor,
|
||||
},
|
||||
externals: {
|
||||
'@antv/data-set': 'DataSet',
|
||||
bizcharts: 'BizCharts',
|
||||
},
|
||||
// proxy: {
|
||||
// '/server/api/': {
|
||||
// target: 'https://preview.pro.ant.design/',
|
||||
// changeOrigin: true,
|
||||
// pathRewrite: { '^/server': '' },
|
||||
// },
|
||||
// },
|
||||
ignoreMomentLocale: true,
|
||||
lessLoaderOptions: {
|
||||
javascriptEnabled: true,
|
||||
},
|
||||
disableRedirectHoist: true,
|
||||
cssLoaderOptions: {
|
||||
modules: true,
|
||||
getLocalIdent: (context, localIdentName, localName) => {
|
||||
if (
|
||||
context.resourcePath.includes('node_modules') ||
|
||||
context.resourcePath.includes('ant.design.pro.less') ||
|
||||
context.resourcePath.includes('global.less')
|
||||
) {
|
||||
return localName;
|
||||
}
|
||||
const match = context.resourcePath.match(/src(.*)/);
|
||||
if (match && match[1]) {
|
||||
const antdProPath = match[1].replace('.less', '');
|
||||
const arr = slash(antdProPath)
|
||||
.split('/')
|
||||
.map(a => a.replace(/([A-Z])/g, '-$1'))
|
||||
.map(a => a.toLowerCase());
|
||||
return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
|
||||
}
|
||||
return localName;
|
||||
},
|
||||
},
|
||||
manifest: {
|
||||
basePath: '/',
|
||||
},
|
||||
|
||||
chainWebpack: webpackPlugin,
|
||||
};
|
||||
33
admin-web/config/plugin.config.js
Normal file
33
admin-web/config/plugin.config.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// Change theme plugin
|
||||
|
||||
import MergeLessPlugin from 'antd-pro-merge-less';
|
||||
import AntDesignThemePlugin from 'antd-theme-webpack-plugin';
|
||||
import path from 'path';
|
||||
|
||||
export default config => {
|
||||
// pro 和 开发环境再添加这个插件
|
||||
if (process.env.APP_TYPE === 'site' || process.env.NODE_ENV !== 'production') {
|
||||
// 将所有 less 合并为一个供 themePlugin使用
|
||||
const outFile = path.join(__dirname, '../.temp/ant-design-pro.less');
|
||||
const stylesDir = path.join(__dirname, '../src/');
|
||||
|
||||
config.plugin('merge-less').use(MergeLessPlugin, [
|
||||
{
|
||||
stylesDir,
|
||||
outFile,
|
||||
},
|
||||
]);
|
||||
|
||||
config.plugin('ant-design-theme').use(AntDesignThemePlugin, [
|
||||
{
|
||||
antDir: path.join(__dirname, '../node_modules/antd'),
|
||||
stylesDir,
|
||||
varFile: path.join(__dirname, '../node_modules/antd/lib/style/themes/default.less'),
|
||||
mainLessFile: outFile, // themeVariables: ['@primary-color'],
|
||||
indexFileName: 'index.html',
|
||||
generateOne: true,
|
||||
lessUrl: 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js',
|
||||
},
|
||||
]);
|
||||
}
|
||||
};
|
||||
273
admin-web/config/router.config.js
Normal file
273
admin-web/config/router.config.js
Normal file
@@ -0,0 +1,273 @@
|
||||
export default [
|
||||
// user
|
||||
{
|
||||
path: '/user',
|
||||
component: '../layouts/UserLayout',
|
||||
routes: [
|
||||
{ path: '/user', redirect: '/user/login' },
|
||||
{ path: '/user/login', name: 'login', component: './User/Login' },
|
||||
{ path: '/user/register', name: 'register', component: './User/Register' },
|
||||
{
|
||||
path: '/user/register-result',
|
||||
name: 'register.result',
|
||||
component: './User/RegisterResult',
|
||||
},
|
||||
],
|
||||
},
|
||||
// app
|
||||
{
|
||||
path: '/',
|
||||
component: '../layouts/BasicLayout',
|
||||
Routes: ['src/pages/Authorized'],
|
||||
authority: ['admin', 'user'],
|
||||
routes: [
|
||||
// dashboard
|
||||
{ path: '/', redirect: '/dashboard/analysis' },
|
||||
{
|
||||
path: '/dashboard',
|
||||
name: 'dashboard',
|
||||
icon: 'dashboard',
|
||||
routes: [
|
||||
{
|
||||
path: '/dashboard/analysis',
|
||||
name: 'analysis',
|
||||
component: './Dashboard/Analysis',
|
||||
},
|
||||
{
|
||||
path: '/dashboard/monitor',
|
||||
name: 'monitor',
|
||||
component: './Dashboard/Monitor',
|
||||
},
|
||||
{
|
||||
path: '/dashboard/workplace',
|
||||
name: 'workplace',
|
||||
component: './Dashboard/Workplace',
|
||||
},
|
||||
],
|
||||
},
|
||||
// forms
|
||||
{
|
||||
path: '/form',
|
||||
icon: 'form',
|
||||
name: 'form',
|
||||
routes: [
|
||||
{
|
||||
path: '/form/basic-form',
|
||||
name: 'basicform',
|
||||
component: './Forms/BasicForm',
|
||||
},
|
||||
{
|
||||
path: '/form/step-form',
|
||||
name: 'stepform',
|
||||
component: './Forms/StepForm',
|
||||
hideChildrenInMenu: true,
|
||||
routes: [
|
||||
{
|
||||
path: '/form/step-form',
|
||||
redirect: '/form/step-form/info',
|
||||
},
|
||||
{
|
||||
path: '/form/step-form/info',
|
||||
name: 'info',
|
||||
component: './Forms/StepForm/Step1',
|
||||
},
|
||||
{
|
||||
path: '/form/step-form/confirm',
|
||||
name: 'confirm',
|
||||
component: './Forms/StepForm/Step2',
|
||||
},
|
||||
{
|
||||
path: '/form/step-form/result',
|
||||
name: 'result',
|
||||
component: './Forms/StepForm/Step3',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/form/advanced-form',
|
||||
name: 'advancedform',
|
||||
authority: ['admin'],
|
||||
component: './Forms/AdvancedForm',
|
||||
},
|
||||
],
|
||||
},
|
||||
// list
|
||||
{
|
||||
path: '/list',
|
||||
icon: 'table',
|
||||
name: 'list',
|
||||
routes: [
|
||||
{
|
||||
path: '/list/table-list',
|
||||
name: 'searchtable',
|
||||
component: './List/TableList',
|
||||
},
|
||||
{
|
||||
path: '/list/basic-list',
|
||||
name: 'basiclist',
|
||||
component: './List/BasicList',
|
||||
},
|
||||
{
|
||||
path: '/list/card-list',
|
||||
name: 'cardlist',
|
||||
component: './List/CardList',
|
||||
},
|
||||
{
|
||||
path: '/list/search',
|
||||
name: 'searchlist',
|
||||
component: './List/List',
|
||||
routes: [
|
||||
{
|
||||
path: '/list/search',
|
||||
redirect: '/list/search/articles',
|
||||
},
|
||||
{
|
||||
path: '/list/search/articles',
|
||||
name: 'articles',
|
||||
component: './List/Articles',
|
||||
},
|
||||
{
|
||||
path: '/list/search/projects',
|
||||
name: 'projects',
|
||||
component: './List/Projects',
|
||||
},
|
||||
{
|
||||
path: '/list/search/applications',
|
||||
name: 'applications',
|
||||
component: './List/Applications',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/profile',
|
||||
name: 'profile',
|
||||
icon: 'profile',
|
||||
routes: [
|
||||
// profile
|
||||
{
|
||||
path: '/profile/basic',
|
||||
name: 'basic',
|
||||
component: './Profile/BasicProfile',
|
||||
},
|
||||
{
|
||||
path: '/profile/basic/:id',
|
||||
name: 'basic',
|
||||
hideInMenu: true,
|
||||
component: './Profile/BasicProfile',
|
||||
},
|
||||
{
|
||||
path: '/profile/advanced',
|
||||
name: 'advanced',
|
||||
authority: ['admin'],
|
||||
component: './Profile/AdvancedProfile',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'result',
|
||||
icon: 'check-circle-o',
|
||||
path: '/result',
|
||||
routes: [
|
||||
// result
|
||||
{
|
||||
path: '/result/success',
|
||||
name: 'success',
|
||||
component: './Result/Success',
|
||||
},
|
||||
{ path: '/result/fail', name: 'fail', component: './Result/Error' },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'exception',
|
||||
icon: 'warning',
|
||||
path: '/exception',
|
||||
routes: [
|
||||
// exception
|
||||
{
|
||||
path: '/exception/403',
|
||||
name: 'not-permission',
|
||||
component: './Exception/403',
|
||||
},
|
||||
{
|
||||
path: '/exception/404',
|
||||
name: 'not-find',
|
||||
component: './Exception/404',
|
||||
},
|
||||
{
|
||||
path: '/exception/500',
|
||||
name: 'server-error',
|
||||
component: './Exception/500',
|
||||
},
|
||||
{
|
||||
path: '/exception/trigger',
|
||||
name: 'trigger',
|
||||
hideInMenu: true,
|
||||
component: './Exception/TriggerException',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'account',
|
||||
icon: 'user',
|
||||
path: '/account',
|
||||
routes: [
|
||||
{
|
||||
path: '/account/center',
|
||||
name: 'center',
|
||||
component: './Account/Center/Center',
|
||||
routes: [
|
||||
{
|
||||
path: '/account/center',
|
||||
redirect: '/account/center/articles',
|
||||
},
|
||||
{
|
||||
path: '/account/center/articles',
|
||||
component: './Account/Center/Articles',
|
||||
},
|
||||
{
|
||||
path: '/account/center/applications',
|
||||
component: './Account/Center/Applications',
|
||||
},
|
||||
{
|
||||
path: '/account/center/projects',
|
||||
component: './Account/Center/Projects',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/account/settings',
|
||||
name: 'settings',
|
||||
component: './Account/Settings/Info',
|
||||
routes: [
|
||||
{
|
||||
path: '/account/settings',
|
||||
redirect: '/account/settings/base',
|
||||
},
|
||||
{
|
||||
path: '/account/settings/base',
|
||||
component: './Account/Settings/BaseView',
|
||||
},
|
||||
{
|
||||
path: '/account/settings/security',
|
||||
component: './Account/Settings/SecurityView',
|
||||
},
|
||||
{
|
||||
path: '/account/settings/binding',
|
||||
component: './Account/Settings/BindingView',
|
||||
},
|
||||
{
|
||||
path: '/account/settings/notification',
|
||||
component: './Account/Settings/NotificationView',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
component: '404',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user