5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 14:42:03 +08:00

Fix vue3-js template (#727)

* fix(cli): add babel conversion and vuex

* docs: perfect Readme

* fix(cli): modify vue3-js template routing mode

* ref(cli): remove package.json.back file.
This commit is contained in:
misitebao 2021-06-01 05:50:05 +08:00 committed by GitHub
parent 14cc8681bf
commit 7a97c71ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 3382 additions and 1205 deletions

View File

@ -1,4 +1,4 @@
# vue3-js # vue-js
## Project setup ## Project setup
``` ```
@ -15,5 +15,10 @@ npm run serve
npm run build npm run build
``` ```
### Lints and fixes files
```
npm run lint
```
### Customize configuration ### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/). See [Configuration Reference](https://cli.vuejs.org/config/).

View File

@ -0,0 +1,5 @@
module.exports = {
presets: [
'@vue/cli-plugin-babel/preset'
]
}

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +0,0 @@
{
"name": "vue3-js",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"dependencies": {
"@wailsapp/runtime": "^1.1.1",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0"
},
"devDependencies": {
"@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}

View File

@ -4,17 +4,42 @@
"private": true, "private": true,
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build" "build": "vue-cli-service build",
"lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"@wailsapp/runtime": "^1.1.1", "@wailsapp/runtime": "^1.1.1",
"core-js": "^3.6.5",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-router": "^4.0.0-0" "vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",
"@vue/cli-plugin-eslint": "~4.5.0",
"@vue/cli-plugin-router": "~4.5.0", "@vue/cli-plugin-router": "~4.5.0",
"@vue/cli-plugin-vuex": "~4.5.0",
"@vue/cli-service": "~4.5.0", "@vue/cli-service": "~4.5.0",
"@vue/compiler-sfc": "^3.0.0" "@vue/compiler-sfc": "^3.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-vue": "^7.0.0",
"stylus": "^0.54.7",
"stylus-loader": "^3.0.2"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
}, },
"browserslist": [ "browserslist": [
"> 1%", "> 1%",

View File

@ -1,14 +1,12 @@
<template> <template>
<div id="app">
<div id="nav"> <div id="nav">
<router-link to="/">Home</router-link> | <router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link> <router-link to="/about">About</router-link>
</div> </div>
<router-view /> <router-view />
</div>
</template> </template>
<style> <style lang="stylus">
#app { #app {
font-family: Avenir, Helvetica, Arial, sans-serif; font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;

View File

@ -6,11 +6,11 @@
<script> <script>
export default { export default {
name: 'HelloWorld', name: "HelloWorld",
props: { props: {
msg: String msg: String,
} },
} };
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only --> <!-- Add "scoped" attribute to limit CSS to this component only -->

View File

@ -1,10 +1,14 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
import store from './store'
// import wails runtime
import * as Wails from '@wailsapp/runtime'; import * as Wails from '@wailsapp/runtime';
Wails.Init(() => { Wails.Init(() => {
createApp(App) createApp(App)
.use(store)
.use(router) .use(router)
.mount('#app'); .mount('#app')
}); })

View File

@ -1,7 +1,8 @@
import { createRouter, createWebHistory } from 'vue-router' import { createRouter, createMemoryHistory } from 'vue-router'
import Home from '../views/Home.vue' import Home from '../views/Home.vue'
import About from '../views/About.vue' import About from '../views/About.vue'
const routes = [ const routes = [
{ {
path: '/', path: '/',
@ -11,15 +12,13 @@ const routes = [
{ {
path: '/about', path: '/about',
name: 'About', name: 'About',
// route level code-splitting // You can only use pre-loading to add routes, not the on-demand loading method.
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: About component: About
} }
] ]
const router = createRouter({ const router = createRouter({
history: createWebHistory(process.env.BASE_URL), history: createMemoryHistory(),
routes routes
}) })

View File

@ -0,0 +1,12 @@
import { createStore } from 'vuex'
export default createStore({
state: {
},
mutations: {
},
actions: {
},
modules: {
}
})

View File

@ -25,8 +25,8 @@ export default {
const getMessage = () => { const getMessage = () => {
window.backend window.backend
.basic() .basic()
.then((result) => { .then((res) => {
message.value = result; message.value = res;
}) })
.catch((err) => { .catch((err) => {
console.log(err); console.log(err);

View File

@ -1,8 +1,8 @@
{ {
"name": "Vue3 JS", "name": "Vue3 JS",
"version": "1.0.0", "version": "1.0.0",
"shortdescription": "A template based on Vue 3, Vue-router, and Webpack5", "shortdescription": "A template based on Vue 3, Vue-router, Vuex, and Webpack5",
"description": "A template based on Vue 3, Vue-router, and Webpack5", "description": "A template based on Vue 3, Vue-router, Vuex, and Webpack5",
"install": "npm install", "install": "npm install",
"build": "npm run build", "build": "npm run build",
"author": "Misitebao <i@misitebao.com>", "author": "Misitebao <i@misitebao.com>",