@maxelms/create-plugin-cli 1.1.8 → 1.1.10
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/bin/index.js +1 -0
- package/lib/index.js +5 -1
- package/package.json +1 -1
- package/templates/vue3-micro-app/.gitignore.tpl +23 -0
- package/templates/vue3-micro-app/README.md +15 -31
- package/templates/vue3-micro-app/babel.config.js +3 -0
- package/templates/vue3-micro-app/package.json.tpl +41 -36
- package/templates/vue3-micro-app/public/index.html +20 -0
- package/templates/vue3-micro-app/src/App.vue +52 -70
- package/templates/vue3-micro-app/src/assets/logo.png +0 -0
- package/templates/vue3-micro-app/src/components/HelloWorld.vue +63 -31
- package/templates/vue3-micro-app/src/main.js +64 -0
- package/templates/vue3-micro-app/src/public-path.js +4 -0
- package/templates/vue3-micro-app/src/router/index.js +6 -0
- package/templates/vue3-micro-app/src/store/count.js +34 -0
- package/templates/vue3-micro-app/src/store/index.js +12 -0
- package/templates/vue3-micro-app/src/views/About.vue +19 -0
- package/templates/vue3-micro-app/src/views/Home.vue +37 -0
- package/templates/vue3-micro-app/vue.config.js.tpl +43 -0
- package/templates/vue3-micro-plugin/README.md +24 -0
- package/templates/vue3-micro-plugin/babel.config.js +8 -0
- package/templates/vue3-micro-plugin/manifest.json.tpl +3 -0
- package/templates/vue3-micro-plugin/package.json.tpl +57 -0
- package/templates/vue3-micro-plugin/public/configuration.json +30 -0
- package/templates/vue3-micro-plugin/public/index.html +10 -0
- package/templates/vue3-micro-plugin/scripts/compress.js +32 -0
- package/templates/vue3-micro-plugin/src/App.vue.tpl +42 -0
- package/templates/vue3-micro-plugin/src/main.js +41 -0
- package/templates/vue3-micro-plugin/src/style.less.tpl +16 -0
- package/templates/vue3-micro-plugin/vue.config.js +46 -0
- package/templates/vue3vite-micro-app/.gitignore.tpl +23 -0
- package/templates/vue3vite-micro-app/README.md +48 -0
- package/templates/{vue3-micro-app → vue3vite-micro-app}/eslint.config.js +5 -1
- package/templates/vue3vite-micro-app/package.json.tpl +53 -0
- package/templates/vue3vite-micro-app/public/configuration.json +30 -0
- package/templates/vue3vite-micro-app/public/favicon.ico +0 -0
- package/templates/vue3vite-micro-app/scripts/devDistServe.cjs +16 -0
- package/templates/vue3vite-micro-app/src/App.vue +91 -0
- package/templates/vue3vite-micro-app/src/components/HelloWorld.vue +42 -0
- package/templates/vue3vite-micro-app/src/main.ts +40 -0
- package/templates/vue3vite-micro-app/src/typings.d.ts +5 -0
- package/templates/{vue3-micro-app → vue3vite-micro-app}/tsconfig.app.json +1 -0
- package/templates/vue3-micro-app/src/main.ts +0 -14
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/.editorconfig +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/.prettierrc.json +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/.vscode/extensions.json +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/env.d.ts +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/index.html +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/assets/base.css +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/assets/logo.svg +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/assets/main.css +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/TheWelcome.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/WelcomeItem.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/__tests__/HelloWorld.spec.ts +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconCommunity.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconDocumentation.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconEcosystem.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconSupport.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconTooling.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/router/index.ts +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/stores/counter.ts +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/views/AboutView.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/views/HomeView.vue +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/tsconfig.json +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/tsconfig.node.json +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/tsconfig.vitest.json +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/vite.config.ts +0 -0
- /package/templates/{vue3-micro-app → vue3vite-micro-app}/vitest.config.ts +0 -0
package/bin/index.js
CHANGED
package/lib/index.js
CHANGED
|
@@ -48,7 +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
|
-
var frameworks = ['react', 'vue', 'vue3'];
|
|
51
|
+
var frameworks = ['react', 'vue', 'vue3', 'vue3vite'];
|
|
52
52
|
var jQuery = 'jQuery';
|
|
53
53
|
var templates = ['umi'];
|
|
54
54
|
/** 项目类型 */
|
|
@@ -190,6 +190,10 @@ var create = function (pluginName, options) { return __awaiter(void 0, void 0, v
|
|
|
190
190
|
templateName += "-".concat(TEMPLATE);
|
|
191
191
|
}
|
|
192
192
|
templateDir = path_1.default.resolve(__dirname, "../templates/".concat(templateName));
|
|
193
|
+
if (!fs_1.default.existsSync(templateDir)) {
|
|
194
|
+
console.log(chalk_1.default.magentaBright("\n \u6682\u65E0 ".concat(templateName, " \u6A21\u677F\uFF01\n\n ")));
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
}
|
|
193
197
|
ignore = [];
|
|
194
198
|
if (configurationType === ConfigTypeEnum.JSON) {
|
|
195
199
|
ignore.push.apply(ignore, ['**/configuration/**', '**/configuration.html']);
|
package/package.json
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.DS_Store
|
|
2
|
+
node_modules
|
|
3
|
+
/dist
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# local env files
|
|
7
|
+
.env.local
|
|
8
|
+
.env.*.local
|
|
9
|
+
|
|
10
|
+
# Log files
|
|
11
|
+
npm-debug.log*
|
|
12
|
+
yarn-debug.log*
|
|
13
|
+
yarn-error.log*
|
|
14
|
+
pnpm-debug.log*
|
|
15
|
+
|
|
16
|
+
# Editor directories and files
|
|
17
|
+
.idea
|
|
18
|
+
.vscode
|
|
19
|
+
*.suo
|
|
20
|
+
*.ntvs*
|
|
21
|
+
*.njsproj
|
|
22
|
+
*.sln
|
|
23
|
+
*.sw?
|
|
@@ -1,45 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# hello-vue3
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Project setup
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
|
8
|
-
|
|
9
|
-
## Type Support for `.vue` Imports in TS
|
|
10
|
-
|
|
11
|
-
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.
|
|
12
|
-
|
|
13
|
-
## Customize configuration
|
|
14
|
-
|
|
15
|
-
See [Vite Configuration Reference](https://vite.dev/config/).
|
|
16
|
-
|
|
17
|
-
## Project Setup
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
pnpm install
|
|
5
|
+
```
|
|
6
|
+
npm install
|
|
21
7
|
```
|
|
22
8
|
|
|
23
|
-
###
|
|
9
|
+
### Compiles and hot-reloads for development
|
|
24
10
|
|
|
25
|
-
```
|
|
26
|
-
|
|
11
|
+
```
|
|
12
|
+
npm run serve
|
|
27
13
|
```
|
|
28
14
|
|
|
29
|
-
###
|
|
15
|
+
### Compiles and minifies for production
|
|
30
16
|
|
|
31
|
-
```
|
|
32
|
-
|
|
17
|
+
```
|
|
18
|
+
npm run build
|
|
33
19
|
```
|
|
34
20
|
|
|
35
|
-
###
|
|
21
|
+
### Lints and fixes files
|
|
36
22
|
|
|
37
|
-
```
|
|
38
|
-
|
|
23
|
+
```
|
|
24
|
+
npm run lint
|
|
39
25
|
```
|
|
40
26
|
|
|
41
|
-
###
|
|
27
|
+
### Customize configuration
|
|
42
28
|
|
|
43
|
-
|
|
44
|
-
pnpm lint
|
|
45
|
-
```
|
|
29
|
+
See [Configuration Reference](https://cli.vuejs.org/config/).
|
|
@@ -1,46 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "<%= pluginName %>",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
5
|
"scripts": {
|
|
7
|
-
"start": "
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"build-only": "vite build",
|
|
12
|
-
"type-check": "vue-tsc --build",
|
|
13
|
-
"lint": "eslint . --fix",
|
|
14
|
-
"format": "prettier --write src/"
|
|
6
|
+
"start": "vue-cli-service serve",
|
|
7
|
+
"serve": "vue-cli-service serve && maxelms-plugin-cli -c",
|
|
8
|
+
"build": "vue-cli-service build",
|
|
9
|
+
"lint": "vue-cli-service lint"
|
|
15
10
|
},
|
|
16
11
|
"dependencies": {
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"vue-router": "4.4.5"
|
|
12
|
+
"core-js": "3.6.5",
|
|
13
|
+
"vue": "3.0.0",
|
|
14
|
+
"vue-router": "4.0.0-beta.11",
|
|
15
|
+
"vuex": "4.0.0-beta.4"
|
|
22
16
|
},
|
|
23
17
|
"devDependencies": {
|
|
24
18
|
"@maxelms/create-plugin-cli": "<%= cliVersion %>",
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@
|
|
28
|
-
"@
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
19
|
+
"@vue/cli-plugin-babel": "4.5.0",
|
|
20
|
+
"@vue/cli-plugin-eslint": "4.5.0",
|
|
21
|
+
"@vue/cli-service": "4.5.0",
|
|
22
|
+
"@vue/compiler-sfc": "3.0.0",
|
|
23
|
+
"babel-eslint": "10.1.0",
|
|
24
|
+
"eslint": "6.7.2",
|
|
25
|
+
"eslint-plugin-vue": "7.0.0",
|
|
26
|
+
"less": "3.0.4",
|
|
27
|
+
"less-loader": "5.0.0"
|
|
28
|
+
},
|
|
29
|
+
"resolutions": {
|
|
30
|
+
"magic-string": "0.30.15"
|
|
31
|
+
},
|
|
32
|
+
"eslintConfig": {
|
|
33
|
+
"root": true,
|
|
34
|
+
"env": {
|
|
35
|
+
"node": true
|
|
36
|
+
},
|
|
37
|
+
"extends": [
|
|
38
|
+
"plugin:vue/vue3-essential",
|
|
39
|
+
"eslint:recommended"
|
|
40
|
+
],
|
|
41
|
+
"parserOptions": {
|
|
42
|
+
"parser": "babel-eslint"
|
|
43
|
+
},
|
|
44
|
+
"rules": {}
|
|
45
|
+
},
|
|
46
|
+
"browserslist": [
|
|
47
|
+
"> 1%",
|
|
48
|
+
"last 2 versions",
|
|
49
|
+
"not dead"
|
|
50
|
+
]
|
|
46
51
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
|
7
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico" />
|
|
8
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<noscript>
|
|
12
|
+
<strong
|
|
13
|
+
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please
|
|
14
|
+
enable it to continue.</strong
|
|
15
|
+
>
|
|
16
|
+
</noscript>
|
|
17
|
+
<div id="app"></div>
|
|
18
|
+
<!-- built files will be auto injected -->
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
|
@@ -1,88 +1,70 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<!-- <script setup lang="ts">
|
|
2
|
+
defineProps<{
|
|
3
|
+
configurations: any
|
|
4
|
+
}>()
|
|
5
|
+
</script> -->
|
|
5
6
|
|
|
6
7
|
<template>
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
<nav>
|
|
14
|
-
<a>Home</a>
|
|
15
|
-
<br />
|
|
16
|
-
<a>about</a>
|
|
17
|
-
<!-- <RouterLink to="/">Home</RouterLink> -->
|
|
18
|
-
<!-- <RouterLink to="/about">About</RouterLink> -->
|
|
19
|
-
</nav>
|
|
8
|
+
<div id="app">
|
|
9
|
+
<div id="nav">
|
|
10
|
+
{{ configurations?.propName1 }}
|
|
11
|
+
<router-link to="/">Home</router-link> |
|
|
12
|
+
<router-link to="/about">About</router-link>
|
|
20
13
|
</div>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<RouterView />
|
|
14
|
+
<router-view/>
|
|
15
|
+
</div>
|
|
24
16
|
</template>
|
|
25
17
|
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
line-height: 1.5;
|
|
29
|
-
max-height: 100vh;
|
|
30
|
-
}
|
|
18
|
+
<script>
|
|
19
|
+
import { onMounted, onBeforeUpdate } from 'vue';
|
|
31
20
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
21
|
+
export default {
|
|
22
|
+
name: 'HelloWorld',
|
|
23
|
+
props: {
|
|
24
|
+
configurations: {},
|
|
25
|
+
},
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
27
|
+
data() {
|
|
28
|
+
return {
|
|
29
|
+
nameColor: 'orange',
|
|
30
|
+
};
|
|
31
|
+
},
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
33
|
+
setup() {
|
|
34
|
+
// const { ctx } = getCurrentInstance();
|
|
47
35
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
36
|
+
onMounted(() => {
|
|
37
|
+
console.log('mounted');
|
|
38
|
+
});
|
|
51
39
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
border-left: 1px solid var(--color-border);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
nav a:first-of-type {
|
|
59
|
-
border: 0;
|
|
60
|
-
}
|
|
40
|
+
onBeforeUpdate(() => {
|
|
41
|
+
console.log('beforeUpdate');
|
|
42
|
+
});
|
|
61
43
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
padding-right: calc(var(--section-gap) / 2);
|
|
67
|
-
}
|
|
44
|
+
return { };
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
68
48
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
49
|
+
<style lang="less">
|
|
50
|
+
#app {
|
|
51
|
+
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
52
|
+
-webkit-font-smoothing: antialiased;
|
|
53
|
+
-moz-osx-font-smoothing: grayscale;
|
|
54
|
+
text-align: center;
|
|
55
|
+
color: #2c3e50;
|
|
56
|
+
}
|
|
72
57
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
place-items: flex-start;
|
|
76
|
-
flex-wrap: wrap;
|
|
77
|
-
}
|
|
58
|
+
#nav {
|
|
59
|
+
padding: 30px;
|
|
78
60
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
font-size: 1rem;
|
|
61
|
+
a {
|
|
62
|
+
font-weight: bold;
|
|
63
|
+
color: #2c3e50;
|
|
83
64
|
|
|
84
|
-
|
|
85
|
-
|
|
65
|
+
&.router-link-exact-active {
|
|
66
|
+
color: #42b983;
|
|
67
|
+
}
|
|
86
68
|
}
|
|
87
69
|
}
|
|
88
70
|
</style>
|
|
Binary file
|
|
@@ -1,42 +1,74 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
defineProps<{
|
|
3
|
-
msg: string
|
|
4
|
-
}>()
|
|
5
|
-
console.log('1234214321', '12341232323412')
|
|
6
|
-
</script>
|
|
7
|
-
|
|
8
1
|
<template>
|
|
9
|
-
<div class="
|
|
10
|
-
<h1
|
|
11
|
-
<
|
|
12
|
-
You’ve successfully created a project with
|
|
13
|
-
<a href="https://vite.dev/" target="_blank" rel="noopener">Vite</a> +
|
|
14
|
-
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>. What's next?
|
|
15
|
-
</h3>
|
|
2
|
+
<div class="hello-content">
|
|
3
|
+
<h1>{{ msg }}</h1>
|
|
4
|
+
<p>Vue version: {{ version }}</p>
|
|
16
5
|
</div>
|
|
17
6
|
</template>
|
|
18
7
|
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
<script>
|
|
9
|
+
import { onMounted, onBeforeUpdate, getCurrentInstance, version } from 'vue';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
name: 'HelloWorld',
|
|
13
|
+
props: {
|
|
14
|
+
msg: String,
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
data() {
|
|
18
|
+
return {
|
|
19
|
+
nameColor: 'orange',
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
setup() {
|
|
24
|
+
const { ctx } = getCurrentInstance();
|
|
25
|
+
|
|
26
|
+
const changeGlobalState = () => {
|
|
27
|
+
if (ctx.$setGlobalState) {
|
|
28
|
+
console.log('此处可设置全局state');
|
|
29
|
+
// ctx.$setGlobalState({name: 'chaunjie'})
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
onMounted(() => {
|
|
34
|
+
console.log('mounted');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
onBeforeUpdate(() => {
|
|
38
|
+
console.log('beforeUpdate');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
changeGlobalState,
|
|
43
|
+
version,
|
|
44
|
+
};
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<style>
|
|
50
|
+
.name {
|
|
51
|
+
color: v-bind(nameColor);
|
|
25
52
|
}
|
|
53
|
+
</style>
|
|
26
54
|
|
|
55
|
+
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
56
|
+
<style scoped>
|
|
27
57
|
h3 {
|
|
28
|
-
|
|
58
|
+
margin: 40px 0 0;
|
|
29
59
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
text-align: center;
|
|
60
|
+
ul {
|
|
61
|
+
list-style-type: none;
|
|
62
|
+
padding: 0;
|
|
34
63
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
64
|
+
li {
|
|
65
|
+
display: inline-block;
|
|
66
|
+
margin: 0 10px;
|
|
67
|
+
}
|
|
68
|
+
a {
|
|
69
|
+
color: #42b983;
|
|
70
|
+
}
|
|
71
|
+
h1 {
|
|
72
|
+
color: #64b587;
|
|
41
73
|
}
|
|
42
74
|
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import './public-path';
|
|
2
|
+
import { createApp } from 'vue';
|
|
3
|
+
import { createRouter, createWebHistory } from 'vue-router';
|
|
4
|
+
import App from './App.vue';
|
|
5
|
+
import routes from './router';
|
|
6
|
+
import store from './store';
|
|
7
|
+
|
|
8
|
+
let router = null;
|
|
9
|
+
let instance = null;
|
|
10
|
+
let history = null;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
function render(props = {}) {
|
|
14
|
+
console.log(props)
|
|
15
|
+
const { container, configurations } = props;
|
|
16
|
+
history = createWebHistory(window.__POWERED_BY_QIANKUN__ ? '/' : '/');
|
|
17
|
+
router = createRouter({
|
|
18
|
+
history,
|
|
19
|
+
routes,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
instance = createApp(App, { configurations });
|
|
23
|
+
instance.use(router);
|
|
24
|
+
instance.use(store);
|
|
25
|
+
instance.mount(container ? container.querySelector('#app') : '#app');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!window.__POWERED_BY_QIANKUN__) {
|
|
29
|
+
render();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export async function bootstrap() {
|
|
33
|
+
console.log('%c%s', 'color: green;', 'vue3.0 app bootstraped');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function storeTest(props) {
|
|
37
|
+
props.onGlobalStateChange &&
|
|
38
|
+
props.onGlobalStateChange(
|
|
39
|
+
(value, prev) => console.log(`[onGlobalStateChange - ${props.name}]:`, value, prev),
|
|
40
|
+
true,
|
|
41
|
+
);
|
|
42
|
+
props.setGlobalState &&
|
|
43
|
+
props.setGlobalState({
|
|
44
|
+
ignore: props.name,
|
|
45
|
+
user: {
|
|
46
|
+
name: props.name,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function mount(props) {
|
|
52
|
+
storeTest(props);
|
|
53
|
+
render(props);
|
|
54
|
+
instance.config.globalProperties.$onGlobalStateChange = props.onGlobalStateChange;
|
|
55
|
+
instance.config.globalProperties.$setGlobalState = props.setGlobalState;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export async function unmount() {
|
|
59
|
+
instance.unmount();
|
|
60
|
+
instance._container.innerHTML = '';
|
|
61
|
+
instance = null;
|
|
62
|
+
router = null;
|
|
63
|
+
history.destroy();
|
|
64
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
namespaced: true,
|
|
3
|
+
state: {
|
|
4
|
+
count: 0,
|
|
5
|
+
},
|
|
6
|
+
getters: {
|
|
7
|
+
evenOrOdd: state => (state.count % 2 === 0 ? 'even' : 'odd'),
|
|
8
|
+
},
|
|
9
|
+
mutations: {
|
|
10
|
+
increment(state) {
|
|
11
|
+
state.count++;
|
|
12
|
+
},
|
|
13
|
+
decrement(state) {
|
|
14
|
+
state.count--;
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
actions: {
|
|
18
|
+
increment: ({ commit }) => commit('increment'),
|
|
19
|
+
decrement: ({ commit }) => commit('decrement'),
|
|
20
|
+
incrementIfOdd({ commit, state }) {
|
|
21
|
+
if ((state.count + 1) % 2 === 0) {
|
|
22
|
+
commit('increment');
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
incrementAsync({ commit }) {
|
|
26
|
+
return new Promise(resolve => {
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
commit('increment');
|
|
29
|
+
resolve();
|
|
30
|
+
}, 1000);
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="about-content">
|
|
3
|
+
<h1>This is about page</h1>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
export default {
|
|
9
|
+
name: 'About',
|
|
10
|
+
setup() {},
|
|
11
|
+
};
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
15
|
+
<style scoped>
|
|
16
|
+
.about-content {
|
|
17
|
+
color: #7265e6;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<img alt="Vue logo" src="../assets/logo.png" />
|
|
3
|
+
<HelloWorld msg="Vue.js Demo" @close="close"> </HelloWorld>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script>
|
|
7
|
+
import HelloWorld from '@/components/HelloWorld.vue';
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
name: 'App',
|
|
11
|
+
components: {
|
|
12
|
+
HelloWorld,
|
|
13
|
+
},
|
|
14
|
+
created() {
|
|
15
|
+
console.log('vue2.0写法 created');
|
|
16
|
+
},
|
|
17
|
+
mounted() {
|
|
18
|
+
console.log(this.$route);
|
|
19
|
+
},
|
|
20
|
+
methods: {
|
|
21
|
+
close() {
|
|
22
|
+
console.log('close');
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
/* #app {
|
|
30
|
+
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
31
|
+
-webkit-font-smoothing: antialiased;
|
|
32
|
+
-moz-osx-font-smoothing: grayscale;
|
|
33
|
+
text-align: center;
|
|
34
|
+
color: #2c3e50;
|
|
35
|
+
margin-top: 60px;
|
|
36
|
+
} */
|
|
37
|
+
</style>
|