@maxelms/create-plugin-cli 1.1.0

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.
Files changed (274) hide show
  1. package/README.en.md +36 -0
  2. package/README.md +12 -0
  3. package/bin/build.js +29 -0
  4. package/bin/compress.js +35 -0
  5. package/bin/copy.js +39 -0
  6. package/bin/index.js +53 -0
  7. package/configuration-schema.json +829 -0
  8. package/lib/index.d.ts +21 -0
  9. package/lib/index.js +242 -0
  10. package/lib/utils.d.ts +18 -0
  11. package/lib/utils.js +114 -0
  12. package/package.json +50 -0
  13. package/templates/jQuery-micro-app/package.json.tpl +19 -0
  14. package/templates/jQuery-micro-app/src/README.md +5 -0
  15. package/templates/jQuery-micro-app/src/configuration.json +30 -0
  16. package/templates/jQuery-micro-app/src/index.html +17 -0
  17. package/templates/jQuery-micro-app/src/main.js.tpl +31 -0
  18. package/templates/jQuery-micro-app/src/manifest.json.tpl +9 -0
  19. package/templates/jQuery-micro-app/src/style.css +11 -0
  20. package/templates/maxelms-navigation/.babelrc +7 -0
  21. package/templates/maxelms-navigation/.gitignore.tpl +23 -0
  22. package/templates/maxelms-navigation/README.md +15 -0
  23. package/templates/maxelms-navigation/global.d.ts +2 -0
  24. package/templates/maxelms-navigation/index.html +16 -0
  25. package/templates/maxelms-navigation/package.json +65 -0
  26. package/templates/maxelms-navigation/patches/live2d-widget@3.1.4.patch +4534 -0
  27. package/templates/maxelms-navigation/pnpm-lock.yaml +7993 -0
  28. package/templates/maxelms-navigation/src/App.tsx +47 -0
  29. package/templates/maxelms-navigation/src/components/Actions/ColorPicker.tsx +86 -0
  30. package/templates/maxelms-navigation/src/components/Actions/SwitchApps.tsx +83 -0
  31. package/templates/maxelms-navigation/src/components/Actions/index.tsx +95 -0
  32. package/templates/maxelms-navigation/src/components/Cutie.tsx +24 -0
  33. package/templates/maxelms-navigation/src/components/Enterprises.tsx +46 -0
  34. package/templates/maxelms-navigation/src/components/Logo.tsx +29 -0
  35. package/templates/maxelms-navigation/src/components/Menus/MenuPanel.tsx +55 -0
  36. package/templates/maxelms-navigation/src/components/Menus/index.tsx +50 -0
  37. package/templates/maxelms-navigation/src/components/Search.tsx +77 -0
  38. package/templates/maxelms-navigation/src/imgs/corp-admin.svg +1 -0
  39. package/templates/maxelms-navigation/src/imgs/saas-admin.svg +1 -0
  40. package/templates/maxelms-navigation/src/imgs/skin.svg +1 -0
  41. package/templates/maxelms-navigation/src/imgs/tenant-admin.svg +1 -0
  42. package/templates/maxelms-navigation/src/imgs/user-center.svg +1 -0
  43. package/templates/maxelms-navigation/src/index.tsx +14 -0
  44. package/templates/maxelms-navigation/src/interface.ts +27 -0
  45. package/templates/maxelms-navigation/src/style.less.tpl +278 -0
  46. package/templates/maxelms-navigation/src/utils.ts.tpl +40 -0
  47. package/templates/maxelms-navigation/tsconfig.json +111 -0
  48. package/templates/maxelms-navigation/webpack.config.js +119 -0
  49. package/templates/maxelms-script/.babelrc +5 -0
  50. package/templates/maxelms-script/.gitignore.tpl +23 -0
  51. package/templates/maxelms-script/README.md +0 -0
  52. package/templates/maxelms-script/global.d.ts +2 -0
  53. package/templates/maxelms-script/index.html +10 -0
  54. package/templates/maxelms-script/package.json.tpl +55 -0
  55. package/templates/maxelms-script/pnpm-lock.yaml +7699 -0
  56. package/templates/maxelms-script/src/App.tsx +15 -0
  57. package/templates/maxelms-script/src/index.tsx +15 -0
  58. package/templates/maxelms-script/src/style.less.tpl +8 -0
  59. package/templates/maxelms-script/src/utils.ts.tpl +2 -0
  60. package/templates/maxelms-script/tsconfig.json +111 -0
  61. package/templates/maxelms-script/webpack.config.js +92 -0
  62. package/templates/maxelms-style/.gitignore.tpl +38 -0
  63. package/templates/maxelms-style/README.md +0 -0
  64. package/templates/maxelms-style/index.css +3 -0
  65. package/templates/maxelms-style/index.less +4 -0
  66. package/templates/maxelms-style/package.json.tpl +17 -0
  67. package/templates/playground/dist/main.css +2 -0
  68. package/templates/playground/dist/main.js +2 -0
  69. package/templates/playground/dist/main.js.LICENSE.txt +52 -0
  70. package/templates/playground/dist/playground.html +1 -0
  71. package/templates/playground/dist/react-dom.production.min.js +2 -0
  72. package/templates/playground/dist/react-dom.production.min.js.LICENSE.txt +8 -0
  73. package/templates/playground/dist/react.production.min.js +2 -0
  74. package/templates/playground/dist/react.production.min.js.LICENSE.txt +8 -0
  75. package/templates/playground/dist/zone.umd.min.js +2 -0
  76. package/templates/playground/dist/zone.umd.min.js.LICENSE.txt +29 -0
  77. package/templates/project/package.json +17 -0
  78. package/templates/react-micro-app/.babelrc +6 -0
  79. package/templates/react-micro-app/.gitignore.tpl +23 -0
  80. package/templates/react-micro-app/README.md +5 -0
  81. package/templates/react-micro-app/manifest.json.tpl +21 -0
  82. package/templates/react-micro-app/package.json.tpl +53 -0
  83. package/templates/react-micro-app/public/configuration.json +30 -0
  84. package/templates/react-micro-app/public/index.html +10 -0
  85. package/templates/react-micro-app/src/components/NoMatch.tsx +15 -0
  86. package/templates/react-micro-app/src/context/masterContext.ts +11 -0
  87. package/templates/react-micro-app/src/index.tsx +52 -0
  88. package/templates/react-micro-app/src/layouts/BasicLayout.less +16 -0
  89. package/templates/react-micro-app/src/layouts/BasicLayout.tsx +21 -0
  90. package/templates/react-micro-app/src/pages/Home/index.less +15 -0
  91. package/templates/react-micro-app/src/pages/Home/index.tsx +33 -0
  92. package/templates/react-micro-app/src/pages/List/index.less +12 -0
  93. package/templates/react-micro-app/src/pages/List/index.tsx +12 -0
  94. package/templates/react-micro-app/src/pages/New/index.less +12 -0
  95. package/templates/react-micro-app/src/pages/New/index.tsx +12 -0
  96. package/templates/react-micro-app/src/pages/View/index.less +12 -0
  97. package/templates/react-micro-app/src/pages/View/index.tsx +12 -0
  98. package/templates/react-micro-app/src/public-path.js +4 -0
  99. package/templates/react-micro-app/src/router.tsx +44 -0
  100. package/templates/react-micro-app/tsconfig.json +102 -0
  101. package/templates/react-micro-app/typings.d.ts +11 -0
  102. package/templates/react-micro-app/webpack.config.js.tpl +178 -0
  103. package/templates/react-micro-app-umi/.editorconfig +16 -0
  104. package/templates/react-micro-app-umi/.env +1 -0
  105. package/templates/react-micro-app-umi/.gitignore.tpl +23 -0
  106. package/templates/react-micro-app-umi/.prettierignore +8 -0
  107. package/templates/react-micro-app-umi/.prettierrc +11 -0
  108. package/templates/react-micro-app-umi/.umirc.ts.tpl +31 -0
  109. package/templates/react-micro-app-umi/README.md +5 -0
  110. package/templates/react-micro-app-umi/manifest.json.tpl +21 -0
  111. package/templates/react-micro-app-umi/package.json.tpl +42 -0
  112. package/templates/react-micro-app-umi/public/basicConfiguration.json +30 -0
  113. package/templates/react-micro-app-umi/public/configuration.json +30 -0
  114. package/templates/react-micro-app-umi/src/layout/BasicLayout.tsx +16 -0
  115. package/templates/react-micro-app-umi/src/pages/about.tsx +11 -0
  116. package/templates/react-micro-app-umi/src/pages/home.tsx +19 -0
  117. package/templates/react-micro-app-umi/tsconfig.json +36 -0
  118. package/templates/react-micro-app-umi/typings.d.ts +8 -0
  119. package/templates/react-micro-button/.gitignore.tpl +23 -0
  120. package/templates/react-micro-button/README.md +5 -0
  121. package/templates/react-micro-button/configuration/Configuration.tsx +113 -0
  122. package/templates/react-micro-button/configuration/index.css +8 -0
  123. package/templates/react-micro-button/configuration/index.tsx +6 -0
  124. package/templates/react-micro-button/manifest.json.tpl +3 -0
  125. package/templates/react-micro-button/package.json.tpl +49 -0
  126. package/templates/react-micro-button/postcss.config.js +5 -0
  127. package/templates/react-micro-button/public/basicConfiguration.json +30 -0
  128. package/templates/react-micro-button/public/configuration.html +10 -0
  129. package/templates/react-micro-button/public/configuration.json +30 -0
  130. package/templates/react-micro-button/public/index.html +10 -0
  131. package/templates/react-micro-button/src/App.tsx +41 -0
  132. package/templates/react-micro-button/src/app.less +0 -0
  133. package/templates/react-micro-button/src/index.less +0 -0
  134. package/templates/react-micro-button/src/index.tsx +30 -0
  135. package/templates/react-micro-button/tsconfig.json +11 -0
  136. package/templates/react-micro-button/webpack.config.js.tpl +150 -0
  137. package/templates/react-micro-field/.babelrc +5 -0
  138. package/templates/react-micro-field/.gitignore.tpl +23 -0
  139. package/templates/react-micro-field/README.md +5 -0
  140. package/templates/react-micro-field/configuration/Configuration.tsx +113 -0
  141. package/templates/react-micro-field/configuration/index.css +8 -0
  142. package/templates/react-micro-field/configuration/index.tsx +6 -0
  143. package/templates/react-micro-field/manifest.json.tpl +7 -0
  144. package/templates/react-micro-field/package.json.tpl +50 -0
  145. package/templates/react-micro-field/postcss.config.js +5 -0
  146. package/templates/react-micro-field/public/basicConfiguration.json +30 -0
  147. package/templates/react-micro-field/public/configuration.html +10 -0
  148. package/templates/react-micro-field/public/configuration.json +30 -0
  149. package/templates/react-micro-field/public/index.html +10 -0
  150. package/templates/react-micro-field/src/App.tsx.tpl +51 -0
  151. package/templates/react-micro-field/src/index.tsx +29 -0
  152. package/templates/react-micro-field/src/style.less.tpl +12 -0
  153. package/templates/react-micro-field/tsconfig.json +11 -0
  154. package/templates/react-micro-field/webpack.config.js.tpl +157 -0
  155. package/templates/react-micro-field-umi/.editorconfig +16 -0
  156. package/templates/react-micro-field-umi/.gitignore.tpl +24 -0
  157. package/templates/react-micro-field-umi/.prettierignore +8 -0
  158. package/templates/react-micro-field-umi/.prettierrc +11 -0
  159. package/templates/react-micro-field-umi/README.md +5 -0
  160. package/templates/react-micro-field-umi/config/config.ts.tpl +41 -0
  161. package/templates/react-micro-field-umi/config/plugin.ts +18 -0
  162. package/templates/react-micro-field-umi/manifest.json.tpl +7 -0
  163. package/templates/react-micro-field-umi/package.json.tpl +48 -0
  164. package/templates/react-micro-field-umi/public/basicConfiguration.json +30 -0
  165. package/templates/react-micro-field-umi/public/configuration.json +30 -0
  166. package/templates/react-micro-field-umi/src/app.tsx +46 -0
  167. package/templates/react-micro-field-umi/src/global.tsx +0 -0
  168. package/templates/react-micro-field-umi/src/hooks/masterProps.ts +33 -0
  169. package/templates/react-micro-field-umi/src/layouts/BasicLayout.tsx +17 -0
  170. package/templates/react-micro-field-umi/src/pages/configuration/index.tsx +90 -0
  171. package/templates/react-micro-field-umi/src/pages/index.tsx.tpl +54 -0
  172. package/templates/react-micro-field-umi/src/pages/interface.ts +12 -0
  173. package/templates/react-micro-field-umi/src/pages/style.less.tpl +15 -0
  174. package/templates/react-micro-field-umi/src/public-path.js +5 -0
  175. package/templates/react-micro-field-umi/tsconfig.json +37 -0
  176. package/templates/react-micro-field-umi/typings.d.ts +10 -0
  177. package/templates/react-micro-plugin/.babelrc +5 -0
  178. package/templates/react-micro-plugin/.gitignore.tpl +23 -0
  179. package/templates/react-micro-plugin/README.md +5 -0
  180. package/templates/react-micro-plugin/configuration/Configuration.tsx +114 -0
  181. package/templates/react-micro-plugin/configuration/index.css +8 -0
  182. package/templates/react-micro-plugin/configuration/index.tsx +6 -0
  183. package/templates/react-micro-plugin/manifest.json.tpl +3 -0
  184. package/templates/react-micro-plugin/package.json.tpl +50 -0
  185. package/templates/react-micro-plugin/postcss.config.js +5 -0
  186. package/templates/react-micro-plugin/public/configuration.html +10 -0
  187. package/templates/react-micro-plugin/public/configuration.json +30 -0
  188. package/templates/react-micro-plugin/public/index.html +10 -0
  189. package/templates/react-micro-plugin/src/App.tsx.tpl +32 -0
  190. package/templates/react-micro-plugin/src/index.tsx +29 -0
  191. package/templates/react-micro-plugin/src/style.less.tpl +12 -0
  192. package/templates/react-micro-plugin/tsconfig.json +11 -0
  193. package/templates/react-micro-plugin/webpack.config.js.tpl +156 -0
  194. package/templates/react-micro-plugin-umi/.editorconfig +16 -0
  195. package/templates/react-micro-plugin-umi/.gitignore.tpl +24 -0
  196. package/templates/react-micro-plugin-umi/.prettierignore +8 -0
  197. package/templates/react-micro-plugin-umi/.prettierrc +11 -0
  198. package/templates/react-micro-plugin-umi/README.md +5 -0
  199. package/templates/react-micro-plugin-umi/config/config.ts +29 -0
  200. package/templates/react-micro-plugin-umi/config/plugin.ts +18 -0
  201. package/templates/react-micro-plugin-umi/manifest.json.tpl +3 -0
  202. package/templates/react-micro-plugin-umi/package.json.tpl +48 -0
  203. package/templates/react-micro-plugin-umi/public/configuration.json +30 -0
  204. package/templates/react-micro-plugin-umi/src/app.tsx +46 -0
  205. package/templates/react-micro-plugin-umi/src/global.tsx +0 -0
  206. package/templates/react-micro-plugin-umi/src/hooks/masterProps.ts +34 -0
  207. package/templates/react-micro-plugin-umi/src/layouts/BasicLayout.tsx +17 -0
  208. package/templates/react-micro-plugin-umi/src/pages/configuration/index.tsx +113 -0
  209. package/templates/react-micro-plugin-umi/src/pages/index.tsx +21 -0
  210. package/templates/react-micro-plugin-umi/src/public-path.js +5 -0
  211. package/templates/react-micro-plugin-umi/tsconfig.json +37 -0
  212. package/templates/react-micro-plugin-umi/typings.d.ts +10 -0
  213. package/templates/vue-micro-app/.gitignore.tpl +23 -0
  214. package/templates/vue-micro-app/README.md +5 -0
  215. package/templates/vue-micro-app/babel.config.js +15 -0
  216. package/templates/vue-micro-app/manifest.json.tpl +21 -0
  217. package/templates/vue-micro-app/package.json.tpl +54 -0
  218. package/templates/vue-micro-app/public/configuration.json +30 -0
  219. package/templates/vue-micro-app/public/favicon.ico +0 -0
  220. package/templates/vue-micro-app/public/index.html +10 -0
  221. package/templates/vue-micro-app/src/App.vue +35 -0
  222. package/templates/vue-micro-app/src/assets/logo.png +0 -0
  223. package/templates/vue-micro-app/src/components/HelloWorld.vue +32 -0
  224. package/templates/vue-micro-app/src/main.js +80 -0
  225. package/templates/vue-micro-app/src/public-path.js +5 -0
  226. package/templates/vue-micro-app/src/routes.js +19 -0
  227. package/templates/vue-micro-app/src/views/About.vue +13 -0
  228. package/templates/vue-micro-app/src/views/Home.vue +21 -0
  229. package/templates/vue-micro-app/vue.config.js.tpl +35 -0
  230. package/templates/vue-micro-button/.gitignore.tpl +23 -0
  231. package/templates/vue-micro-button/README.md +5 -0
  232. package/templates/vue-micro-button/babel.config.js +8 -0
  233. package/templates/vue-micro-button/configuration/App.vue +78 -0
  234. package/templates/vue-micro-button/configuration/main.js +11 -0
  235. package/templates/vue-micro-button/manifest.json.tpl +3 -0
  236. package/templates/vue-micro-button/package.json.tpl +51 -0
  237. package/templates/vue-micro-button/public/basicConfiguration.json +30 -0
  238. package/templates/vue-micro-button/public/configuration.html +10 -0
  239. package/templates/vue-micro-button/public/configuration.json +30 -0
  240. package/templates/vue-micro-button/public/index.html +12 -0
  241. package/templates/vue-micro-button/src/App.vue +46 -0
  242. package/templates/vue-micro-button/src/main.js +44 -0
  243. package/templates/vue-micro-button/vue.config.js.tpl +51 -0
  244. package/templates/vue-micro-field/.gitignore.tpl +23 -0
  245. package/templates/vue-micro-field/README.md +5 -0
  246. package/templates/vue-micro-field/babel.config.js +8 -0
  247. package/templates/vue-micro-field/configuration/App.vue +78 -0
  248. package/templates/vue-micro-field/configuration/main.js +11 -0
  249. package/templates/vue-micro-field/manifest.json.tpl +7 -0
  250. package/templates/vue-micro-field/package.json.tpl +53 -0
  251. package/templates/vue-micro-field/public/basicConfiguration.json +30 -0
  252. package/templates/vue-micro-field/public/configuration.html +10 -0
  253. package/templates/vue-micro-field/public/configuration.json +30 -0
  254. package/templates/vue-micro-field/public/index.html +10 -0
  255. package/templates/vue-micro-field/scripts/compress.js +32 -0
  256. package/templates/vue-micro-field/src/App.vue.tpl +55 -0
  257. package/templates/vue-micro-field/src/main.js +38 -0
  258. package/templates/vue-micro-field/src/style.less.tpl +16 -0
  259. package/templates/vue-micro-field/vue.config.js.tpl +51 -0
  260. package/templates/vue-micro-plugin/.gitignore.tpl +23 -0
  261. package/templates/vue-micro-plugin/README.md +24 -0
  262. package/templates/vue-micro-plugin/babel.config.js +8 -0
  263. package/templates/vue-micro-plugin/configuration/App.vue +100 -0
  264. package/templates/vue-micro-plugin/configuration/main.js +11 -0
  265. package/templates/vue-micro-plugin/manifest.json.tpl +3 -0
  266. package/templates/vue-micro-plugin/package.json.tpl +56 -0
  267. package/templates/vue-micro-plugin/public/configuration.html +10 -0
  268. package/templates/vue-micro-plugin/public/configuration.json +30 -0
  269. package/templates/vue-micro-plugin/public/index.html +10 -0
  270. package/templates/vue-micro-plugin/scripts/compress.js +32 -0
  271. package/templates/vue-micro-plugin/src/App.vue.tpl +42 -0
  272. package/templates/vue-micro-plugin/src/main.js +38 -0
  273. package/templates/vue-micro-plugin/src/style.less.tpl +16 -0
  274. package/templates/vue-micro-plugin/vue.config.js.tpl +53 -0
