知与行后台管理端

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. import defaultSettings from './defaultSettings'; // https://umijs.org/config/
  2. import slash from 'slash2';
  3. import webpackPlugin from './plugin.config';
  4. const { pwa, primaryColor } = defaultSettings; // preview.pro.ant.design only do not use in your production ;
  5. // preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
  6. const { ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION } = process.env;
  7. const isAntDesignProPreview = ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site';
  8. const plugins = [
  9. [
  10. 'umi-plugin-react',
  11. {
  12. antd: true,
  13. dva: {
  14. hmr: true,
  15. },
  16. locale: {
  17. // default false
  18. enable: true,
  19. // default zh-CN
  20. default: 'zh-CN',
  21. // default true, when it is true, will use `navigator.language` overwrite default
  22. baseNavigator: true,
  23. },
  24. // dynamicImport: {
  25. // loadingComponent: './components/PageLoading/index',
  26. // webpackChunkName: true,
  27. // level: 3,
  28. // },
  29. pwa: pwa
  30. ? {
  31. workboxPluginMode: 'InjectManifest',
  32. workboxOptions: {
  33. importWorkboxFrom: 'local',
  34. },
  35. }
  36. : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
  37. // dll features https://webpack.js.org/plugins/dll-plugin/
  38. // dll: {
  39. // include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
  40. // exclude: ['@babel/runtime', 'netlify-lambda'],
  41. // },
  42. },
  43. ],
  44. [
  45. 'umi-plugin-pro-block',
  46. {
  47. moveMock: false,
  48. moveService: false,
  49. modifyRequest: true,
  50. autoAddMenu: true,
  51. },
  52. ],
  53. ]; // 针对 preview.pro.ant.design 的 GA 统计代码
  54. if (isAntDesignProPreview) {
  55. plugins.push([
  56. 'umi-plugin-ga',
  57. {
  58. code: 'UA-72788897-6',
  59. },
  60. ]);
  61. plugins.push([
  62. 'umi-plugin-pro',
  63. {
  64. serverUrl: 'https://ant-design-pro.netlify.com',
  65. },
  66. ]);
  67. }
  68. export default {
  69. plugins,
  70. block: {
  71. // 国内用户可以使用码云
  72. // defaultGitUrl: 'https://gitee.com/ant-design/pro-blocks',
  73. defaultGitUrl: 'https://github.com/ant-design/pro-blocks',
  74. },
  75. hash: true,
  76. targets: {
  77. ie: 11,
  78. },
  79. devtool: isAntDesignProPreview ? 'source-map' : false,
  80. // umi routes: https://umijs.org/zh/guide/router.html
  81. routes: [
  82. {
  83. path: '/user',
  84. component: '../layouts/UserLayout',
  85. routes: [
  86. {
  87. name: 'login',
  88. path: '/user/login',
  89. component: './user/login',
  90. },
  91. ],
  92. },
  93. {
  94. path: '/',
  95. component: '../layouts/SecurityLayout',
  96. routes: [
  97. {
  98. path: '/',
  99. component: '../layouts/BasicLayout',
  100. authority: ['admin', 'user'],
  101. routes: [
  102. {
  103. path: '/',
  104. redirect: '/welcome',
  105. },
  106. {
  107. path: '/welcome',
  108. name: '首页',
  109. component: './Welcome',
  110. },
  111. {
  112. path: '/building',
  113. name: '项目管理',
  114. component: '../layouts/BlankLayout',
  115. routes: [
  116. {
  117. path: '/building/list',
  118. name: '项目列表',
  119. component: './building/list/index',
  120. },
  121. ],
  122. },
  123. {
  124. path: '/integralMall',
  125. name: '积分商城',
  126. component: '../layouts/BlankLayout',
  127. routes: [
  128. {
  129. path: '/integralMall/GoodsList',
  130. name: '商品列表',
  131. component: './integralMall/GoodsList',
  132. },
  133. {
  134. path: '/integralMall/editGoods',
  135. name: '',
  136. component: './integralMall/editGoods',
  137. },
  138. ],
  139. },
  140. {
  141. path: '/channel',
  142. name: '渠道管理',
  143. component: '../layouts/BlankLayout',
  144. routes: [
  145. {
  146. path: '/channel/channelList',
  147. name: '渠道管理',
  148. component: './channel/channelList',
  149. },
  150. // {
  151. // path: '/channel/addChannel',
  152. // name: '新增渠道',
  153. // component: './channel/addChannel',
  154. // },
  155. ],
  156. },
  157. {
  158. path: '/news',
  159. name: '资讯管理',
  160. component: '../layouts/BlankLayout',
  161. routes: [
  162. {
  163. path: '/news/NewTypeList',
  164. name: '资讯列表',
  165. component: './news/NewTypeList',
  166. },
  167. {
  168. path: '/activity/editActivity',
  169. name: '',
  170. component: './activity/editActivity',
  171. },
  172. ],
  173. },
  174. {
  175. path: '/activity',
  176. name: '活动管理',
  177. component: '../layouts/BlankLayout',
  178. routes: [
  179. {
  180. path: '/activity/ActivityList',
  181. name: '活动列表',
  182. component: './activity/ActivityList',
  183. },
  184. {
  185. path: '/activity/editActivity',
  186. name: '',
  187. component: './activity/editActivity',
  188. },
  189. ],
  190. },
  191. {
  192. component: './404',
  193. },
  194. ],
  195. },
  196. {
  197. component: './404',
  198. },
  199. ],
  200. },
  201. {
  202. component: './404',
  203. },
  204. ],
  205. // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  206. theme: {
  207. 'primary-color': primaryColor,
  208. },
  209. define: {
  210. ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION:
  211. ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION || '', // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量,请不要在你的项目中使用它。
  212. },
  213. ignoreMomentLocale: true,
  214. lessLoaderOptions: {
  215. javascriptEnabled: true,
  216. },
  217. disableRedirectHoist: true,
  218. cssLoaderOptions: {
  219. modules: true,
  220. getLocalIdent: (context, _, localName) => {
  221. if (
  222. context.resourcePath.includes('node_modules') ||
  223. context.resourcePath.includes('ant.design.pro.less') ||
  224. context.resourcePath.includes('global.less')
  225. ) {
  226. return localName;
  227. }
  228. const match = context.resourcePath.match(/src(.*)/);
  229. if (match && match[1]) {
  230. const antdProPath = match[1].replace('.less', '');
  231. const arr = slash(antdProPath)
  232. .split('/')
  233. .map(a => a.replace(/([A-Z])/g, '-$1'))
  234. .map(a => a.toLowerCase());
  235. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  236. }
  237. return localName;
  238. },
  239. },
  240. manifest: {
  241. basePath: '/',
  242. },
  243. chainWebpack: webpackPlugin,
  244. /*
  245. proxy: {
  246. '/server/api/': {
  247. target: 'https://preview.pro.ant.design/',
  248. changeOrigin: true,
  249. pathRewrite: { '^/server': '' },
  250. },
  251. },
  252. */
  253. };