@jiangood/springboot-admin-starter 0.0.1 → 0.0.2

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.
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var umi_1 = require("umi");
4
+ //https://umijs.org/docs/api/config
5
+ console.log('i am config.ts');
6
+ exports.default = (0, umi_1.defineConfig)({
7
+ // 配置是否让生成的文件包含 hash 后缀,通常用于增量发布和避免浏览器加载缓存。
8
+ hash: true,
9
+ history: { type: 'hash' },
10
+ // 复杂,还得设置忽略、编译等,先关掉
11
+ mfsu: false,
12
+ });
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ // .umirc.local.ts 仅在 umi dev 时有效。umi build 时不会被加载
3
+ // 这份配置会和 .umirc.ts 做 deep merge 后形成最终配置。
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ var umi_1 = require("umi");
6
+ exports.default = (0, umi_1.defineConfig)({
7
+ proxy: {
8
+ '/admin': {
9
+ target: 'http://127.0.0.1:8002',
10
+ changeOrigin: true,
11
+ },
12
+ '/ureport': {
13
+ target: 'http://127.0.0.1:8002',
14
+ changeOrigin: true,
15
+ pathRewrite: { '^/ureport': '/ureport' },
16
+ },
17
+ '/ws-log-view': {
18
+ target: 'http://127.0.0.1:8002',
19
+ changeOrigin: true,
20
+ ws: true,
21
+ },
22
+ }
23
+ });
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config"), exports);
18
+ __exportStar(require("./config.local"), exports);
19
+ __exportStar(require("./plugins/route-plugin"), exports);
20
+ __exportStar(require("./plugins/form-plugin"), exports);
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var fs = require("fs");
4
+ var path = require("path");
5
+ // 自动注册src/forms下的表单
6
+ var pkgName = '@jiangood/springboot-admin-starter';
7
+ exports.default = (function (api) {
8
+ api.logger.info('plugin starting... ');
9
+ api.logger.info('info', JSON.stringify(api.env));
10
+ api.describe({
11
+ key: 'form-register-by-dir',
12
+ });
13
+ var isFramework = api.pkg.name === pkgName;
14
+ api.logger.info('current pkgName', api.pkg.name);
15
+ api.logger.info('is framework ?', isFramework);
16
+ var formRegistryPath = path.join(api.paths.absSrcPath, 'framework');
17
+ if (!isFramework) {
18
+ formRegistryPath = path.join(api.paths.absNodeModulesPath, pkgName);
19
+ }
20
+ api.logger.info('formRegistryPath', formRegistryPath);
21
+ api.addEntryImports(function () { return ({
22
+ source: formRegistryPath,
23
+ specifier: '{formRegistry}'
24
+ }); });
25
+ parseDir(api, path.join(api.paths.absSrcPath, 'forms'));
26
+ if (!isFramework) {
27
+ parseDir(api, path.join(api.paths.absNodeModulesPath, pkgName, 'src', 'forms'));
28
+ }
29
+ });
30
+ function parseDir(api, dir) {
31
+ api.logger.info('scan dir', dir);
32
+ if (!fs.existsSync(dir)) {
33
+ api.logger.info('dir not exist, return ');
34
+ return;
35
+ }
36
+ fs.readdirSync(dir).forEach(function (file) {
37
+ if (!file.endsWith(".jsx")) {
38
+ return;
39
+ }
40
+ var source = path.join(dir, file);
41
+ var name = file.replace(".jsx", "");
42
+ // import form
43
+ api.addEntryImports(function () { return ({
44
+ source: source,
45
+ specifier: name
46
+ }); });
47
+ // register form
48
+ api.addEntryCodeAhead(function () { return "formRegistry.register(\"".concat(name, "\",").concat(name, " );"); });
49
+ api.logger.info('formRegistry.register: ', name, source);
50
+ });
51
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var fs = require("fs");
4
+ var path = require("path");
5
+ // 自动注册src/forms下的表单
6
+ var pkgName = '@jiangood/springboot-admin-starter';
7
+ exports.default = (function (api) {
8
+ api.describe({
9
+ key: 'addDependenceRoutes',
10
+ });
11
+ var pageDir = api.paths.absNodeModulesPath + "/" + pkgName + "/src/pages";
12
+ api.logger.info('scan dir is', pageDir);
13
+ var exist = fs.existsSync(pageDir);
14
+ if (!exist) {
15
+ api.logger.info('dir not exist, return ');
16
+ return;
17
+ }
18
+ var frameworkRoutes = [];
19
+ parseDir(pageDir, frameworkRoutes);
20
+ api.modifyRoutes(function (routes) {
21
+ // routes 代表用户项目的路由,umi已经自动解析过pages目录
22
+ // 接下来加入加入框架的路由,确保用户项目路由优先级高
23
+ for (var _i = 0, frameworkRoutes_1 = frameworkRoutes; _i < frameworkRoutes_1.length; _i++) {
24
+ var route = frameworkRoutes_1[_i];
25
+ if (routes[route.id] == null) { // 如果用户项目没有这个路由,则加入。否则以用户项目为准
26
+ routes[route.id] = route;
27
+ }
28
+ }
29
+ return routes;
30
+ });
31
+ });
32
+ function parseDir(pageDir, fileRoutes) {
33
+ var list = fs.readdirSync(pageDir);
34
+ for (var _i = 0, list_1 = list; _i < list_1.length; _i++) {
35
+ var fileName = list_1[_i];
36
+ var fullPath = path.join(pageDir, fileName);
37
+ var stats = fs.statSync(fullPath);
38
+ if (stats.isFile()) {
39
+ if (fileName.endsWith(".jsx")) {
40
+ addRoute(fullPath, fileRoutes);
41
+ }
42
+ }
43
+ else if (stats.isDirectory()) {
44
+ parseDir(fullPath, fileRoutes);
45
+ }
46
+ }
47
+ }
48
+ function addRoute(file, fileRoutes) {
49
+ var routePath = file.substring(file.indexOf('pages') + 6, file.length - 4);
50
+ routePath = routePath.replaceAll('\\', '/');
51
+ var parentId = "@@/global-layout";
52
+ // 文件$开头的会替换为路径变量 如$id 变为 :id
53
+ routePath = routePath.replaceAll("\$", ":");
54
+ fileRoutes.push({
55
+ absPath: file,
56
+ id: routePath,
57
+ path: routePath,
58
+ file: file,
59
+ parentId: parentId
60
+ });
61
+ if (routePath.endsWith("/index")) {
62
+ routePath = routePath.substring(0, routePath.length - 6);
63
+ fileRoutes.push({
64
+ absPath: file,
65
+ id: routePath,
66
+ path: routePath,
67
+ file: file,
68
+ parentId: parentId
69
+ });
70
+ }
71
+ }
package/package.json CHANGED
@@ -30,12 +30,12 @@
30
30
  "description": "springboot-admin-starter",
31
31
  "files": [
32
32
  "src/*",
33
- "config/*"
33
+ "config/dist/*"
34
34
  ],
35
35
  "main": "src/index.js",
36
- "version": "0.0.1",
36
+ "version": "0.0.2",
37
37
  "scripts": {
38
38
  "dev": "umi dev",
39
- "build": "umi build"
39
+ "build": "tsc --outDir config/dist --skipLibCheck --noEmitOnError false config/index.ts"
40
40
  }
41
41
  }