@@ -0,0 +1,23 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /npm-debug.log*
6
+ /yarn-error.log
7
+ /yarn.lock
8
+ /package-lock.json
9
+
10
+ # production
11
+ /dist
12
+
13
+ # misc
14
+ .DS_Store
15
+
16
+ # umi
17
+ /src/.umi
18
+ /src/.umi-production
19
+ /src/.umi-test
20
+ /.env.local
21
+ /dist.maxplugin
22
+ /dist.zip
23
+ /.vscode
@@ -0,0 +1,5 @@
1
+ # Maxelms MicroApp
2
+
3
+ ## 功能介绍
4
+
5
+ ## 使用说明
@@ -0,0 +1,21 @@
1
+ {
2
+ "routes": [
3
+ {
4
+ "title": "首页",
5
+ "value": "/"
6
+ },
7
+ {
8
+ "title": "列表页",
9
+ "value": "/list"
10
+ },
11
+ {
12
+ "title": "详情页",
13
+ "value": "/view"
14
+ },
15
+ {
16
+ "title": "新建页",
17
+ "value": "/new"
18
+ }
19
+ ],
20
+ "deviceTypes": ["pc"]
21
+ }
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "<%= pluginName %>",
3
+ "version": "1.0.0",
4
+ "description": "<%= pluginName %>",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1",
8
+ "build": "webpack --mode=production --node-env=production && maxelms-plugin-cli -c",
9
+ "build:dev": "webpack --mode=development",
10
+ "build:prod": "webpack --mode=production --node-env=production",
11
+ "serve": "webpack serve",
12
+ "start": "webpack serve"
13
+ },
14
+ "keywords": [],
15
+ "author": "",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "moment-locales-webpack-plugin": "1.2.0",
19
+ "@babel/core": "7.15.8",
20
+ "@babel/preset-react": "7.14.5",
21
+ "@maxelms/create-plugin-cli": "<%= cliVersion %>",
22
+ "@squoosh/lib": "0.5.3",
23
+ "@types/react": "17.0.27",
24
+ "@types/react-dom": "17.0.9",
25
+ "@webpack-cli/generators": "2.4.0",
26
+ "archiver": "5.3.1",
27
+ "autoprefixer": "10.3.7",
28
+ "babel-loader": "8.2.2",
29
+ "babel-plugin-import": "1.13.5",
30
+ "copy-webpack-plugin": "11.0.0",
31
+ "css-loader": "6.3.0",
32
+ "css-minimizer-webpack-plugin": "4.2.1",
33
+ "html-webpack-plugin": "5.3.2",
34
+ "image-minimizer-webpack-plugin": "3.8.1",
35
+ "less": "4.1.2",
36
+ "less-loader": "10.0.1",
37
+ "mini-css-extract-plugin": "2.4.2",
38
+ "postcss-loader": "6.1.1",
39
+ "style-loader": "3.3.0",
40
+ "ts-loader": "9.2.6",
41
+ "typescript": "4.4.3",
42
+ "webpack": "5.58.0",
43
+ "webpack-cli": "4.10.0",
44
+ "webpack-dev-server": "4.3.1",
45
+ "workbox-webpack-plugin": "6.3.0"
46
+ },
47
+ "dependencies": {
48
+ "antd": "4.21.2",
49
+ "react": "17.0.2",
50
+ "react-dom": "17.0.2",
51
+ "react-router-dom": "6.4.3"
52
+ }
53
+ }
@@ -0,0 +1,30 @@
1
+ {
2
+ "propName1": {
3
+ "label": "配置项一",
4
+ "type": "string",
5
+ "defaultValue": "配置项内容"
6
+ },
7
+ "propName2": {
8
+ "label": "配置项二",
9
+ "type": "number",
10
+ "defaultValue": 350
11
+ },
12
+ "propName3": {
13
+ "label": "配置项三",
14
+ "type": "select",
15
+ "options": [
16
+ {
17
+ "label": "选项1",
18
+ "value": "option1"
19
+ },
20
+ {
21
+ "label": "选项2",
22
+ "value": "option2"
23
+ },
24
+ {
25
+ "label": "选项3",
26
+ "value": "option3"
27
+ }
28
+ ]
29
+ }
30
+ }
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Maxelms MicroApp</title>
6
+ </head>
7
+ <body>
8
+ <div id="micro-app" style="height: 100%;"></div>
9
+ </body>
10
+ </html>
@@ -0,0 +1,15 @@
1
+ import React from 'react'
2
+ import { Link } from "react-router-dom"
3
+
4
+ const NoMatch = () => {
5
+ return (
6
+ <div style={{ textAlign: 'center' }}>
7
+ <h2>Nothing to see here!</h2>
8
+ <p>
9
+ <Link to="/">Go to the home page</Link>
10
+ </p>
11
+ </div>
12
+ );
13
+ }
14
+
15
+ export default NoMatch
@@ -0,0 +1,11 @@
1
+ import React from 'react'
2
+
3
+ const Context = React.createContext<{
4
+ base: string;
5
+ container: HTMLDivElement;
6
+ configurations?: Record<string, any>
7
+ [key: string]: any;
8
+ } | null>(null)
9
+
10
+
11
+ export default Context
@@ -0,0 +1,52 @@
1
+
2
+ import React from 'react'
3
+ import ReactDOM from 'react-dom'
4
+ import { RouterProvider } from "react-router-dom"
5
+ import Context from '@/context/masterContext'
6
+ import initRouter from '@/router'
7
+ import './public-path'
8
+
9
+ const rootId = 'micro-app'
10
+
11
+ const render = (props?: any) => {
12
+ const { container, base } = props || {}
13
+ const root = container ? container.querySelector(`#${rootId}`) : document.getElementById(rootId)
14
+ ReactDOM.render((
15
+ <Context.Provider value={props}>
16
+ <RouterProvider router={initRouter(base)} />
17
+ </Context.Provider>
18
+ ), root)
19
+ }
20
+
21
+ // @ts-ignore
22
+ if (!window.__POWERED_BY_QIANKUN__) {
23
+ render()
24
+ }
25
+
26
+ /**
27
+ * bootstrap 只会在微应用初始化的时候调用一次,下次微应用重新进入时会直接调用 mount 钩子,不会再重复触发 bootstrap。
28
+ * 通常我们可以在这里做一些全局变量的初始化,比如不会在 unmount 阶段被销毁的应用级别的缓存等。
29
+ */
30
+ export async function bootstrap() {
31
+ }
32
+
33
+ /**
34
+ * 应用每次进入都会调用 mount 方法,通常我们在这里触发应用的渲染方法
35
+ */
36
+ export async function mount(props: any) {
37
+ render(props)
38
+ }
39
+
40
+ /**
41
+ * 应用每次 切出/卸载 会调用的方法,通常在这里我们会卸载微应用的应用实例
42
+ */
43
+ export async function unmount(props: any) {
44
+ const { container } = props || {}
45
+ const root = container ? container.querySelector(`#${rootId}`) : document.getElementById(rootId)
46
+ root && ReactDOM.unmountComponentAtNode(root)
47
+ }
48
+
49
+
50
+ export async function update(props: any) {
51
+ render(props)
52
+ }
@@ -0,0 +1,16 @@
1
+ .container {
2
+ height: 100%;
3
+ display: flex;
4
+ flex-direction: column;
5
+ :global {
6
+
7
+ }
8
+ }
9
+
10
+ .content {
11
+ flex: 1;
12
+ overflow: auto;
13
+ > div {
14
+ height: 100%;
15
+ }
16
+ }
@@ -0,0 +1,21 @@
1
+ import React from 'react'
2
+ import { Outlet, Link } from "react-router-dom"
3
+ import styles from './BasicLayout.less'
4
+
5
+ const BasicLayout: React.FC = props=> {
6
+ return (
7
+ <div className={styles.container}>
8
+ <header>
9
+ <Link to="/">首页</Link> |
10
+ <Link to="/new">新建</Link> |
11
+ <Link to="/list">列表</Link> |
12
+ <Link to="/view">详情</Link>
13
+ </header>
14
+ <div className={styles.content}>
15
+ <Outlet />
16
+ </div>
17
+ </div>
18
+ )
19
+ }
20
+
21
+ export default BasicLayout
@@ -0,0 +1,15 @@
1
+
2
+
3
+ .container {
4
+ :global {
5
+
6
+ display: flex;
7
+ align-items: center;
8
+ justify-content: center;
9
+ flex-direction: column;
10
+ input {
11
+ text-align: center;
12
+ }
13
+ }
14
+ }
15
+
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { Input } from 'antd'
3
+ import MasterContext from '@/context/masterContext'
4
+ import styles from './index.less'
5
+
6
+
7
+ const Home = () => {
8
+ /** APaaS 平台传递给微应用的状态数据 */
9
+ const props = React.useContext(MasterContext)
10
+ /** 当组件运行在 APaaS 基座应用时才存在 props 属性 */
11
+ const { configurations } = props || {}
12
+ /** configurations 是组件的配置项信息 */
13
+ const {
14
+ propName1: placeholder,
15
+ propName2: width = 350,
16
+ propName3: disabled,
17
+ } = configurations || {}
18
+
19
+ return (
20
+ <div className={styles.container}>
21
+ <div>
22
+ <Input
23
+ style={{ width }}
24
+ disabled={disabled}
25
+ placeholder={placeholder}
26
+ defaultValue="欢迎使用 Maxelms 微应用"
27
+ />
28
+ </div>
29
+ </div>
30
+ );
31
+ };
32
+
33
+ export default Home;
@@ -0,0 +1,12 @@
1
+
2
+
3
+ .container {
4
+ :global {
5
+
6
+
7
+
8
+
9
+
10
+
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import React from 'react'
2
+ import styles from './index.less'
3
+
4
+ const List = () => {
5
+ return (
6
+ <div className={styles.container}>
7
+ List
8
+ </div>
9
+ )
10
+ }
11
+
12
+ export default List
@@ -0,0 +1,12 @@
1
+
2
+
3
+ .container {
4
+ :global {
5
+
6
+
7
+
8
+
9
+
10
+
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import React from 'react'
2
+ import styles from './index.less'
3
+
4
+ const New = () => {
5
+ return (
6
+ <div className={styles.container}>
7
+ New
8
+ </div>
9
+ )
10
+ }
11
+
12
+ export default New
@@ -0,0 +1,12 @@
1
+
2
+
3
+ .container {
4
+ :global {
5
+
6
+
7
+
8
+
9
+
10
+
11
+ }
12
+ }
@@ -0,0 +1,12 @@
1
+ import React from 'react'
2
+ import styles from './index.less'
3
+
4
+ const View = () => {
5
+ return (
6
+ <div className={styles.container}>
7
+ View
8
+ </div>
9
+ )
10
+ }
11
+
12
+ export default View
@@ -0,0 +1,4 @@
1
+ // @ts-nocheck
2
+ if (window?.__INJECTED_PUBLIC_PATH_BY_QIANKUN__) {
3
+ __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
4
+ }
@@ -0,0 +1,44 @@
1
+ import React from 'react'
2
+ import { createHashRouter } from "react-router-dom"
3
+ import BasicLayout from '@/layouts/BasicLayout'
4
+ import NoMatch from '@/components/NoMatch'
5
+ import New from '@/pages/New'
6
+ import List from '@/pages/List'
7
+ import View from '@/pages/View'
8
+ import Home from '@/pages/Home'
9
+
10
+
11
+ const initRouter = (basename?: string) => {
12
+ return createHashRouter([
13
+ {
14
+ path: '/',
15
+ element: <BasicLayout />,
16
+ children: [
17
+ {
18
+ index: true,
19
+ element: <Home />,
20
+ },
21
+ {
22
+ path: "/new",
23
+ element: <New />,
24
+ },
25
+ {
26
+ path: "/list",
27
+ element: <List />,
28
+ },
29
+ {
30
+ path: "/view",
31
+ element: <View />,
32
+ },
33
+ ],
34
+ },
35
+ {
36
+ path: "*",
37
+ element: <NoMatch />,
38
+ },
39
+ ], {
40
+ basename,
41
+ });
42
+ }
43
+
44
+ export default initRouter
@@ -0,0 +1,102 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Enable incremental compilation */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "es5", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ "lib": ["ES2015", "DOM"], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ "jsx": "react", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
22
+ // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+
26
+ /* Modules */
27
+ "module": "ESNext", /* Specify what module code is generated. */
28
+ // "rootDir": "./", /* Specify the root folder within your source files. */
29
+ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
30
+ "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
31
+ "paths": {
32
+ "@/*": ["./src/*"],
33
+ }, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
+ // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
36
+ // "types": [], /* Specify type package names to be included without being referenced in a source file. */
37
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
38
+ // "resolveJsonModule": true, /* Enable importing .json files */
39
+ // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
40
+
41
+ /* JavaScript Support */
42
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */
43
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
45
+
46
+ /* Emit */
47
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
52
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
53
+ // "removeComments": true, /* Disable emitting comments. */
54
+ // "noEmit": true, /* Disable emitting files from a compilation. */
55
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
57
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
64
+ // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
65
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
66
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
+ // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
68
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
+
70
+ /* Interop Constraints */
71
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
72
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
73
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */
74
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
75
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
76
+
77
+ /* Type Checking */
78
+ "strict": true, /* Enable all strict type-checking options. */
79
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
80
+ // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
81
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
82
+ // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
83
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
84
+ // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
85
+ // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
86
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
87
+ // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
88
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
89
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
90
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
91
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
92
+ // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
93
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
94
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
95
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
96
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
97
+
98
+ /* Completeness */
99
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
100
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
101
+ }
102
+ }
@@ -0,0 +1,11 @@
1
+ declare module '*.css'
2
+ declare module '*.less'
3
+ declare module '*.scss'
4
+ declare module '*.sass'
5
+ declare module '*.svg'
6
+ declare module '*.png'
7
+ declare module '*.jpg'
8
+ declare module '*.jpeg'
9
+ declare module '*.gif'
10
+ declare module '*.bmp'
11
+ declare module '*.tiff'