init,环境配置

This commit is contained in:
王铜 2020-10-28 21:57:45 +08:00
parent 3ae8868d86
commit e6666b9948
13 changed files with 186 additions and 72 deletions

17
.eslintrc.js Normal file
View File

@ -0,0 +1,17 @@
module.exports = {
root: true,
env: {
node: true
},
'extends': [
'plugin:vue/essential',
// 'eslint:recommended'
],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'off' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'off' : 'off'
},
parserOptions: {
parser: 'babel-eslint'
}
}

12
jsconfig.json Normal file
View File

@ -0,0 +1,12 @@
{
"compilerOptions": {
"target":"es6",
"baseUrl": ".",
"allowSyntheticDefaultImports": true,
"paths": {
"@/*": ["./src/*"] ,
"com/*":["./src/components/*"]
}
},
// "exclude": ["node_modules"]
}

View File

@ -8,8 +8,11 @@
"lint": "vue-cli-service lint"
},
"dependencies": {
"ant-design-vue": "^1.7.0",
"core-js": "^3.6.5",
"vue": "^2.6.11"
"vue": "^2.6.11",
"vue-router": "^3.4.8",
"vuex": "^3.5.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.0",

View File

@ -1,19 +1,11 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
<router-view/>
</div>
</template>
<script>
import HelloWorld from './components/HelloWorld.vue'
export default {
name: 'App',
components: {
HelloWorld
}
}
export default {}
</script>
<style>
@ -21,8 +13,14 @@ export default {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
border: 0;
padding: 0;
margin: 0;
}
body {
border: 0;
padding: 0;
margin: 0;
}
</style>

View File

@ -1,58 +0,0 @@
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br>
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
</ul>
<h3>Essential Links</h3>
<ul>
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
</ul>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
props: {
msg: String
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>

13
src/components/Login.vue Normal file
View File

@ -0,0 +1,13 @@
<template>
</template>
<script>
export default {
}
</script>
<style>
</style>

33
src/components/Main.vue Normal file
View File

@ -0,0 +1,33 @@
<template>
<a-layout>
<a-layout-header style="height:108px;">
<a-row style="height:38px;position:absolute; line-height:38px;top:70px;">
<a-button type="primary">
主页
</a-button>
<a-button type="danger">
查询
</a-button>
</a-row>
</a-layout-header>
<a-layout-content>Content</a-layout-content>
</a-layout>
</template>
<script>
export default {
data() {
return {}
}
}
</script>
<style>
.ant-layout-header {
height: 108px;
}
.ant-layout-content {
height: calc(100vh - 108px);
}
</style>

View File

@ -1,8 +1,16 @@
import Vue from 'vue'
import App from './App.vue'
import store from './utils/store'
import router from './utils/router'
import Antd from 'ant-design-vue';
import 'ant-design-vue/dist/antd.css';
Vue.use(Antd)
Vue.config.productionTip = false
Vue.prototype.$store = store
new Vue({
router,
render: h => h(App),
}).$mount('#app')

0
src/utils/http.js Normal file
View File

45
src/utils/router.js Normal file
View File

@ -0,0 +1,45 @@
import Vue from 'vue'
import Router from 'vue-router'
import Index from '@/components/Main'
Vue.use(Router)
const routes = [
{
path: '/',
redirect: '/index',
},
{
path: '/index',
name: 'index',
component: Index,
meta: {
requireAuth: false
}
}
]
const router = new Router({
base: process.env.BASE_URL,
routes
})
router.beforeEach((to, from, next) => {
if (to.meta.requireAuth) {
// console.log(to.fullPath);
if (store.state.login && ((new Date()).getTime() - store.state.loginTime) < store.state.second * 1000) {
next()
} else {
next({
path: '/login', query: {
redirect: to.fullPath
}
})
}
}
else {
next()
}
})
export default router

12
src/utils/store.js Normal file
View File

@ -0,0 +1,12 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
const store = new Vuex.Store({
state: {
}
})
export default store

0
src/utils/utils.js Normal file
View File

31
vue.config.js Normal file
View File

@ -0,0 +1,31 @@
const path = require('path')
module.exports = {
publicPath: '/water/',
devServer: {
host: '127.0.0.1',
port: 8090,
proxy: {
'/backend': {
// target: 'http://223.75.53.208:8081',
target: 'http://127.0.0.1:8000',
}
}
},
productionSourceMap: false,
configureWebpack: {
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'com': path.resolve(__dirname, 'src', 'components')
}
},
module: {
}
}
}