jjb-cmd 2.2.3 → 2.2.5

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/build.js DELETED
@@ -1,15 +0,0 @@
1
- const child_process = require('child_process');
2
- const utils = require("./src/old/util");
3
-
4
- child_process.execSync(`npx javascript-obfuscator src --output publish/src --config obf.config.json`, (error, stdout) => {});
5
- console.log("obf Done!");
6
- utils.CopyFolder('./bin', './publish/bin', () => {
7
- console.log("bin Folder Done!");
8
- utils.CopyFile('./package.json', './publish/package.json', () => {
9
- utils.CopyFile('./README.md', './publish/README.md', () => {
10
- utils.CopyFile('./LICENSE', './publish/LICENSE', () => {
11
- console.log("ALL Done !");
12
- });
13
- });
14
- });
15
- })
package/obf.config.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "compact": true
3
- }
@@ -1,40 +0,0 @@
1
- /**
2
- * @author XiWell
3
- * @version 2.0.1
4
- * @description 基于QianKun框架的APP注册文件,请勿修改!
5
- */
6
-
7
- import 'moment/locale/zh-cn';
8
- import dva from 'dva';
9
- import { createBrowserHistory } from 'history';
10
- import { unmountComponentAtNode } from 'react-dom';
11
-
12
- /**
13
- * @description 注册app
14
- * @param selector {string}
15
- * @returns {{unmount: Function, mount: Function, bootstrap: Function}}
16
- */
17
- export const registerApplication = (selector = '#root') => {
18
- try {
19
- const app = dva({ history: createBrowserHistory() });
20
- require('./models').automaticModels(app);
21
- app.router(config => require('./router').AutomaticRouter(config));
22
-
23
- const render = () => app.start(selector);
24
- if (!window.__POWERED_BY_QIANKUN__) render();
25
-
26
- return {
27
- mount: () => render(),
28
- unmount: props => {
29
- const { container } = props;
30
- const element = container
31
- ? container.querySelector(selector)
32
- : document.querySelector(selector);
33
- unmountComponentAtNode(element);
34
- },
35
- bootstrap: props => props
36
- };
37
- } catch (e) {
38
- console.error('注册APP失败,原因:', e.message);
39
- }
40
- };
@@ -1,22 +0,0 @@
1
- /**
2
- * @author XiWell
3
- * @version 1.0.1
4
- * @description 基于QianKun框架的APP注册文件,请勿修改!
5
- */
6
-
7
- import dva from 'dva';
8
- import ReactDOM from 'react-dom';
9
- import { createBrowserHistory } from 'history';
10
- import 'antd/dist/antd.less';
11
-
12
- /**
13
- * @description 注册app
14
- * @param selector {string}
15
- * @returns {{unmount: Function, mount: Function, bootstrap: Function}}
16
- */
17
- export const registerApplication = (selector = '#app-root') => {
18
- const app = dva({ history: createBrowserHistory() });
19
- require('./models').automaticModels(app);
20
- app.router(config => require('./router').AutomaticRouter(config));
21
- app.start(selector);
22
- };
@@ -1,210 +0,0 @@
1
- /**
2
- * @author XiWell
3
- * @version 2.0.1
4
- * @description 此文件为dva/router自动化文件,无需配置路由,请勿修改!
5
- */
6
-
7
- import React from 'react';
8
- import { ConfigProvider } from 'antd';
9
- import { BrowserRouter, Route, Switch } from 'dva/router';
10
-
11
- /**
12
- * @description 是否匹配页面
13
- * @param name {string}
14
- * @return {{stat: boolean, param: null}}
15
- */
16
- function isParamPage (name) {
17
- const result = {
18
- stat: false,
19
- param: null
20
- };
21
- if (/^_/.test(name)) {
22
- const match = name.replace(/\.js$/, '').split(/_/).filter(item => !!item && item !== 'index');
23
- result.stat = match.length !== 0;
24
- result.param = match.join('_');
25
- }
26
- return result;
27
- }
28
-
29
- /**
30
- * @description 首字母转小写
31
- * @param value {string}
32
- * @return {string}
33
- */
34
- function toLowerCase (value) {
35
- return `${value[ 0 ].toLowerCase()}${value.substring(1)}`;
36
- }
37
-
38
- /**
39
- * @description 获取初始路由集合
40
- * @return {{path: string, file: string}[]}
41
- */
42
- function getRoutes () {
43
- const routes = [];
44
- const fileList = require.context('~/pages', true, /\.js$/).keys();
45
- for (let i = 0; i < fileList.length; i++) {
46
- const route = {};
47
- const file = fileList[ i ];
48
- const fileSplit = file.split(/\//);
49
- const fileName = fileSplit[ fileSplit.length - 1 ];
50
- const {
51
- stat: fileState,
52
- param: fileParam
53
- } = isParamPage(fileName);
54
- const filePathArray = fileSplit.slice(1, fileSplit.length - 1).map(item => {
55
- const {
56
- stat,
57
- param
58
- } = isParamPage(item);
59
- return stat
60
- ? `:${param}`
61
- : item;
62
- });
63
- if (fileState || fileName === 'index.js') {
64
- if (filePathArray.length) {
65
- const path = filePathArray.map(item => toLowerCase(item)).join('/');
66
- route.path = (`/${path}${fileState
67
- ? `/:${fileParam}`
68
- : ''}`);
69
- } else {
70
- route.path = `/${fileState
71
- ? `:${fileParam}`
72
- : ''}`;
73
- }
74
- route.file = file;
75
- routes.push(route);
76
- }
77
- }
78
- return routes.reverse();
79
- }
80
-
81
- /**
82
- * @typedef {object} TreeRoutes
83
- * @property {string} path
84
- * @property {string} file
85
- * @property {TreeRoutes[]} children
86
- */
87
-
88
- /**
89
- * @description 优化tree
90
- * @param tree {TreeRoutes[]}
91
- * @return {TreeRoutes[]}
92
- */
93
- function optimizationTree (tree = []) {
94
- function deep (array = []) {
95
- const inner = [];
96
- for (let i = 0; i < array.length; i++) {
97
- const item = array[ i ];
98
- const newItem = {};
99
- newItem.children = item.children.length
100
- ? deep(item.children)
101
- : [];
102
- newItem.path = item.path;
103
- newItem.Component = require(`~/pages${item.file.replace(/^\./, '')}`).default;
104
- inner.push(newItem);
105
- }
106
- return inner;
107
- }
108
-
109
- return deep(tree);
110
- }
111
-
112
- /**
113
- * @description 将初始routes转换为tree结构
114
- * @param routes {{path: string, file: string}[]}
115
- * @return {TreeRoutes[]}
116
- */
117
- function treeRoutes (routes = []) {
118
- const dataSource = [];
119
- const indexItem = routes.find(item => item.path === '/');
120
- for (let i = 0; i < routes.length; i++) {
121
- const route = routes[ i ];
122
- if (route.path === '/') {
123
- continue;
124
- }
125
- const pathArray = route.path.split('/').slice(1);
126
- route.parentFile = pathArray.length === 1
127
- ? null
128
- : routes[ i - 1 ].file;
129
- dataSource.push(route);
130
- }
131
- if (indexItem) {
132
- Object.assign(indexItem, { parentFile: null });
133
- dataSource.push(indexItem);
134
- }
135
- let len;
136
- for (let i = 0; len = dataSource.length, i < len; i++) {
137
- const arrTemp = [];
138
- for (let j = 0; j < dataSource.length; j++) {
139
- if (dataSource[ i ].file === dataSource[ j ].parentFile) {
140
- dataSource[ i ].children = arrTemp;
141
- arrTemp.push(dataSource[ j ]);
142
- } else {
143
- dataSource[ i ].children = arrTemp;
144
- }
145
- }
146
- }
147
- const result = [];
148
- for (let i = 0; i < dataSource.length; i++) {
149
- if (dataSource[ i ].parentFile === null) {
150
- result.push(dataSource[ i ]);
151
- }
152
- }
153
- return optimizationTree(result);
154
- }
155
-
156
- function RenderRoute (routes = [], inProps = {}) {
157
- return (
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>
176
- );
177
- }
178
-
179
- /**
180
- * @description 自动化路由组件
181
- * @param app {object}
182
- * @param history {history}
183
- * @return {JSX.Element}
184
- */
185
- export const AutomaticRouter = ({
186
- app,
187
- history
188
- }) => {
189
- return (
190
- <ConfigProvider locale={require('antd/lib/locale/zh_CN').default}>
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>
208
- </ConfigProvider>
209
- );
210
- };
@@ -1,119 +0,0 @@
1
- /**
2
- * @author XiWell
3
- * @version 1.0.1
4
- * @description 此文件为dva/router自动化文件,无需配置路由,请勿修改!
5
- */
6
-
7
- import React from 'react';
8
- import { ConfigProvider } from 'antd';
9
- import { Route, Router, Switch } from 'dva/router';
10
-
11
- /**
12
- * @description react路由扫描器
13
- * @param props {{app: object, history: any}}
14
- */
15
- function ReactRouterScanner (props) {
16
- const paths = require.context('~/pages', true, /\.(jsx|js)$/).keys().filter(item => !item.match(/components/));
17
- const symbolByEntry = 'Entry_index.js';
18
- const symbolByContainer = 'Container_index.js';
19
-
20
- /**
21
- * @description 路由处理
22
- * @param path {string}
23
- * @return string
24
- */
25
- function routeHandle (path) {
26
- return `/${path.replace(/\/index.js$/, '').split(/\//).map(a => {
27
- a = a.replace(a[ 0 ], a[ 0 ].toLowerCase());
28
- return a;
29
- }).map(a => {
30
- if (/^[a-zA-Z]+_[a-zA-Z]+$/.test(a)) {
31
- return `:${a.split(/_/).join('')}`;
32
- }
33
- return a;
34
- }).join('/')}`;
35
- }
36
-
37
- const routerMap = paths.map(path => {
38
- const pure = path.replace(/^\.\//, '');
39
- return {
40
- path: pure === 'index.js'
41
- ? '/'
42
- : pure === symbolByContainer
43
- ? '/container'
44
- : path === symbolByEntry
45
- ? '/entry'
46
- : routeHandle(pure),
47
- suffix: 'index.js',
48
- component: require(`~/pages/${pure}`).default,
49
- componentName: pure.replace(/\//g, '_')
50
- };
51
- });
52
-
53
- const Main = routerMap.find(item => item.componentName === 'index.js');
54
- const Entry = routerMap.find(item => item.componentName === symbolByEntry);
55
- const Container = routerMap.find(item => item.componentName === symbolByContainer);
56
- const ChildrenRoute = routerMap.filter(item => item.componentName.match(new RegExp('Container_')) && item.path !== '/container');
57
- const ContainerComponent = Container
58
- ? Container.component
59
- : null;
60
- return (
61
- <Router history={props.history}>
62
- <Switch location={history.location}>
63
- {Main && (
64
- <Route
65
- exact
66
- path={Main.path}
67
- component={Main.component}
68
- />
69
- )}
70
- {Entry && (
71
- <Route
72
- exact
73
- path={Entry.path}
74
- component={Entry.component}
75
- />
76
- )}
77
- {Container && (
78
- <Route
79
- path={Container.path}
80
- render={$props => (
81
- <ContainerComponent {...$props}>
82
- <Switch location={history.location}>
83
- {ChildrenRoute.map((route, key) => (
84
- <Route
85
- exact
86
- key={key}
87
- path={route.path}
88
- component={route.component}
89
- />
90
- ))}
91
- </Switch>
92
- </ContainerComponent>
93
- )}
94
- />
95
- )}
96
- </Switch>
97
- </Router>
98
- );
99
- }
100
-
101
- /**
102
- * @description 自动化路由组件
103
- * @param app {object}
104
- * @param history {history}
105
- * @return {JSX.Element}
106
- */
107
- export const AutomaticRouter = ({
108
- app,
109
- history
110
- }) => {
111
- return (
112
- <ConfigProvider locale={require('antd/lib/locale/zh_CN').default}>
113
- <ReactRouterScanner
114
- app={app}
115
- history={history}
116
- />
117
- </ConfigProvider>
118
- );
119
- };