jjb-cmd 1.0.16 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jjb-cmd",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "jjb脚手架工具",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,15 +26,11 @@ export const registerApplication = (selector = '#root') => {
26
26
  return {
27
27
  mount: () => render(),
28
28
  unmount: props => {
29
- if (window.__POWERED_BY_QIANKUN__) {
30
- const { container } = props;
31
- const element = container
32
- ? container.querySelector(selector)
33
- : document.querySelector(selector);
34
- unmountComponentAtNode(element);
35
- } else {
36
- console.error('卸载APP失败,原因:', '当前环境非QianKun');
37
- }
29
+ const { container } = props;
30
+ const element = container
31
+ ? container.querySelector(selector)
32
+ : document.querySelector(selector);
33
+ unmountComponentAtNode(element);
38
34
  },
39
35
  bootstrap: props => props
40
36
  };
@@ -6,7 +6,7 @@
6
6
 
7
7
  import React from 'react';
8
8
  import { ConfigProvider } from 'antd';
9
- import { Route, Router, Switch } from 'dva/router';
9
+ import { BrowserRouter, Route, Switch } from 'dva/router';
10
10
 
11
11
  /**
12
12
  * @description 是否匹配页面
@@ -153,27 +153,26 @@ function treeRoutes (routes = []) {
153
153
  return optimizationTree(result);
154
154
  }
155
155
 
156
- function RenderRouter (routes = [], inProps = {}) {
156
+ function RenderRoute (routes = [], inProps = {}) {
157
157
  return (
158
- <Router history={inProps.history}>
159
- <Switch>
160
- {routes.map(({
161
- path,
162
- children,
163
- Component
164
- }, index) => (
165
- <Route
166
- key={index}
167
- path={`${(process.env.app || {}).basename || ''}${path}`}
168
- render={props => (
169
- <Component {...props}>
170
- {RenderRouter(children, inProps)}
171
- </Component>
172
- )}
173
- />
174
- ))}
175
- </Switch>
176
- </Router>
158
+ <Switch>
159
+ {routes.map(({
160
+ path,
161
+ children,
162
+ Component
163
+ }, index) => (
164
+ <Route
165
+ exact={path === '/'}
166
+ key={index}
167
+ path={path}
168
+ render={props => (
169
+ <Component {...props}>
170
+ {RenderRoute(children, inProps)}
171
+ </Component>
172
+ )}
173
+ />
174
+ ))}
175
+ </Switch>
177
176
  );
178
177
  }
179
178
 
@@ -189,10 +188,23 @@ export const AutomaticRouter = ({
189
188
  }) => {
190
189
  return (
191
190
  <ConfigProvider locale={require('antd/lib/locale/zh_CN').default}>
192
- {RenderRouter(treeRoutes(getRoutes()), {
193
- app,
194
- history
195
- })}
191
+ <BrowserRouter basename={(process.env.app || {}).basename || ''}>
192
+ <Switch>
193
+ {(process.env.app || {}).notRouter
194
+ ? (
195
+ <Route
196
+ path="*"
197
+ component={require('~/pages').default}
198
+ />
199
+ )
200
+ : (
201
+ RenderRoute(treeRoutes(getRoutes()), {
202
+ app,
203
+ history
204
+ })
205
+ )}
206
+ </Switch>
207
+ </BrowserRouter>
196
208
  </ConfigProvider>
197
209
  );
198
210
  };
@@ -38,7 +38,9 @@ module.exports = mode => {
38
38
  // 指定编译的‘js’存放目录文件名称
39
39
  filename: 'static/js/[id].js',
40
40
  // 输出公共路径
41
- publicPath: '/'
41
+ publicPath: '/',
42
+ // 默认暴露‘window’此处修改为暴露到‘exports’中
43
+ libraryTarget: 'umd'
42
44
  },
43
45
  // ‘node.module’
44
46
  module: {