@maxelms/create-plugin-cli 1.1.15 → 1.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/bin/build.js +2 -2
  2. package/bin/index.js +1 -1
  3. package/lib/index.js +1 -2
  4. package/package.json +1 -1
  5. package/templates/vue3-micro-app/package.json.tpl +1 -1
  6. package/templates/vue3-micro-app/vue.config.js.tpl +2 -1
  7. package/templates/vue3-micro-field/README.md +24 -0
  8. package/templates/vue3-micro-field/babel.config.js +8 -0
  9. package/templates/vue3-micro-field/manifest.json.tpl +3 -0
  10. package/templates/vue3-micro-field/package.json.tpl +57 -0
  11. package/templates/vue3-micro-field/public/configuration.json +30 -0
  12. package/templates/vue3-micro-field/public/index.html +10 -0
  13. package/templates/vue3-micro-field/scripts/compress.js +32 -0
  14. package/templates/vue3-micro-field/src/App.vue.tpl +42 -0
  15. package/templates/vue3-micro-field/src/main.js +41 -0
  16. package/templates/vue3-micro-field/src/style.less.tpl +16 -0
  17. package/templates/vue3-micro-field/vue.config.js +46 -0
  18. package/templates/vue3vite-micro-plugin/.editorconfig +6 -0
  19. package/templates/vue3vite-micro-plugin/.gitignore.tpl +23 -0
  20. package/templates/vue3vite-micro-plugin/.prettierrc.json +7 -0
  21. package/templates/vue3vite-micro-plugin/.vscode/extensions.json +9 -0
  22. package/templates/vue3vite-micro-plugin/README.md +48 -0
  23. package/templates/vue3vite-micro-plugin/env.d.ts +1 -0
  24. package/templates/vue3vite-micro-plugin/eslint.config.js +29 -0
  25. package/templates/vue3vite-micro-plugin/index.html +13 -0
  26. package/templates/vue3vite-micro-plugin/package.json.tpl +56 -0
  27. package/templates/vue3vite-micro-plugin/public/configuration.json +30 -0
  28. package/templates/vue3vite-micro-plugin/public/favicon.ico +0 -0
  29. package/templates/vue3vite-micro-plugin/scripts/devDistServe.cjs +16 -0
  30. package/templates/vue3vite-micro-plugin/src/App.vue.tpl +48 -0
  31. package/templates/vue3vite-micro-plugin/src/main.ts +39 -0
  32. package/templates/vue3vite-micro-plugin/src/typings.d.ts +8 -0
  33. package/templates/vue3vite-micro-plugin/tsconfig.app.json +14 -0
  34. package/templates/vue3vite-micro-plugin/tsconfig.json +14 -0
  35. package/templates/vue3vite-micro-plugin/tsconfig.node.json +19 -0
  36. package/templates/vue3vite-micro-plugin/tsconfig.vitest.json +11 -0
  37. package/templates/vue3vite-micro-plugin/vite.config.ts +24 -0
  38. package/templates/vue3vite-micro-plugin/vitest.config.ts +14 -0
package/bin/build.js CHANGED
@@ -5,7 +5,7 @@ const program = require('commander')
5
5
  program
6
6
  .version(`maxelms-plugin-cli ${require('../package').version}`)
7
7
  .usage('maxelms-plugin-cli -cp -c')
8
-
8
+
9
9
 
10
10
  program
11
11
  .option('-cp, --copy [copy]')
@@ -23,7 +23,7 @@ program
23
23
  }
24
24
 
25
25
  if (compress) require('./compress.js')
26
-
26
+
27
27
  });
28
28
 
29
29
  program.parse(process.argv);
package/bin/index.js CHANGED
@@ -20,7 +20,7 @@ program
20
20
  `请选择前端框架`,
21
21
  'react',
22
22
  'vue',
23
- // 'vue3',
23
+ 'vue3',
24
24
  'vue3vite',
25
25
  ].join('\n'))
