5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 22:13:36 +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

@ -18,7 +18,7 @@
## Internationalization
English| [简体中文](README.zh_CN.md)
English | [简体中文](README.zh_CN.md)
The traditional method of providing web interfaces to Go programs is via a built-in web server. Wails offers a different approach: it provides the ability to wrap both Go code and a web frontend into a single binary. Tools are provided to make this easy for you by handling project creation, compilation and bundling. All you have to do is get creative!

View File

@ -1,4 +1,4 @@
# vue3-js
# vue-js
## Project setup
```
@ -15,5 +15,10 @@ npm run serve
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
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,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"@wailsapp/runtime": "^1.1.1",
"core-js": "^3.6.5",
"vue": "^3.0.0",
"vue-router": "^4.0.0-0"
"vue-router": "^4.0.0-0",
"vuex": "^4.0.0-0"
},
"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-vuex": "~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": [
"> 1%",

View File

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

View File

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

View File

@ -1,10 +1,14 @@
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
// import wails runtime
import * as Wails from '@wailsapp/runtime';
Wails.Init(() => {
createApp(App)
.use(store)
.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 About from '../views/About.vue'
const routes = [
{
path: '/',
@ -11,15 +12,13 @@ const routes = [
{
path: '/about',
name: 'About',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
// You can only use pre-loading to add routes, not the on-demand loading method.
component: About
}
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
history: createMemoryHistory(),
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 = () => {
window.backend
.basic()
.then((result) => {
message.value = result;
.then((res) => {
message.value = res;
})
.catch((err) => {
console.log(err);

View File

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