@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.
Files changed (68) hide show
  1. package/bin/index.js +1 -0
  2. package/lib/index.js +5 -1
  3. package/package.json +1 -1
  4. package/templates/vue3-micro-app/.gitignore.tpl +23 -0
  5. package/templates/vue3-micro-app/README.md +15 -31
  6. package/templates/vue3-micro-app/babel.config.js +3 -0
  7. package/templates/vue3-micro-app/package.json.tpl +41 -36
  8. package/templates/vue3-micro-app/public/index.html +20 -0
  9. package/templates/vue3-micro-app/src/App.vue +52 -70
  10. package/templates/vue3-micro-app/src/assets/logo.png +0 -0
  11. package/templates/vue3-micro-app/src/components/HelloWorld.vue +63 -31
  12. package/templates/vue3-micro-app/src/main.js +64 -0
  13. package/templates/vue3-micro-app/src/public-path.js +4 -0
  14. package/templates/vue3-micro-app/src/router/index.js +6 -0
  15. package/templates/vue3-micro-app/src/store/count.js +34 -0
  16. package/templates/vue3-micro-app/src/store/index.js +12 -0
  17. package/templates/vue3-micro-app/src/views/About.vue +19 -0
  18. package/templates/vue3-micro-app/src/views/Home.vue +37 -0
  19. package/templates/vue3-micro-app/vue.config.js.tpl +43 -0
  20. package/templates/vue3-micro-plugin/README.md +24 -0
  21. package/templates/vue3-micro-plugin/babel.config.js +8 -0
  22. package/templates/vue3-micro-plugin/manifest.json.tpl +3 -0
  23. package/templates/vue3-micro-plugin/package.json.tpl +57 -0
  24. package/templates/vue3-micro-plugin/public/configuration.json +30 -0
  25. package/templates/vue3-micro-plugin/public/index.html +10 -0
  26. package/templates/vue3-micro-plugin/scripts/compress.js +32 -0
  27. package/templates/vue3-micro-plugin/src/App.vue.tpl +42 -0
  28. package/templates/vue3-micro-plugin/src/main.js +41 -0
  29. package/templates/vue3-micro-plugin/src/style.less.tpl +16 -0
  30. package/templates/vue3-micro-plugin/vue.config.js +46 -0
  31. package/templates/vue3vite-micro-app/.gitignore.tpl +23 -0
  32. package/templates/vue3vite-micro-app/README.md +48 -0
  33. package/templates/{vue3-micro-app → vue3vite-micro-app}/eslint.config.js +5 -1
  34. package/templates/vue3vite-micro-app/package.json.tpl +53 -0
  35. package/templates/vue3vite-micro-app/public/configuration.json +30 -0
  36. package/templates/vue3vite-micro-app/public/favicon.ico +0 -0
  37. package/templates/vue3vite-micro-app/scripts/devDistServe.cjs +16 -0
  38. package/templates/vue3vite-micro-app/src/App.vue +91 -0
  39. package/templates/vue3vite-micro-app/src/components/HelloWorld.vue +42 -0
  40. package/templates/vue3vite-micro-app/src/main.ts +40 -0
  41. package/templates/vue3vite-micro-app/src/typings.d.ts +5 -0
  42. package/templates/{vue3-micro-app → vue3vite-micro-app}/tsconfig.app.json +1 -0
  43. package/templates/vue3-micro-app/src/main.ts +0 -14
  44. /package/templates/{vue3-micro-app → vue3vite-micro-app}/.editorconfig +0 -0
  45. /package/templates/{vue3-micro-app → vue3vite-micro-app}/.prettierrc.json +0 -0
  46. /package/templates/{vue3-micro-app → vue3vite-micro-app}/.vscode/extensions.json +0 -0
  47. /package/templates/{vue3-micro-app → vue3vite-micro-app}/env.d.ts +0 -0
  48. /package/templates/{vue3-micro-app → vue3vite-micro-app}/index.html +0 -0
  49. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/assets/base.css +0 -0
  50. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/assets/logo.svg +0 -0
  51. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/assets/main.css +0 -0
  52. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/TheWelcome.vue +0 -0
  53. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/WelcomeItem.vue +0 -0
  54. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/__tests__/HelloWorld.spec.ts +0 -0
  55. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconCommunity.vue +0 -0
  56. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconDocumentation.vue +0 -0
  57. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconEcosystem.vue +0 -0
  58. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconSupport.vue +0 -0
  59. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/components/icons/IconTooling.vue +0 -0
  60. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/router/index.ts +0 -0
  61. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/stores/counter.ts +0 -0
  62. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/views/AboutView.vue +0 -0
  63. /package/templates/{vue3-micro-app → vue3vite-micro-app}/src/views/HomeView.vue +0 -0
  64. /package/templates/{vue3-micro-app → vue3vite-micro-app}/tsconfig.json +0 -0
  65. /package/templates/{vue3-micro-app → vue3vite-micro-app}/tsconfig.node.json +0 -0
  66. /package/templates/{vue3-micro-app → vue3vite-micro-app}/tsconfig.vitest.json +0 -0
  67. /package/templates/{vue3-micro-app → vue3vite-micro-app}/vite.config.ts +0 -0
  68. /package/templates/{vue3-micro-app → vue3vite-micro-app}/vitest.config.ts +0 -0