26
26
  .option('-c, --PROJECT_CONFIG_TYPE <PROJECT_CONFIG_TYPE>', [
package/lib/index.js CHANGED
@@ -48,8 +48,7 @@ var uuid_1 = require("uuid");
48
48
  var utils_1 = require("./utils");
49
49
  var pkg = require('../package.json');
50
50
  var cliVersion = pkg.version;
51
- // const frameworks = ['react', 'vue', 'vue3', 'vue3vite'];
52
- var frameworks = ['react', 'vue', 'vue3vite'];
51
+ var frameworks = ['react', 'vue', 'vue3', 'vue3vite'];
53
52
  var jQuery = 'jQuery';
54
53
  var templates = ['umi'];
55
54
  /** 项目类型 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxelms/create-plugin-cli",
3
- "version": "1.1.15",
3
+ "version": "1.1.17",
4
4
  "main": "./bin/index.js",
5
5
  "author": "jackc_001",
6
6
  "bin": {
@@ -5,7 +5,7 @@
5
5
  "scripts": {
6
6
  "start": "vue-cli-service serve",
7
7
  "serve": "vue-cli-service serve && maxelms-plugin-cli -c",
8
- "build": "vue-cli-service build",
8
+ "build": "vue-cli-service build && maxelms-plugin-cli -c",
9
9
  "lint": "vue-cli-service lint"
10
10
  },
11
11
  "dependencies": {
@@ -9,7 +9,8 @@ const port = 7105;
9
9
 
10
10
  module.exports = {
11
11
  outputDir: 'dist',
12
- assetsDir: 'static',
12
+ // assetsDir: 'static',
13
+ publicPath: './',
13
14
  filenameHashing: true,
14
15
  devServer: {
15
16
  hot: true,
@@ -0,0 +1,24 @@
1
+ # vue-p2
2
+
3
+ ## Project setup
4
+ ```
5
+ pnpm install
6
+ ```
7
+
8
+ ### Compiles and hot-reloads for development
9
+ ```
10
+ pnpm run serve
11
+ ```
12
+
13
+ ### Compiles and minifies for production
14
+ ```
15
+ pnpm run build
16
+ ```
17
+
18
+ ### Lints and fixes files
19
+ ```
20
+ pnpm run lint
21
+ ```
22
+
23
+ ### Customize configuration
24
+ See [Configuration Reference](https://cli.vuejs.org/config/).
@@ -0,0 +1,8 @@
1
+ module.exports = {
2
+ presets: [
3
+ '@vue/cli-plugin-babel/preset'
4
+ ],
5
+ plugins: [
6
+ '@babel/plugin-proposal-optional-chaining'
7
+ ]
8
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "configurationType": "<%= configurationType %>"
3
+ }
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "<%= pluginName %>",
3
+ "version": "0.1.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "serve": "vue-cli-service serve",
7
+ "start": "vue-cli-service serve",
8
+ "build": "vue-cli-service build && maxelms-plugin-cli -c",
9
+ "lint": "vue-cli-service lint"
10
+ },
11
+ "dependencies": {
12
+ "@maxelms/create-pulgin-api": "1.0.0",
13
+ "core-js": "3.6.5",
14
+ "element-ui": "2.15.6",
15
+ "vue": "3.0.0",
16
+ "vue-router": "4.0.0-beta.11",
17
+ "vuex": "4.0.0-beta.4"
18
+ },
19
+ "devDependencies": {
20
+ "@babel/plugin-proposal-optional-chaining": "7.21.0",
21
+ "@maxelms/create-plugin-cli": "^1.0.0",
22
+ "@vue/cli-plugin-babel": "4.5.0",
23
+ "@vue/cli-plugin-eslint": "4.5.0",
24
+ "@vue/cli-service": "4.5.0",
25
+ "archiver": "5.3.1",
26
+ "@vue/compiler-sfc": "3.0.0",
27
+ "babel-eslint": "10.1.0",
28
+ "copy-webpack-plugin": "5.1.1",
29
+ "eslint": "6.7.2",
30
+ "eslint-plugin-vue": "6.2.2",
31
+ "less": "^4.1.3",
32
+ "less-loader": "5.0.0",
33
+ "sass": "1.47.0",
34
+ "sass-loader": "8.0.2",
35
+ "url-loader": "2.2.0",
36
+ "vue-template-compiler": "2.6.11"
37
+ },
38
+ "eslintConfig": {
39
+ "root": true,
40
+ "env": {
41
+ "node": true
42
+ },
43
+ "extends": [
44
+ "plugin:vue/essential",
45
+ "eslint:recommended"
46
+ ],
47
+ "parserOptions": {
48
+ "parser": "babel-eslint"
49
+ },
50
+ "rules": {}
51
+ },
52
+ "browserslist": [
53
+ "> 1%",
54
+ "last 2 versions",
55
+ "not dead"
56
+ ]
57
+ }
@@ -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 页面组件</title>
6
+ </head>
7
+ <body>
8
+ <div id="root"></div>
9
+ </body>
10
+ </html>
@@ -0,0 +1,32 @@
1
+ const fs = require('fs');
2
+ const archiver = require('archiver');
3
+
4
+ const distDir = 'dist'
5
+ if (fs.existsSync(distDir)) {
6
+ if (fs.existsSync('dist.maxplugin')) {
7
+ fs.unlinkSync('dist.maxplugin')
8
+ }
9
+
10
+ const output = fs.createWriteStream('dist.maxplugin');
11
+ const archive = archiver('zip', {
12
+ zlib: { level: 9 }
13
+ });
14
+
15
+ output.on('close', function() {
16
+ console.log('Compress completed!');
17
+ });
18
+
19
+ archive.on('error', function(err) {
20
+ console.log('Compress failed!');
21
+ throw err;
22
+ });
23
+
24
+ archive.pipe(output);
25
+
26
+
27
+ archive.directory('dist/', 'dist');
28
+
29
+ archive.finalize();
30
+ } else {
31
+ console.log('No dist directory found!');
32
+ }
@@ -0,0 +1,42 @@
1
+ <template>
2
+ <div>
3
+ <div class="maxelms-customize-component-<%= timestamp %>">
4
+ <input
5
+ :style="{width: `${width}px`}"
6
+ :disabled="disabled"
7
+ :placeholder="placeholder"
8
+ value="欢迎使用 Maxelms 页面组件"
9
+ />
10
+ </div>
11
+ </div>
12
+ </template>
13
+
14
+ <script>
15
+
16
+ export default {
17
+ name: 'App',
18
+ components: {
19
+ },
20
+ methods: {
21
+
22
+ },
23
+ computed: {
24
+ /** 是否禁用 */
25
+ disabled () {
26
+ return this.$root?.masterProps?.configurations?.propName3
27
+ },
28
+ /** 控件宽度 */
29
+ width () {
30
+ return this.$root?.masterProps?.configurations?.propName2 || 350
31
+ },
32
+ /** 提示文本 */
33
+ placeholder () {
34
+ return this.$root?.masterProps?.configurations?.propName1
35
+ },
36
+ },
37
+ }
38
+ </script>
39
+
40
+ <style lang="less">
41
+ @import "./style.less";
42
+ </style>
@@ -0,0 +1,41 @@
1
+ import { createApp } from 'vue';
2
+ import { registerPlugin, poweredByMaxelms } from '@maxelms/create-pulgin-api'
3
+ import App from './App.vue'
4
+
5
+ // Vue.config.productionTip = false
6
+
7
+ window.__SINGLETON_MODE__ = true
8
+
9
+ // configureCompat({
10
+ // MODE: true, // 开启 Vue 2 兼容模式
11
+ // });
12
+
13
+ const vms = {}
14
+
15
+ const render = (props) => {
16
+ const { containerId } = props || {}
17
+ createApp(App, {
18
+ data: {
19
+ masterProps: props || {}
20
+ },
21
+ }).mount(containerId ? `#${containerId} #root` : '#root');
22
+ }
23
+
24
+ if (poweredByMaxelms) {
25
+ registerPlugin({
26
+ mount(props) {
27
+ render(props)
28
+ },
29
+ update(props) {
30
+ if (vms[props.containerId]) {
31
+ vms[props.containerId].masterProps = props
32
+ }
33
+ },
34
+ unmount(props) {
35
+ vms[props.containerId]?.$destroy?.()
36
+ vms[props.containerId] = null
37
+ }
38
+ });
39
+ } else {
40
+ render()
41
+ }
@@ -0,0 +1,16 @@
1
+
2
+ @prefixCls: maxelms-customize-component-<%= timestamp %>;
3
+
4
+ .@{prefixCls} {
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ flex-direction: column;
9
+ input {
10
+ width: 300px;
11
+ text-align: center;
12
+ }
13
+ img {
14
+ width: 350px;
15
+ }
16
+ }
@@ -0,0 +1,46 @@
1
+ const path = require('path');
2
+ const CopyWebpackPlugin = require('copy-webpack-plugin');
3
+
4
+ module.exports = {
5
+ pages: {
6
+ index: {
7
+ entry: "src/main.js",
8
+ template: "public/index.html",
9
+ filename: "index.html",
10
+ title: "Maxelms Plugin",
11
+ },
12
+
13
+ },
14
+ publicPath: './',
15
+ css: {
16
+ extract: true,
17
+ },
18
+ productionSourceMap: false,
19
+ devServer: {
20
+ headers: {
21
+ "Access-Control-Allow-Origin": "*",
22
+ },
23
+ port: 8080,
24
+ open: ['/', '/playground.html'],
25
+ contentBase: path.join(__dirname, 'examples/'),
26
+ },
27
+ chainWebpack: (config) => {
28
+ config.module
29
+ .rule('fonts')
30
+ .test(/.(ttf|otf|eot|woff|woff2)$/)
31
+ .use('url-loader')
32
+ .loader('url-loader')
33
+ .tap(() => ({
34
+ name: '/fonts/[name].[hash:8].[ext]'
35
+ }))
36
+ .end()
37
+ },
38
+ configureWebpack: {
39
+ plugins: [
40
+ new CopyWebpackPlugin([
41
+ { from: 'README.md' },
42
+ { from: 'manifest.json' },
43
+ ]),
44
+ ]
45
+ },
46
+ };
@@ -0,0 +1,6 @@
1
+ [*.{js,jsx,mjs,cjs,ts,tsx,mts,cts,vue}]
2
+ charset = utf-8
3
+ indent_size = 2
4
+ indent_style = space
5
+ insert_final_newline = true
6
+ trim_trailing_whitespace = true
@@ -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,7 @@
1
+
2
+ {
3
+ "$schema": "https://json.schemastore.org/prettierrc",
4
+ "semi": false,
5
+ "singleQuote": true,
6
+ "printWidth": 100
7
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "recommendations": [
3
+ "Vue.volar",
4
+ "vitest.explorer",
5
+ "dbaeumer.vscode-eslint",
6
+ "EditorConfig.EditorConfig",
7
+ "esbenp.prettier-vscode"
8
+ ]
9
+ }
@@ -0,0 +1,48 @@
1
+ ### 本地使用代理到主应用环境
2
+ npm run proxy(可以控制 DIST_PROT 修改静态资源端口号)
3
+
4
+ # vue-project
5
+
6
+ This template should help get you started developing with Vue 3 in Vite.
7
+
8
+ ## Recommended IDE Setup
9
+
10
+ [VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
11
+
12
+ ## Type Support for `.vue` Imports in TS
13
+
14
+ TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
15
+
16
+ ## Customize configuration
17
+
18
+ See [Vite Configuration Reference](https://vite.dev/config/).
19
+
20
+ ## Project Setup
21
+
22
+ ```sh
23
+ pnpm install
24
+ ```
25
+
26
+ ### Compile and Hot-Reload for Development
27
+
28
+ ```sh
29
+ pnpm dev
30
+ ```
31
+
32
+ ### Type-Check, Compile and Minify for Production
33
+
34
+ ```sh
35
+ pnpm build
36
+ ```
37
+
38
+ ### Run Unit Tests with [Vitest](https://vitest.dev/)
39
+
40
+ ```sh
41
+ pnpm test:unit
42
+ ```
43
+
44
+ ### Lint with [ESLint](https://eslint.org/)
45
+
46
+ ```sh
47
+ pnpm lint
48
+ ```
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,29 @@
1
+ import pluginVue from 'eslint-plugin-vue'
2
+ import vueTsEslintConfig from '@vue/eslint-config-typescript'
3
+ import pluginVitest from '@vitest/eslint-plugin'
4
+ import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
5
+
6
+ export default [
7
+ {
8
+ name: 'app/files-to-lint',
9
+ files: ['**/*.{ts,mts,tsx,vue}'],
10
+ },
11
+
12
+ {
13
+ name: 'app/files-to-ignore',
14
+ ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
15
+ },
16
+
17
+ ...pluginVue.configs['flat/essential'],
18
+ ...vueTsEslintConfig(),
19
+ {
20
+ ...pluginVitest.configs.recommended,
21
+ files: ['src/**/__tests__/*'],
22
+ },
23
+ skipFormatting,
24
+ {
25
+ rules: {
26
+ '@typescript-eslint/no-explicit-any': 'off',
27
+ }
28
+ },
29
+ ]
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" href="/favicon.ico" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Maxelms MicroApp</title>
8
+ </head>
9
+ <body>
10
+ <div id="micro-app" style="height: 100%"></div>
11
+ <script type="module" src="/src/main.ts"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "<%= pluginName %>",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "start": "vite",
8
+ "proxy": "npm run build && cross-env DIST_PROT=9966 node scripts/devDistServe.cjs",
9
+ "build": "run-p type-check \"build-only {@}\" -- && maxelms-plugin-cli -c",
10
+ "preview": "vite preview",
11
+ "test:unit": "vitest",
12
+ "build-only": "vite build",
13
+ "type-check": "vue-tsc --build",
14
+ "lint": "eslint . --fix",
15
+ "format": "prettier --write src/"
16
+ },
17
+ "dependencies": {
18
+ "@esbuild/darwin-arm64": "0.24.0",
19
+ "@maxelms/create-pulgin-api": "1.0.0",
20
+ "@rollup/rollup-darwin-arm64": "4.28.1",
21
+ "pinia": "2.2.6",
22
+ "vue": "3.5.13",
23
+ "vue-router": "4.4.5"
24
+ },
25
+ "devDependencies": {
26
+ "@maxelms/create-plugin-cli": "<%= cliVersion %>",
27
+ "@tsconfig/node22": "22.0.0",
28
+ "@types/jsdom": "21.1.7",
29
+ "@types/node": "22.9.3",
30
+ "@vitejs/plugin-vue": "5.2.1",
31
+ "@vitejs/plugin-vue-jsx": "4.1.1",
32
+ "@vitest/eslint-plugin": "1.1.10",
33
+ "@vue/eslint-config-prettier": "10.1.0",
34
+ "@vue/eslint-config-typescript": "14.1.3",
35
+ "@vue/test-utils": "2.4.6",
36
+ "@vue/tsconfig": "0.7.0",
37
+ "cors": "2.8.5",
38
+ "cross-env": "7.0.3",
39
+ "eslint": "9.14.0",
40
+ "eslint-plugin-vue": "9.30.0",
41
+ "express": "4.21.2",
42
+ "jsdom": "25.0.1",
43
+ "npm-run-all2": "7.0.1",
44
+ "prettier": "3.3.3",
45
+ "typescript": "5.6.3",
46
+ "vite": "6.0.1",
47
+ "vite-plugin-vue-devtools": "7.6.5",
48
+ "vitest": "2.1.5",
49
+ "vue-tsc": "2.1.10"
50
+ },
51
+ "resolutions": {
52
+ "magic-string": "0.30.15",
53
+ "@esbuild/darwin-arm64": "0.24.0",
54
+ "esbuild": "0.24.0"
55
+ }
56
+ }
@@ -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,16 @@
1
+ const express = require('express');
2
+ const cors = require('cors');
3
+ const path = require('path');
4
+ const { DIST_PROT = '3000' } = process.env
5
+
6
+ const app = express();
7
+
8
+ // 启用 CORS 中间件
9
+ app.use(cors());
10
+
11
+ // 设置静态文件目录
12
+ app.use(express.static(path.join(__dirname, '../dist')));
13
+
14
+ app.listen(DIST_PROT, () => {
15
+ console.log(`Server running at http://localhost:${DIST_PROT}/`);
16
+ });
@@ -0,0 +1,48 @@
1
+ <template>
2
+ <div>
3
+ <div class="maxelms-customize-component-<%= timestamp %>">
4
+ <input
5
+ :style="{width: `${width}px`}"
6
+ :disabled="disabled"
7
+ :placeholder="placeholder"
8
+ value="欢迎使用 Maxelms 页面组件"
9
+ />
10
+ </div>
11
+ </div>
12
+ </template>
13
+
14
+ <script>
15
+
16
+ export default {
17
+ name: 'App',
18
+ components: {
19
+ },
20
+ methods: {
21
+
22
+ },
23
+ computed: {
24
+ /** 是否禁用 */
25
+ disabled () {
26
+ return this.$root?.masterProps?.configurations?.propName3
27
+ },
28
+ /** 控件宽度 */
29
+ width () {
30
+ return this.$root?.masterProps?.configurations?.propName2 || 350
31
+ },
32
+ /** 提示文本 */
33
+ placeholder () {
34
+ return this.$root?.masterProps?.configurations?.propName1
35
+ },
36
+ },
37
+ }
38
+ </script>
39
+
40
+ <style scoped>
41
+ .maxelms-customize-component-<%= timestamp %> input {
42
+ width: 300px;
43
+ text-align: center;
44
+ }
45
+ .maxelms-customize-component-<%= timestamp %> img {
46
+ width: 350px;
47
+ }
48
+ </style>
@@ -0,0 +1,39 @@
1
+ import { createApp } from 'vue'
2
+ import { createPinia } from 'pinia'
3
+ import { registerPlugin, poweredByMaxelms } from '@maxelms/create-pulgin-api'
4
+ import App from './App.vue'
5
+ // const subId = window.__MAXELMS_GLOBAL_ENV__?.popoverContainerId?.replace(/^maxelms-ma-popover-container-/, '') || ''
6
+
7
+ // Vue.config.productionTip = false
8
+ window.__SINGLETON_MODE__ = true
9
+
10
+ const vms: any = {}
11
+
12
+ if (poweredByMaxelms && registerPlugin) {
13
+ registerPlugin({
14
+ mount(props) {
15
+ render(props)
16
+ },
17
+ update(props) {
18
+ if (vms[props.containerId]) {
19
+ vms[props.containerId].masterProps = props
20
+ }
21
+ },
22
+ unmount(props) {
23
+ vms[props.containerId]?.$destroy?.()
24
+ vms[props.containerId] = null
25
+ }
26
+ });
27
+ } else {
28
+ render()
29
+ }
30
+
31
+ function render(props: any = {}) {
32
+ const { containerId } = props
33
+ console.log(containerId)
34
+ vms[containerId] = createApp(App, {
35
+ configurations: props || {},
36
+ })
37
+ vms[containerId].use(createPinia())
38
+ vms[containerId].mount(containerId ? `#${containerId} #micro-app` : '#micro-app')
39
+ }
@@ -0,0 +1,8 @@
1
+ declare module "*.vue"
2
+
3
+ interface Window {
4
+ __SINGLETON_MODE__?: any
5
+ __MAXELMS_GLOBAL_ENV__?: {
6
+ popoverContainerId: string
7
+ };
8
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "@vue/tsconfig/tsconfig.dom.json",
3
+ "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
4
+ "exclude": ["src/**/__tests__/*"],
5
+ "compilerOptions": {
6
+ "noImplicitAny": true,
7
+ "composite": true,
8
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
9
+
10
+ "paths": {
11
+ "@/*": ["./src/*"]
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "files": [],
3
+ "references": [
4
+ {
5
+ "path": "./tsconfig.node.json"
6
+ },
7
+ {
8
+ "path": "./tsconfig.app.json"
9
+ },
10
+ {
11
+ "path": "./tsconfig.vitest.json"
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "@tsconfig/node22/tsconfig.json",
3
+ "include": [
4
+ "vite.config.*",
5
+ "vitest.config.*",
6
+ "cypress.config.*",
7
+ "nightwatch.conf.*",
8
+ "playwright.config.*"
9
+ ],
10
+ "compilerOptions": {
11
+ "composite": true,
12
+ "noEmit": true,
13
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
14
+
15
+ "module": "ESNext",
16
+ "moduleResolution": "Bundler",
17
+ "types": ["node"]
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./tsconfig.app.json",
3
+ "exclude": [],
4
+ "compilerOptions": {
5
+ "composite": true,
6
+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
7
+
8
+ "lib": [],
9
+ "types": ["node", "jsdom"]
10
+ }
11
+ }
@@ -0,0 +1,24 @@
1
+ import { fileURLToPath, URL } from 'node:url'
2
+ import { defineConfig } from 'vite'
3
+ import vue from '@vitejs/plugin-vue'
4
+ import vueJsx from '@vitejs/plugin-vue-jsx'
5
+ import vueDevTools from 'vite-plugin-vue-devtools'
6
+
7
+ // https://vite.dev/config/
8
+ export default defineConfig({
9
+ plugins: [vue(), vueJsx(), vueDevTools()],
10
+ base: './',
11
+ resolve: {
12
+ alias: {
13
+ '@': fileURLToPath(new URL('./src', import.meta.url)),
14
+ },
15
+ },
16
+ build: {
17
+ target: 'es2015',
18
+ rollupOptions: {
19
+ output: {
20
+ format: 'umd',
21
+ },
22
+ },
23
+ },
24
+ })
@@ -0,0 +1,14 @@
1
+ import { fileURLToPath, URL } from 'node:url'
2
+ import { mergeConfig, defineConfig, configDefaults } from 'vitest/config'
3
+ import viteConfig from './vite.config'
4
+
5
+ export default mergeConfig(
6
+ viteConfig,
7
+ defineConfig({
8
+ test: {
9
+ environment: 'jsdom',
10
+ exclude: [...configDefaults.exclude, 'e2e/**'],
11
+ root: fileURLToPath(new URL('./', import.meta.url)),
12
+ },
13
+ }),
14
+ )