package/src/app.js CHANGED
@@ -0,0 +1 @@
1
+ console.log('i am app.js')
@@ -121,15 +121,12 @@ export default class InstanceInfo extends React.Component {
121
121
  let ExForm = formRegistry.get(formKey);
122
122
  if (!ExForm) {
123
123
  return <div>
124
+ <p>
124
125
  未注册表单,请注册表单 {formKey}。
125
- <Gap></Gap>
126
- <div>js代码示例:</div>
127
- <div>
128
- // app.js
129
- </div>
130
- <div>
131
- formRegistry.register("{formKey}",XXXForm)
132
- </div>
126
+ </p>
127
+ <Typography.Text>
128
+ 表单路径:src/forms/{formKey}.jsx
129
+ </Typography.Text>
133
130
  </div>
134
131
  }
135
132
 
@@ -0,0 +1,18 @@
1
+ import {Form, Input} from "antd";
2
+
3
+
4
+ export default function (props){
5
+ console.log(props)
6
+
7
+ return <div>
8
+ demo-司机表单
9
+ <Form>
10
+ <Form.Item label="车牌号">
11
+ <Input/>
12
+ </Form.Item>
13
+ <Form.Item label="姓名">
14
+ <Input/>
15
+ </Form.Item>
16
+ </Form>
17
+ </div>
18
+ }
@@ -9,5 +9,5 @@ export * from './page'
9
9
  export * from "./sys"
10
10
 
11
11
  export * from './http'
12
- export * from './FormRegistry'
12
+ export * from './formRegistry'
13
13
  export * from './theme'
@@ -108,7 +108,7 @@ export default class extends React.Component {
108
108
  <Header className='header'>
109
109
  <div className='header-left'>
110
110
 
111
- <img className='logo-img' src={siteInfo.logoUrl} onClick={() => history.push('/')} alt='logo'/>
111
+ {siteInfo.logoUrl && <img className='logo-img' src={siteInfo.logoUrl} onClick={() => history.push('/')} alt='logo'/>}
112
112
  <h3 className='hide-on-mobile'>
113
113
  <Link to="/" style={{color: theme["primary-color"]}}>{siteInfo.title} </Link>
114
114
  </h3>
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import {Button, Card, Form, Input, message, Radio, Spin, Splitter,} from "antd";
3
3
  import InstanceInfo from "../../../components/InstanceInfo";
4
4
  import {history} from "umi";
5
- import {HttpUtil, Page} from "../../../framework";
5
+ import {HttpUtil, Page, PageUtil} from "../../../framework";
6
6
 
7
7
  export default class extends React.Component {
8
8
 
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import {Button, Modal, Tabs} from "antd";
3
- import {HttpUtil, LinkButton, Page, PageLoading, ProTable} from "../../../framework";
4
3
  import InstanceInfo from "../../../components/InstanceInfo";
4
+ import {HttpUtil, LinkButton, Page, PageLoading, ProTable} from "../../../framework";
5
5
 
6
6
 
7
7
  export default class extends React.Component {
@@ -10,7 +10,6 @@ export default class extends React.Component {
10
10
 
11
11
 
12
12
 
13
-
14
13
  </Card>
15
14
  }
16
15
  }
package/config/config.js DELETED
@@ -1,10 +0,0 @@
1
- import {defineConfig} from 'umi';
2
- import {defaultConfig} from "./defaultConfig";
3
-
4
-
5
-
6
-
7
-
8
- export default defineConfig({
9
- ...defaultConfig,
10
- });
@@ -1,10 +0,0 @@
1
- // .umirc.local.ts 仅在 umi dev 时有效。umi build 时不会被加载
2
- // 这份配置会和 .umirc.ts 做 deep merge 后形成最终配置。
3
-
4
-
5
- import {defineConfig} from 'umi';
6
- import { defaultConfigLocal} from "./defaultConfig";
7
-
8
-
9
-
10
- export default defineConfig(defaultConfigLocal);
@@ -1,35 +0,0 @@
1
- const defaultConfig = {
2
- npmClient: 'pnpm',
3
-
4
- // 配置是否让生成的文件包含 hash 后缀,通常用于增量发布和避免浏览器加载缓存。
5
- hash: true,
6
- history: {type: 'hash'},
7
- // monorepo 复杂,还得设置忽略、编译等,先关掉
8
- mfsu: false,
9
- };
10
-
11
-
12
- const defaultConfigLocal = {
13
-
14
- proxy: {
15
- '/admin': {
16
- target: 'http://127.0.0.1:8002',
17
- changeOrigin: true,
18
- },
19
- '/ureport': {
20
- target: 'http://127.0.0.1:8002',
21
- changeOrigin: true,
22
- pathRewrite: {'^/ureport': '/ureport'},
23
- },
24
- '/ws-log-view': {
25
- target: 'http://127.0.0.1:8002',
26
- changeOrigin: true,
27
- ws: true,
28
- },
29
- }
30
- };
31
-
32
-
33
- module.exports = {
34
- defaultConfig, defaultConfigLocal
35
- }
@@ -1,44 +0,0 @@
1
- const IApi = require( 'umi').IApi;
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
-
7
-
8
-
9
- module.exports = (api) => {
10
- api.describe({
11
- key: 'registryForms',
12
- });
13
-
14
- const dir = api.cwd + "/src/forms"
15
- const files = fs.readdirSync(dir)
16
- api.register({
17
- key: 'addEntryImports',
18
- fn: ()=>{
19
- return 'import { formRegistry } from "./framework/system/FormRegistry";'
20
- }
21
- })
22
- api.addEntryImports(()=>{
23
- return {
24
- source: "./framework/system/FormRegistry",
25
- specifier: 'formRegistry'
26
- }
27
- })
28
-
29
- files.forEach(fileName=>{
30
- const fullPath = path.join(dir, fileName)
31
- const stats = fs.statSync(fullPath)
32
- if (stats.isFile() && fileName.endsWith(".jsx")) {
33
- api.register({
34
- key: 'addEntryCode',
35
- fn: () => {
36
- return 'formRegistry.register("' + fileName + '", ' + fileName.substring(0, fileName.length - 4) + ');
37
- }
38
- })
39
- }
40
- })
41
-
42
-
43
- };
44
-
@@ -1,82 +0,0 @@
1
- const IApi = require( 'umi').IApi;
2
-
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- // 扫描依赖模块的路由
7
-
8
- function addRoute(file, fileRoutes) {
9
- let routePath = file.substring(file.indexOf('pages') + 6, file.length - 4)
10
- routePath = routePath.replaceAll('\\', '/')
11
-
12
- let parentId = "@@/global-layout";
13
-
14
- // 文件$开头的会替换为路径变量 如$id 变为 :id
15
- routePath = routePath.replaceAll("\$", ":")
16
-
17
- fileRoutes.push({
18
- absPath: file,
19
- id: routePath,
20
- path: routePath,
21
- file,
22
- parentId
23
- })
24
- if (routePath.endsWith("/index")) {
25
- routePath = routePath.substring(0, routePath.length - 6)
26
- fileRoutes.push({
27
- absPath: file,
28
- id: routePath,
29
- path: routePath,
30
- file,
31
- parentId: parentId
32
- })
33
- }
34
- }
35
-
36
-
37
-
38
- module.exports = (api) => {
39
- api.describe({
40
- key: 'addDependenceRoutes',
41
- });
42
-
43
- const content = fs.readFileSync(api.cwd + "/package.json", "utf-8")
44
- const pkg = JSON.parse(content)
45
- const deps = Object.assign({}, pkg.devDependencies, pkg.dependencies, pkg.peerDependencies)
46
- const pagePkg = [];
47
- for (let k in deps) {
48
- if (k.startsWith("@jiangood/springboot-admin-starter")) {
49
- pagePkg.push(k)
50
- }
51
- }
52
-
53
- const fileRoutes = []
54
- for (let pkg of pagePkg) {
55
- const pageDir = api.cwd + "/node_modules/" + pkg + "/src/pages"
56
- parseDir(pageDir, fileRoutes)
57
- }
58
- api.modifyRoutes((routes) => {
59
- for (let fileRoute of fileRoutes) {
60
- if(routes[fileRoute.id] == null){
61
- routes[fileRoute.id] = fileRoute
62
- }
63
- }
64
- return routes;
65
- })
66
- };
67
- function parseDir(pageDir, fileRoutes) {
68
- const list = fs.readdirSync(pageDir)
69
-
70
- for (let fileName of list) {
71
- const fullPath = path.join(pageDir, fileName)
72
- const stats = fs.statSync(fullPath)
73
- if (stats.isFile()) {
74
- if (fileName.endsWith(".jsx")) {
75
- addRoute(fullPath, fileRoutes)
76
- }
77
- } else if (stats.isDirectory()) {
78
- parseDir(fullPath, fileRoutes)
79
- }
80
-
81
- }
82
- }