package/bin/index.js CHANGED
@@ -21,6 +21,7 @@ program
21
21
  'react',
22
22
  'vue',
23
23
  'vue3',
24
+ 'vue3vite',
24
25
  ].join('\n'))
25
26
  .option('-c, --PROJECT_CONFIG_TYPE <PROJECT_CONFIG_TYPE>', [
26
27
  `请选择配置类型`,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maxelms/create-plugin-cli",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "main": "./bin/index.js",
5
5
  "author": "jackc_001",
6
6
  "bin": {
@@ -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
- # vue-project
1
+ # hello-vue3
2
2
 
3
- This template should help get you started developing with Vue 3 in Vite.
3
+ ## Project setup
4
4
 
5
- ## Recommended IDE Setup
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
- ### Compile and Hot-Reload for Development
9
+ ### Compiles and hot-reloads for development
24
10
 
25
- ```sh
26
- pnpm dev
11
+ ```
12
+ npm run serve
27
13
  ```
28
14
 
29
- ### Type-Check, Compile and Minify for Production
15
+ ### Compiles and minifies for production
30
16
 
31
- ```sh
32
- pnpm build
17
+ ```
18
+ npm run build
33
19
  ```
34
20
 
35
- ### Run Unit Tests with [Vitest](https://vitest.dev/)
21
+ ### Lints and fixes files
36
22
 
37
- ```sh
38
- pnpm test:unit
23
+ ```
24
+ npm run lint
39
25
  ```
40
26
 
41
- ### Lint with [ESLint](https://eslint.org/)
27
+ ### Customize configuration
42
28
 
43
- ```sh
44
- pnpm lint
45
- ```
29
+ See [Configuration Reference](https://cli.vuejs.org/config/).
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ presets: ['@vue/cli-plugin-babel/preset'],
3
+ };
@@ -1,46 +1,51 @@
1
1
  {
2
2
  "name": "<%= pluginName %>",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "private": true,
5
- "type": "module",
6
5
  "scripts": {
7
- "start": "vite",
8
- "build": "run-p type-check \"build-only {@}\" -- && maxelms-plugin-cli -c",
9
- "preview": "vite preview",
10
- "test:unit": "vitest",
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
- "@esbuild/darwin-arm64": "0.24.0",
18
- "@rollup/rollup-darwin-arm64": "4.28.1",
19
- "pinia": "2.2.6",
20
- "vue": "3.5.13",
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
- "@tsconfig/node22": "22.0.0",
26
- "@types/jsdom": "21.1.7",
27
- "@types/node": "22.9.3",
28
- "@vitejs/plugin-vue": "5.2.1",
29
- "@vitejs/plugin-vue-jsx": "4.1.1",
30
- "@vitest/eslint-plugin": "1.1.10",
31
- "@vue/eslint-config-prettier": "10.1.0",
32
- "@vue/eslint-config-typescript": "14.1.3",
33
- "@vue/test-utils": "2.4.6",
34
- "@vue/tsconfig": "0.7.0",
35
- "eslint": "9.14.0",
36
- "eslint-plugin-vue": "9.30.0",
37
- "jsdom": "25.0.1",
38
- "npm-run-all2": "7.0.1",
39
- "prettier": "3.3.3",
40
- "typescript": "~5.6.3",
41
- "vite": "6.0.1",
42
- "vite-plugin-vue-devtools": "7.6.5",
43
- "vitest": "2.1.5",
44
- "vue-tsc": "2.1.10"
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
- import { RouterLink, RouterView } from 'vue-router'
3
- import HelloWorld from './components/HelloWorld.vue'
4
- </script>
1
+ <!-- <script setup lang="ts">
2
+ defineProps<{
3
+ configurations: any
4
+ }>()
5
+ </script> -->
5
6
 
6
7
  <template>
7
- <header>
8
- <img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
9
-
10
- <div class="wrapper">
11
- <HelloWorld msg="You did it!" />
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
- </header>
22
-
23
- <RouterView />
14
+ <router-view/>
15
+ </div>
24
16
  </template>
25
17
 
26
- <style scoped>
27
- header {
28
- line-height: 1.5;
29
- max-height: 100vh;
30
- }
18
+ <script>
19
+ import { onMounted, onBeforeUpdate } from 'vue';
31
20
 
32
- .logo {
33
- display: block;
34
- margin: 0 auto 2rem;
35
- }
21
+ export default {
22
+ name: 'HelloWorld',
23
+ props: {
24
+ configurations: {},
25
+ },
36
26
 
37
- nav {
38
- width: 100%;
39
- font-size: 12px;
40
- text-align: center;
41
- margin-top: 2rem;
42
- }
27
+ data() {
28
+ return {
29
+ nameColor: 'orange',
30
+ };
31
+ },
43
32
 
44
- nav a.router-link-exact-active {
45
- color: var(--color-text);
46
- }
33
+ setup() {
34
+ // const { ctx } = getCurrentInstance();
47
35
 
48
- nav a.router-link-exact-active:hover {
49
- background-color: transparent;
50
- }
36
+ onMounted(() => {
37
+ console.log('mounted');
38
+ });
51
39
 
52
- nav a {
53
- display: inline-block;
54
- padding: 0 1rem;
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
- @media (min-width: 1024px) {
63
- header {
64
- display: flex;
65
- place-items: center;
66
- padding-right: calc(var(--section-gap) / 2);
67
- }
44
+ return { };
45
+ },
46
+ };
47
+ </script>
68
48
 
69
- .logo {
70
- margin: 0 2rem 0 0;
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
- header .wrapper {
74
- display: flex;
75
- place-items: flex-start;
76
- flex-wrap: wrap;
77
- }
58
+ #nav {
59
+ padding: 30px;
78
60
 
79
- nav {
80
- text-align: left;
81
- margin-left: -1rem;
82
- font-size: 1rem;
61
+ a {
62
+ font-weight: bold;
63
+ color: #2c3e50;
83
64
 
84
- padding: 1rem 0;
85
- margin-top: 1rem;
65
+ &.router-link-exact-active {
66
+ color: #42b983;
67
+ }
86
68
  }
87
69
  }
88
70
  </style>
@@ -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="greetings">
10
- <h1 class="green">{{ msg }}</h1>
11
- <h3>
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
- <style scoped>
20
- h1 {
21
- font-weight: 500;
22
- font-size: 2.6rem;
23
- position: relative;
24
- top: -10px;
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
- font-size: 1.2rem;
58
+ margin: 40px 0 0;
29
59
  }
30
-
31
- .greetings h1,
32
- .greetings h3 {
33
- text-align: center;
60
+ ul {
61
+ list-style-type: none;
62
+ padding: 0;
34
63
  }
35
-
36
- @media (min-width: 1024px) {
37
- .greetings h1,
38
- .greetings h3 {
39
- text-align: left;
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,4 @@
1
+ if (window.__POWERED_BY_QIANKUN__) {
2
+ // eslint-disable-next-line no-undef
3
+ __webpack_public_path__ = window.__INJECTED_PUBLIC_PATH_BY_QIANKUN__;
4
+ }
@@ -0,0 +1,6 @@
1
+ const routes = [
2
+ { path: '/', name: 'home', component: () => import(/* webpackChunkName: "home" */ '@/views/Home') },
3
+ { path: '/about', name: 'about', component: () => import(/* webpackChunkName: "about" */ '@/views/About') },
4
+ ];
5
+
6
+ export default routes;
@@ -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,12 @@
1
+ import { createStore } from 'vuex';
2
+ import count from './count';
3
+
4
+ export default createStore({
5
+ state: {},
6
+ mutations: {},
7
+ actions: {},
8
+ getters: {},
9
+ modules: {
10
+ count,
11
+ },
12
+ });
@@ -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>