@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.
- package/README.en.md +36 -0
- package/README.md +12 -0
- package/bin/build.js +29 -0
- package/bin/compress.js +35 -0
- package/bin/copy.js +39 -0
- package/bin/index.js +53 -0
- package/configuration-schema.json +829 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +242 -0
- package/lib/utils.d.ts +18 -0
- package/lib/utils.js +114 -0
- package/package.json +50 -0
- package/templates/jQuery-micro-app/package.json.tpl +19 -0
- package/templates/jQuery-micro-app/src/README.md +5 -0
- package/templates/jQuery-micro-app/src/configuration.json +30 -0
- package/templates/jQuery-micro-app/src/index.html +17 -0
- package/templates/jQuery-micro-app/src/main.js.tpl +31 -0
- package/templates/jQuery-micro-app/src/manifest.json.tpl +9 -0
- package/templates/jQuery-micro-app/src/style.css +11 -0
- package/templates/maxelms-navigation/.babelrc +7 -0
- package/templates/maxelms-navigation/.gitignore.tpl +23 -0
- package/templates/maxelms-navigation/README.md +15 -0
- package/templates/maxelms-navigation/global.d.ts +2 -0
- package/templates/maxelms-navigation/index.html +16 -0
- package/templates/maxelms-navigation/package.json +65 -0
- package/templates/maxelms-navigation/patches/live2d-widget@3.1.4.patch +4534 -0
- package/templates/maxelms-navigation/pnpm-lock.yaml +7993 -0
- package/templates/maxelms-navigation/src/App.tsx +47 -0
- package/templates/maxelms-navigation/src/components/Actions/ColorPicker.tsx +86 -0
- package/templates/maxelms-navigation/src/components/Actions/SwitchApps.tsx +83 -0
- package/templates/maxelms-navigation/src/components/Actions/index.tsx +95 -0
- package/templates/maxelms-navigation/src/components/Cutie.tsx +24 -0
- package/templates/maxelms-navigation/src/components/Enterprises.tsx +46 -0
- package/templates/maxelms-navigation/src/components/Logo.tsx +29 -0
- package/templates/maxelms-navigation/src/components/Menus/MenuPanel.tsx +55 -0
- package/templates/maxelms-navigation/src/components/Menus/index.tsx +50 -0
- package/templates/maxelms-navigation/src/components/Search.tsx +77 -0
- package/templates/maxelms-navigation/src/imgs/corp-admin.svg +1 -0
- package/templates/maxelms-navigation/src/imgs/saas-admin.svg +1 -0
- package/templates/maxelms-navigation/src/imgs/skin.svg +1 -0
- package/templates/maxelms-navigation/src/imgs/tenant-admin.svg +1 -0
- package/templates/maxelms-navigation/src/imgs/user-center.svg +1 -0
- package/templates/maxelms-navigation/src/index.tsx +14 -0
- package/templates/maxelms-navigation/src/interface.ts +27 -0
- package/templates/maxelms-navigation/src/style.less.tpl +278 -0
- package/templates/maxelms-navigation/src/utils.ts.tpl +40 -0
- package/templates/maxelms-navigation/tsconfig.json +111 -0
- package/templates/maxelms-navigation/webpack.config.js +119 -0
- package/templates/maxelms-script/.babelrc +5 -0
- package/templates/maxelms-script/.gitignore.tpl +23 -0
- package/templates/maxelms-script/README.md +0 -0
- package/templates/maxelms-script/global.d.ts +2 -0
- package/templates/maxelms-script/index.html +10 -0
- package/templates/maxelms-script/package.json.tpl +55 -0
- package/templates/maxelms-script/pnpm-lock.yaml +7699 -0
- package/templates/maxelms-script/src/App.tsx +15 -0
- package/templates/maxelms-script/src/index.tsx +15 -0
- package/templates/maxelms-script/src/style.less.tpl +8 -0
- package/templates/maxelms-script/src/utils.ts.tpl +2 -0
- package/templates/maxelms-script/tsconfig.json +111 -0
- package/templates/maxelms-script/webpack.config.js +92 -0
- package/templates/maxelms-style/.gitignore.tpl +38 -0
- package/templates/maxelms-style/README.md +0 -0
- package/templates/maxelms-style/index.css +3 -0
- package/templates/maxelms-style/index.less +4 -0
- package/templates/maxelms-style/package.json.tpl +17 -0
- package/templates/playground/dist/main.css +2 -0
- package/templates/playground/dist/main.js +2 -0
- package/templates/playground/dist/main.js.LICENSE.txt +52 -0
- package/templates/playground/dist/playground.html +1 -0
- package/templates/playground/dist/react-dom.production.min.js +2 -0
- package/templates/playground/dist/react-dom.production.min.js.LICENSE.txt +8 -0
- package/templates/playground/dist/react.production.min.js +2 -0
- package/templates/playground/dist/react.production.min.js.LICENSE.txt +8 -0
- package/templates/playground/dist/zone.umd.min.js +2 -0
- package/templates/playground/dist/zone.umd.min.js.LICENSE.txt +29 -0
- package/templates/project/package.json +17 -0
- package/templates/react-micro-app/.babelrc +6 -0
- package/templates/react-micro-app/.gitignore.tpl +23 -0
- package/templates/react-micro-app/README.md +5 -0
- package/templates/react-micro-app/manifest.json.tpl +21 -0
- package/templates/react-micro-app/package.json.tpl +53 -0
- package/templates/react-micro-app/public/configuration.json +30 -0
- package/templates/react-micro-app/public/index.html +10 -0
- package/templates/react-micro-app/src/components/NoMatch.tsx +15 -0
- package/templates/react-micro-app/src/context/masterContext.ts +11 -0
- package/templates/react-micro-app/src/index.tsx +52 -0
- package/templates/react-micro-app/src/layouts/BasicLayout.less +16 -0
- package/templates/react-micro-app/src/layouts/BasicLayout.tsx +21 -0
- package/templates/react-micro-app/src/pages/Home/index.less +15 -0
- package/templates/react-micro-app/src/pages/Home/index.tsx +33 -0
- package/templates/react-micro-app/src/pages/List/index.less +12 -0
- package/templates/react-micro-app/src/pages/List/index.tsx +12 -0
- package/templates/react-micro-app/src/pages/New/index.less +12 -0
- package/templates/react-micro-app/src/pages/New/index.tsx +12 -0
- package/templates/react-micro-app/src/pages/View/index.less +12 -0
- package/templates/react-micro-app/src/pages/View/index.tsx +12 -0
- package/templates/react-micro-app/src/public-path.js +4 -0
- package/templates/react-micro-app/src/router.tsx +44 -0
- package/templates/react-micro-app/tsconfig.json +102 -0
- package/templates/react-micro-app/typings.d.ts +11 -0
- package/templates/react-micro-app/webpack.config.js.tpl +178 -0
- package/templates/react-micro-app-umi/.editorconfig +16 -0
- package/templates/react-micro-app-umi/.env +1 -0
- package/templates/react-micro-app-umi/.gitignore.tpl +23 -0
- package/templates/react-micro-app-umi/.prettierignore +8 -0
- package/templates/react-micro-app-umi/.prettierrc +11 -0
- package/templates/react-micro-app-umi/.umirc.ts.tpl +31 -0
- package/templates/react-micro-app-umi/README.md +5 -0
- package/templates/react-micro-app-umi/manifest.json.tpl +21 -0
- package/templates/react-micro-app-umi/package.json.tpl +42 -0
- package/templates/react-micro-app-umi/public/basicConfiguration.json +30 -0
- package/templates/react-micro-app-umi/public/configuration.json +30 -0
- package/templates/react-micro-app-umi/src/layout/BasicLayout.tsx +16 -0
- package/templates/react-micro-app-umi/src/pages/about.tsx +11 -0
- package/templates/react-micro-app-umi/src/pages/home.tsx +19 -0
- package/templates/react-micro-app-umi/tsconfig.json +36 -0
- package/templates/react-micro-app-umi/typings.d.ts +8 -0
- package/templates/react-micro-button/.gitignore.tpl +23 -0
- package/templates/react-micro-button/README.md +5 -0
- package/templates/react-micro-button/configuration/Configuration.tsx +113 -0
- package/templates/react-micro-button/configuration/index.css +8 -0
- package/templates/react-micro-button/configuration/index.tsx +6 -0
- package/templates/react-micro-button/manifest.json.tpl +3 -0
- package/templates/react-micro-button/package.json.tpl +49 -0
- package/templates/react-micro-button/postcss.config.js +5 -0
- package/templates/react-micro-button/public/basicConfiguration.json +30 -0
- package/templates/react-micro-button/public/configuration.html +10 -0
- package/templates/react-micro-button/public/configuration.json +30 -0
- package/templates/react-micro-button/public/index.html +10 -0
- package/templates/react-micro-button/src/App.tsx +41 -0
- package/templates/react-micro-button/src/app.less +0 -0
- package/templates/react-micro-button/src/index.less +0 -0
- package/templates/react-micro-button/src/index.tsx +30 -0
- package/templates/react-micro-button/tsconfig.json +11 -0
- package/templates/react-micro-button/webpack.config.js.tpl +150 -0
- package/templates/react-micro-field/.babelrc +5 -0
- package/templates/react-micro-field/.gitignore.tpl +23 -0
- package/templates/react-micro-field/README.md +5 -0
- package/templates/react-micro-field/configuration/Configuration.tsx +113 -0
- package/templates/react-micro-field/configuration/index.css +8 -0
- package/templates/react-micro-field/configuration/index.tsx +6 -0
- package/templates/react-micro-field/manifest.json.tpl +7 -0
- package/templates/react-micro-field/package.json.tpl +50 -0
- package/templates/react-micro-field/postcss.config.js +5 -0
- package/templates/react-micro-field/public/basicConfiguration.json +30 -0
- package/templates/react-micro-field/public/configuration.html +10 -0
- package/templates/react-micro-field/public/configuration.json +30 -0
- package/templates/react-micro-field/public/index.html +10 -0
- package/templates/react-micro-field/src/App.tsx.tpl +51 -0
- package/templates/react-micro-field/src/index.tsx +29 -0
- package/templates/react-micro-field/src/style.less.tpl +12 -0
- package/templates/react-micro-field/tsconfig.json +11 -0
- package/templates/react-micro-field/webpack.config.js.tpl +157 -0
- package/templates/react-micro-field-umi/.editorconfig +16 -0
- package/templates/react-micro-field-umi/.gitignore.tpl +24 -0
- package/templates/react-micro-field-umi/.prettierignore +8 -0
- package/templates/react-micro-field-umi/.prettierrc +11 -0
- package/templates/react-micro-field-umi/README.md +5 -0
- package/templates/react-micro-field-umi/config/config.ts.tpl +41 -0
- package/templates/react-micro-field-umi/config/plugin.ts +18 -0
- package/templates/react-micro-field-umi/manifest.json.tpl +7 -0
- package/templates/react-micro-field-umi/package.json.tpl +48 -0
- package/templates/react-micro-field-umi/public/basicConfiguration.json +30 -0
- package/templates/react-micro-field-umi/public/configuration.json +30 -0
- package/templates/react-micro-field-umi/src/app.tsx +46 -0
- package/templates/react-micro-field-umi/src/global.tsx +0 -0
- package/templates/react-micro-field-umi/src/hooks/masterProps.ts +33 -0
- package/templates/react-micro-field-umi/src/layouts/BasicLayout.tsx +17 -0
- package/templates/react-micro-field-umi/src/pages/configuration/index.tsx +90 -0
- package/templates/react-micro-field-umi/src/pages/index.tsx.tpl +54 -0
- package/templates/react-micro-field-umi/src/pages/interface.ts +12 -0
- package/templates/react-micro-field-umi/src/pages/style.less.tpl +15 -0
- package/templates/react-micro-field-umi/src/public-path.js +5 -0
- package/templates/react-micro-field-umi/tsconfig.json +37 -0
- package/templates/react-micro-field-umi/typings.d.ts +10 -0
- package/templates/react-micro-plugin/.babelrc +5 -0
- package/templates/react-micro-plugin/.gitignore.tpl +23 -0
- package/templates/react-micro-plugin/README.md +5 -0
- package/templates/react-micro-plugin/configuration/Configuration.tsx +114 -0
- package/templates/react-micro-plugin/configuration/index.css +8 -0
- package/templates/react-micro-plugin/configuration/index.tsx +6 -0
- package/templates/react-micro-plugin/manifest.json.tpl +3 -0
- package/templates/react-micro-plugin/package.json.tpl +50 -0
- package/templates/react-micro-plugin/postcss.config.js +5 -0
- package/templates/react-micro-plugin/public/configuration.html +10 -0
- package/templates/react-micro-plugin/public/configuration.json +30 -0
- package/templates/react-micro-plugin/public/index.html +10 -0
- package/templates/react-micro-plugin/src/App.tsx.tpl +32 -0
- package/templates/react-micro-plugin/src/index.tsx +29 -0
- package/templates/react-micro-plugin/src/style.less.tpl +12 -0
- package/templates/react-micro-plugin/tsconfig.json +11 -0
- package/templates/react-micro-plugin/webpack.config.js.tpl +156 -0
- package/templates/react-micro-plugin-umi/.editorconfig +16 -0
- package/templates/react-micro-plugin-umi/.gitignore.tpl +24 -0
- package/templates/react-micro-plugin-umi/.prettierignore +8 -0
- package/templates/react-micro-plugin-umi/.prettierrc +11 -0
- package/templates/react-micro-plugin-umi/README.md +5 -0
- package/templates/react-micro-plugin-umi/config/config.ts +29 -0
- package/templates/react-micro-plugin-umi/config/plugin.ts +18 -0
- package/templates/react-micro-plugin-umi/manifest.json.tpl +3 -0
- package/templates/react-micro-plugin-umi/package.json.tpl +48 -0
- package/templates/react-micro-plugin-umi/public/configuration.json +30 -0
- package/templates/react-micro-plugin-umi/src/app.tsx +46 -0
- package/templates/react-micro-plugin-umi/src/global.tsx +0 -0
- package/templates/react-micro-plugin-umi/src/hooks/masterProps.ts +34 -0
- package/templates/react-micro-plugin-umi/src/layouts/BasicLayout.tsx +17 -0
- package/templates/react-micro-plugin-umi/src/pages/configuration/index.tsx +113 -0
- package/templates/react-micro-plugin-umi/src/pages/index.tsx +21 -0
- package/templates/react-micro-plugin-umi/src/public-path.js +5 -0
- package/templates/react-micro-plugin-umi/tsconfig.json +37 -0
- package/templates/react-micro-plugin-umi/typings.d.ts +10 -0
- package/templates/vue-micro-app/.gitignore.tpl +23 -0
- package/templates/vue-micro-app/README.md +5 -0
- package/templates/vue-micro-app/babel.config.js +15 -0
- package/templates/vue-micro-app/manifest.json.tpl +21 -0
- package/templates/vue-micro-app/package.json.tpl +54 -0
- package/templates/vue-micro-app/public/configuration.json +30 -0
- package/templates/vue-micro-app/public/favicon.ico +0 -0
- package/templates/vue-micro-app/public/index.html +10 -0
- package/templates/vue-micro-app/src/App.vue +35 -0
- package/templates/vue-micro-app/src/assets/logo.png +0 -0
- package/templates/vue-micro-app/src/components/HelloWorld.vue +32 -0
- package/templates/vue-micro-app/src/main.js +80 -0
- package/templates/vue-micro-app/src/public-path.js +5 -0
- package/templates/vue-micro-app/src/routes.js +19 -0
- package/templates/vue-micro-app/src/views/About.vue +13 -0
- package/templates/vue-micro-app/src/views/Home.vue +21 -0
- package/templates/vue-micro-app/vue.config.js.tpl +35 -0
- package/templates/vue-micro-button/.gitignore.tpl +23 -0
- package/templates/vue-micro-button/README.md +5 -0
- package/templates/vue-micro-button/babel.config.js +8 -0
- package/templates/vue-micro-button/configuration/App.vue +78 -0
- package/templates/vue-micro-button/configuration/main.js +11 -0
- package/templates/vue-micro-button/manifest.json.tpl +3 -0
- package/templates/vue-micro-button/package.json.tpl +51 -0
- package/templates/vue-micro-button/public/basicConfiguration.json +30 -0
- package/templates/vue-micro-button/public/configuration.html +10 -0
- package/templates/vue-micro-button/public/configuration.json +30 -0
- package/templates/vue-micro-button/public/index.html +12 -0
- package/templates/vue-micro-button/src/App.vue +46 -0
- package/templates/vue-micro-button/src/main.js +44 -0
- package/templates/vue-micro-button/vue.config.js.tpl +51 -0
- package/templates/vue-micro-field/.gitignore.tpl +23 -0
- package/templates/vue-micro-field/README.md +5 -0
- package/templates/vue-micro-field/babel.config.js +8 -0
- package/templates/vue-micro-field/configuration/App.vue +78 -0
- package/templates/vue-micro-field/configuration/main.js +11 -0
- package/templates/vue-micro-field/manifest.json.tpl +7 -0
- package/templates/vue-micro-field/package.json.tpl +53 -0
- package/templates/vue-micro-field/public/basicConfiguration.json +30 -0
- package/templates/vue-micro-field/public/configuration.html +10 -0
- package/templates/vue-micro-field/public/configuration.json +30 -0
- package/templates/vue-micro-field/public/index.html +10 -0
- package/templates/vue-micro-field/scripts/compress.js +32 -0
- package/templates/vue-micro-field/src/App.vue.tpl +55 -0
- package/templates/vue-micro-field/src/main.js +38 -0
- package/templates/vue-micro-field/src/style.less.tpl +16 -0
- package/templates/vue-micro-field/vue.config.js.tpl +51 -0
- package/templates/vue-micro-plugin/.gitignore.tpl +23 -0
- package/templates/vue-micro-plugin/README.md +24 -0
- package/templates/vue-micro-plugin/babel.config.js +8 -0
- package/templates/vue-micro-plugin/configuration/App.vue +100 -0
- package/templates/vue-micro-plugin/configuration/main.js +11 -0
- package/templates/vue-micro-plugin/manifest.json.tpl +3 -0
- package/templates/vue-micro-plugin/package.json.tpl +56 -0
- package/templates/vue-micro-plugin/public/configuration.html +10 -0
- package/templates/vue-micro-plugin/public/configuration.json +30 -0
- package/templates/vue-micro-plugin/public/index.html +10 -0
- package/templates/vue-micro-plugin/scripts/compress.js +32 -0
- package/templates/vue-micro-plugin/src/App.vue.tpl +42 -0
- package/templates/vue-micro-plugin/src/main.js +38 -0
- package/templates/vue-micro-plugin/src/style.less.tpl +16 -0
- package/templates/vue-micro-plugin/vue.config.js.tpl +53 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"description": "Maxelms plugin react demo",
|
|
4
|
+
"name": "<%= pluginName %>",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "webpack --mode=production --node-env=production && maxelms-plugin-cli -c",
|
|
7
|
+
"build:dev": "webpack --mode=development",
|
|
8
|
+
"build:prod": "webpack --mode=production --node-env=production",
|
|
9
|
+
"serve": "webpack serve",
|
|
10
|
+
"start": "webpack serve"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"moment-locales-webpack-plugin": "1.2.0",
|
|
14
|
+
"@babel/core": "7.15.8",
|
|
15
|
+
"@babel/preset-react": "7.14.5",
|
|
16
|
+
"@maxelms/create-plugin-cli": "<%= cliVersion %>",
|
|
17
|
+
"@squoosh/lib": "0.5.3",
|
|
18
|
+
"@types/react": "17.0.33",
|
|
19
|
+
"@types/react-dom": "17.0.10",
|
|
20
|
+
"archiver": "5.3.1",
|
|
21
|
+
"autoprefixer": "10.3.7",
|
|
22
|
+
"babel-loader": "8.2.3",
|
|
23
|
+
"clean-webpack-plugin": "4.0.0",
|
|
24
|
+
"copy-webpack-plugin": "10.2.0",
|
|
25
|
+
"css-loader": "6.5.0",
|
|
26
|
+
"css-minimizer-webpack-plugin": "4.2.1",
|
|
27
|
+
"html-webpack-plugin": "5.5.0",
|
|
28
|
+
"image-minimizer-webpack-plugin": "3.8.1",
|
|
29
|
+
"less": "4.1.2",
|
|
30
|
+
"less-loader": "10.2.0",
|
|
31
|
+
"mini-css-extract-plugin": "2.4.3",
|
|
32
|
+
"postcss": "8.3.11",
|
|
33
|
+
"postcss-loader": "6.2.0",
|
|
34
|
+
"prettier": "2.4.1",
|
|
35
|
+
"style-loader": "3.3.1",
|
|
36
|
+
"ts-loader": "9.2.6",
|
|
37
|
+
"typescript": "4.4.4",
|
|
38
|
+
"webpack": "5.60.0",
|
|
39
|
+
"webpack-cli": "4.10.0",
|
|
40
|
+
"webpack-dev-server": "4.4.0",
|
|
41
|
+
"workbox-webpack-plugin": "6.3.0"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@max-kit/max-api": "1.0.1",
|
|
45
|
+
"antd": "4.21.2",
|
|
46
|
+
"react": "16.14.0",
|
|
47
|
+
"react-dom": "16.14.0"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -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,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,41 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { Modal } from 'antd'
|
|
3
|
+
import { ButtonPluginProps } from '@max-kit/max-api'
|
|
4
|
+
import 'antd/lib/modal/style'
|
|
5
|
+
|
|
6
|
+
const App = (props: ButtonPluginProps) => {
|
|
7
|
+
const { originalButtonProps, bizData, pluginEnv, userInfo } = props
|
|
8
|
+
const { name = <button>自定义按钮</button> } = originalButtonProps || {}
|
|
9
|
+
const [visible, setVisible] = React.useState(false)
|
|
10
|
+
|
|
11
|
+
const onOk = () => {
|
|
12
|
+
setVisible(false)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const onCancel = () => {
|
|
16
|
+
setVisible(false)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<>
|
|
21
|
+
<Modal
|
|
22
|
+
title="弹窗"
|
|
23
|
+
okText="确定"
|
|
24
|
+
cancelText="取消"
|
|
25
|
+
visible={visible}
|
|
26
|
+
closable={false}
|
|
27
|
+
onOk={onOk}
|
|
28
|
+
onCancel={onCancel}
|
|
29
|
+
>
|
|
30
|
+
<p>可以在此处编写弹出层 UI 逻辑</p>
|
|
31
|
+
</Modal>
|
|
32
|
+
|
|
33
|
+
{/* 在此处编写要渲染在按钮内的 UI 逻辑,务必保持 UI 简洁,避免影响页面效果 */}
|
|
34
|
+
<span onClick={() => setVisible(true)}>
|
|
35
|
+
{name}
|
|
36
|
+
</span>
|
|
37
|
+
</>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default App
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
import { registerPlugin, poweredByMaxelms, ButtonPluginProps, BasePluginProps } from '@max-kit/max-api'
|
|
4
|
+
import App from './App';
|
|
5
|
+
import './index.less';
|
|
6
|
+
|
|
7
|
+
const render = (container: string, props?: ButtonPluginProps) => {
|
|
8
|
+
ReactDOM.render(<App {...props} />, document.querySelector(container));
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const container = '#micro-button-root';
|
|
12
|
+
|
|
13
|
+
if (poweredByMaxelms) {
|
|
14
|
+
registerPlugin({
|
|
15
|
+
bootstrap() {
|
|
16
|
+
},
|
|
17
|
+
mount(props: ButtonPluginProps) {
|
|
18
|
+
render(`#${props.containerId} ${container}`, props);
|
|
19
|
+
},
|
|
20
|
+
update(props: ButtonPluginProps) {
|
|
21
|
+
render(`#${props.containerId} ${container}`, props);
|
|
22
|
+
},
|
|
23
|
+
unmount(props: BasePluginProps) {
|
|
24
|
+
const element = document.querySelector(`#${props.containerId} ${container}`)
|
|
25
|
+
element && ReactDOM.unmountComponentAtNode(element);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
render(container);
|
|
30
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Generated using webpack-cli https://github.com/webpack/webpack-cli
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
|
5
|
+
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
|
6
|
+
const MomentLocalesPlugin = require('moment-locales-webpack-plugin');
|
|
7
|
+
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
8
|
+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
9
|
+
const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
|
|
10
|
+
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
|
|
11
|
+
|
|
12
|
+
const isProduction = process.env.NODE_ENV == 'production';
|
|
13
|
+
|
|
14
|
+
const stylesHandler = MiniCssExtractPlugin.loader;
|
|
15
|
+
|
|
16
|
+
const config = {
|
|
17
|
+
entry: {
|
|
18
|
+
index: './src/index.tsx',
|
|
19
|
+
<% if (configurationType === 'html') {%>
|
|
20
|
+
configuration: './configuration/index.tsx',
|
|
21
|
+
<% } %>
|
|
22
|
+
},
|
|
23
|
+
output: {
|
|
24
|
+
publicPath: "",
|
|
25
|
+
path: path.resolve(__dirname, 'dist'),
|
|
26
|
+
filename: isProduction
|
|
27
|
+
? '[name].[contenthash].bundle.js'
|
|
28
|
+
: '[name].bundle.js',
|
|
29
|
+
},
|
|
30
|
+
devServer: {
|
|
31
|
+
host: 'localhost',
|
|
32
|
+
port: 8080,
|
|
33
|
+
headers: {
|
|
34
|
+
'Access-Control-Allow-Origin': '*',
|
|
35
|
+
},
|
|
36
|
+
static: [{
|
|
37
|
+
directory: path.join(__dirname, 'public/')
|
|
38
|
+
}],
|
|
39
|
+
},
|
|
40
|
+
plugins: [
|
|
41
|
+
new CleanWebpackPlugin(),
|
|
42
|
+
new MomentLocalesPlugin(),
|
|
43
|
+
new MiniCssExtractPlugin(),
|
|
44
|
+
new HtmlWebpackPlugin({
|
|
45
|
+
inject: true,
|
|
46
|
+
chunks: ['index'],
|
|
47
|
+
filename: 'index.html',
|
|
48
|
+
template: 'public/index.html',
|
|
49
|
+
}),
|
|
50
|
+
<% if (configurationType === 'html') {%>
|
|
51
|
+
new HtmlWebpackPlugin({
|
|
52
|
+
inject: true,
|
|
53
|
+
template: 'public/configuration.html',
|
|
54
|
+
chunks: ['configuration'],
|
|
55
|
+
filename: 'configuration.html',
|
|
56
|
+
}),
|
|
57
|
+
<% } %>
|
|
58
|
+
new CopyWebpackPlugin({
|
|
59
|
+
patterns: [
|
|
60
|
+
{
|
|
61
|
+
from: 'public',
|
|
62
|
+
globOptions: {
|
|
63
|
+
dot: true,
|
|
64
|
+
gitignore: true,
|
|
65
|
+
ignore: ['**/public/index.html', '**/public/configuration.html'],
|
|
66
|
+
},
|
|
67
|
+
noErrorOnMissing: true,
|
|
68
|
+
},
|
|
69
|
+
{ from: 'README.md' },
|
|
70
|
+
{ from: 'manifest.json' },
|
|
71
|
+
],
|
|
72
|
+
}),
|
|
73
|
+
],
|
|
74
|
+
module: {
|
|
75
|
+
rules: [
|
|
76
|
+
{
|
|
77
|
+
test: /\.(ts|tsx)$/i,
|
|
78
|
+
use: [
|
|
79
|
+
{
|
|
80
|
+
loader: 'babel-loader',
|
|
81
|
+
options: {
|
|
82
|
+
presets: ['@babel/preset-react'],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
'ts-loader',
|
|
86
|
+
],
|
|
87
|
+
exclude: ['/node_modules/'],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
test: /\.less$/i,
|
|
91
|
+
use: [stylesHandler, 'css-loader', 'postcss-loader', {
|
|
92
|
+
loader: 'less-loader',
|
|
93
|
+
options: {
|
|
94
|
+
lessOptions: {
|
|
95
|
+
javascriptEnabled: true
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
test: /\.css$/i,
|
|
102
|
+
use: [stylesHandler, 'css-loader', 'postcss-loader'],
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
|
|
106
|
+
type: 'asset',
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
// Add your rules for custom modules here
|
|
110
|
+
// Learn more about loaders from https://webpack.js.org/loaders/
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
resolve: {
|
|
114
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
115
|
+
},
|
|
116
|
+
optimization: {
|
|
117
|
+
minimizer: [
|
|
118
|
+
`...`,
|
|
119
|
+
new CssMinimizerPlugin(),
|
|
120
|
+
new ImageMinimizerPlugin({
|
|
121
|
+
test: /screenshots\/.*\.(jpe?g|png|avif)$/i,
|
|
122
|
+
minimizer: {
|
|
123
|
+
implementation: ImageMinimizerPlugin.squooshMinify,
|
|
124
|
+
options: {
|
|
125
|
+
encodeOptions: {
|
|
126
|
+
mozjpeg: {
|
|
127
|
+
quality: 15,
|
|
128
|
+
},
|
|
129
|
+
avif: {
|
|
130
|
+
cqLevel: 18,
|
|
131
|
+
speed: 6
|
|
132
|
+
},
|
|
133
|
+
oxipng: {
|
|
134
|
+
level: 2,
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
}),
|
|
140
|
+
],
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
module.exports = () => {
|
|
144
|
+
if (isProduction) {
|
|
145
|
+
config.mode = 'production';
|
|
146
|
+
} else {
|
|
147
|
+
config.mode = 'development';
|
|
148
|
+
}
|
|
149
|
+
return config;
|
|
150
|
+
};
|
|
@@ -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,113 @@
|
|
|
1
|
+
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
+
import { Form, Switch, Input, InputNumber, Select } from 'antd';
|
|
3
|
+
import { PluginChannel } from '@max-kit/max-api'
|
|
4
|
+
|
|
5
|
+
interface ConfigurationType {}
|
|
6
|
+
type PlainObject = Record<string, any>
|
|
7
|
+
interface FieldData {
|
|
8
|
+
pathChain: string;
|
|
9
|
+
fieldId: string;
|
|
10
|
+
fieldName: string;
|
|
11
|
+
objId: string;
|
|
12
|
+
objName: string;
|
|
13
|
+
type: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const initFormValues:PlainObject = {
|
|
17
|
+
size: 'default',
|
|
18
|
+
disabled: false,
|
|
19
|
+
placeholder: '',
|
|
20
|
+
maxLength: null,
|
|
21
|
+
label: '',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const Configuration: React.FC<ConfigurationType> = () => {
|
|
25
|
+
const [form] = Form.useForm()
|
|
26
|
+
|
|
27
|
+
const pluginChannelRef = useRef(null)
|
|
28
|
+
|
|
29
|
+
const [fields, setFields] = useState<FieldData[]>([])
|
|
30
|
+
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const channel = new PluginChannel({
|
|
33
|
+
init: initConfigs
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
pluginChannelRef.current = channel
|
|
37
|
+
getFormFieldsAsync(channel)
|
|
38
|
+
return () => {
|
|
39
|
+
channel.destroy()
|
|
40
|
+
}
|
|
41
|
+
}, []);
|
|
42
|
+
|
|
43
|
+
const initConfigs = (configs:PlainObject) => {
|
|
44
|
+
if (!configs || typeof configs !== 'object') return
|
|
45
|
+
if (typeof configs.field === 'object') configs.field = configs.field.pathChain
|
|
46
|
+
form.setFieldsValue(configs)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const submitConfig = () => {
|
|
50
|
+
const configs = form.getFieldsValue()
|
|
51
|
+
const { field } = configs
|
|
52
|
+
if (field) {
|
|
53
|
+
const fieldDetail = fields.find(item => item.pathChain === field)
|
|
54
|
+
if (fieldDetail) configs.field = fieldDetail
|
|
55
|
+
}
|
|
56
|
+
pluginChannelRef.current && pluginChannelRef.current.update(configs)
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const getFormFieldsAsync = (channel: PluginChannel) => {
|
|
60
|
+
channel.emit('getFormFieldsValueAsync').then((data: FieldData[]) => {
|
|
61
|
+
setFields(data)
|
|
62
|
+
}).catch(err => {
|
|
63
|
+
console.log('err: ', err)
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return (
|
|
68
|
+
<Form layout="vertical" form={form} initialValues={initFormValues} onFieldsChange={submitConfig} style={{padding: '10px'}}>
|
|
69
|
+
<Form.Item name="disabled" label="是否禁用" valuePropName="checked">
|
|
70
|
+
<Switch />
|
|
71
|
+
</Form.Item>
|
|
72
|
+
<Form.Item name="maxLength" label="最大长度">
|
|
73
|
+
<InputNumber />
|
|
74
|
+
</Form.Item>
|
|
75
|
+
<Form.Item name="size" label="控件大小">
|
|
76
|
+
<Select
|
|
77
|
+
options={[
|
|
78
|
+
{
|
|
79
|
+
label: 'default',
|
|
80
|
+
value: 'default',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: 'small',
|
|
84
|
+
value: 'small',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
label: 'large',
|
|
88
|
+
value: 'large',
|
|
89
|
+
},
|
|
90
|
+
]}
|
|
91
|
+
/>
|
|
92
|
+
</Form.Item>
|
|
93
|
+
<Form.Item name="placeholder" label="占位符">
|
|
94
|
+
<Input />
|
|
95
|
+
</Form.Item>
|
|
96
|
+
<Form.Item name="label" label="label">
|
|
97
|
+
<Input />
|
|
98
|
+
</Form.Item>
|
|
99
|
+
<Form.Item name="field" label="绑定字段">
|
|
100
|
+
<Select
|
|
101
|
+
options={fields.map((field) => {
|
|
102
|
+
return {
|
|
103
|
+
label: field.fieldName,
|
|
104
|
+
value: field.pathChain
|
|
105
|
+
}
|
|
106
|
+
})}
|
|
107
|
+
/>
|
|
108
|
+
</Form.Item>
|
|
109
|
+
</Form>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export default Configuration;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
body {
|
|
2
|
+
margin: 0;
|
|
3
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
+
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
+
sans-serif;
|
|
6
|
+
-webkit-font-smoothing: antialiased;
|
|
7
|
+
-moz-osx-font-smoothing: grayscale;
|
|
8
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"description": "Maxelms plugin react demo",
|
|
4
|
+
"name": "<%= pluginName %>",
|
|
5
|
+
"scripts": {
|
|
6
|
+
"build": "webpack --mode=production --node-env=production && maxelms-plugin-cli -c",
|
|
7
|
+
"build:dev": "webpack --mode=development",
|
|
8
|
+
"build:prod": "webpack --mode=production --node-env=production",
|
|
9
|
+
"serve": "webpack serve",
|
|
10
|
+
"start": "webpack serve"
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"babel-plugin-import": "1.13.5",
|
|
14
|
+
"moment-locales-webpack-plugin": "1.2.0",
|
|
15
|
+
"@babel/core": "7.15.8",
|
|
16
|
+
"@babel/preset-react": "7.14.5",
|
|
17
|
+
"@maxelms/create-plugin-cli": "<%= cliVersion %>",
|
|
18
|
+
"@squoosh/lib": "0.5.3",
|
|
19
|
+
"@types/react": "17.0.33",
|
|
20
|
+
"@types/react-dom": "17.0.10",
|
|
21
|
+
"archiver": "5.3.1",
|
|
22
|
+
"autoprefixer": "10.3.7",
|
|
23
|
+
"babel-loader": "8.2.3",
|
|
24
|
+
"clean-webpack-plugin": "4.0.0",
|
|
25
|
+
"copy-webpack-plugin": "10.2.0",
|
|
26
|
+
"css-loader": "6.5.0",
|
|
27
|
+
"css-minimizer-webpack-plugin": "4.2.1",
|
|
28
|
+
"html-webpack-plugin": "5.5.0",
|
|
29
|
+
"image-minimizer-webpack-plugin": "3.8.1",
|
|
30
|
+
"less": "4.1.2",
|
|
31
|
+
"less-loader": "10.2.0",
|
|
32
|
+
"mini-css-extract-plugin": "2.4.3",
|
|
33
|
+
"postcss": "8.3.11",
|
|
34
|
+
"postcss-loader": "6.2.0",
|
|
35
|
+
"prettier": "2.4.1",
|
|
36
|
+
"style-loader": "3.3.1",
|
|
37
|
+
"ts-loader": "9.2.6",
|
|
38
|
+
"typescript": "4.4.4",
|
|
39
|
+
"webpack": "5.60.0",
|
|
40
|
+
"webpack-cli": "4.10.0",
|
|
41
|
+
"webpack-dev-server": "4.4.0",
|
|
42
|
+
"workbox-webpack-plugin": "6.3.0"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@max-kit/max-api": "1.0.1",
|
|
46
|
+
"antd": "4.21.2",
|
|
47
|
+
"react": "16.14.0",
|
|
48
|
+
"react-dom": "16.14.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -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
|
+
}
|