From 0743bd38357c34c7203ae7dbc250242f08d8d4f2 Mon Sep 17 00:00:00 2001 From: Eleven Date: Sun, 1 Nov 2020 23:06:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20login=20=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=20=E8=B7=AF=E7=94=B1=E5=9C=B0=E5=9D=80=EF=BC=9A${url}/#login?= =?UTF-8?q?=20*=20=E4=BF=AE=E6=94=B9=E5=89=8D=E7=AB=AF=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BB=93=E6=9E=84=EF=BC=8C=E6=B7=BB=E5=8A=A0=E8=B7=AF=E7=94=B1?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web-vue/babel.config.js | 8 +++- web-vue/package.json | 6 ++- web-vue/src/App.vue | 10 ++-- web-vue/src/api/config.js | 24 ++++++++++ web-vue/src/api/user.js | 9 ++++ web-vue/src/assets/reset.css | 8 ++++ web-vue/src/components/HelloWorld.vue | 58 ----------------------- web-vue/src/main.js | 14 ++++-- web-vue/src/pages/layout/index.vue | 67 +++++++++++++++++++++++++++ web-vue/src/pages/login/index.vue | 51 ++++++++++++++++++++ web-vue/src/router/index.js | 20 ++++++++ 11 files changed, 205 insertions(+), 70 deletions(-) create mode 100644 web-vue/src/api/config.js create mode 100644 web-vue/src/api/user.js create mode 100644 web-vue/src/assets/reset.css delete mode 100644 web-vue/src/components/HelloWorld.vue create mode 100644 web-vue/src/pages/layout/index.vue create mode 100644 web-vue/src/pages/login/index.vue create mode 100644 web-vue/src/router/index.js diff --git a/web-vue/babel.config.js b/web-vue/babel.config.js index e9558405f..a5954d03a 100644 --- a/web-vue/babel.config.js +++ b/web-vue/babel.config.js @@ -1,5 +1,11 @@ module.exports = { presets: [ '@vue/cli-plugin-babel/preset' - ] + ], + // plugins: [ + // [ + // 'import', + // { libraryName: 'ant-design-vue', libraryDirectory: 'es', style: 'css' } + // ] + // ] } diff --git a/web-vue/package.json b/web-vue/package.json index 87a7e180d..6ed9b2279 100644 --- a/web-vue/package.json +++ b/web-vue/package.json @@ -9,14 +9,18 @@ }, "dependencies": { "ant-design-vue": "^1.7.1", + "axios": "^0.21.0", "core-js": "^3.6.5", - "vue": "^2.6.11" + "qs": "^6.9.4", + "vue": "^2.6.11", + "vue-router": "^3.4.8" }, "devDependencies": { "@vue/cli-plugin-babel": "~4.5.0", "@vue/cli-plugin-eslint": "~4.5.0", "@vue/cli-service": "~4.5.0", "babel-eslint": "^10.1.0", + "babel-plugin-import": "^1.13.1", "eslint": "^6.7.2", "eslint-plugin-vue": "^6.2.2", "vue-template-compiler": "^2.6.11" diff --git a/web-vue/src/App.vue b/web-vue/src/App.vue index 55df31532..984c5f157 100644 --- a/web-vue/src/App.vue +++ b/web-vue/src/App.vue @@ -1,17 +1,13 @@ @@ -21,8 +17,8 @@ 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; + margin: 0; + padding: 0; } diff --git a/web-vue/src/api/config.js b/web-vue/src/api/config.js new file mode 100644 index 000000000..d689a9fd6 --- /dev/null +++ b/web-vue/src/api/config.js @@ -0,0 +1,24 @@ +import axios from 'axios'; +import Qs from 'qs'; + +// axios.defaults.baseURL = 'http://localhost:2122' + +// 请求拦截器 +axios.interceptors.request.use(config => { + // 处理数据 + config.data = Qs.stringify(config.data); + return config; +}, error => { + return Promise.reject(error); +}); + +// 响应拦截器 +axios.interceptors.response.use(response => { + // 判断返回值,权限等... + return response.data; +}, error => { + console.log('网络开了小差!请重试...'); + return Promise.reject(error); +}); + +export default axios diff --git a/web-vue/src/api/user.js b/web-vue/src/api/user.js new file mode 100644 index 000000000..eb95a0d63 --- /dev/null +++ b/web-vue/src/api/user.js @@ -0,0 +1,9 @@ +import axios from './config'; + +export function login(params) { + return axios({ + url: '/userLogin', + method: 'post', + data: params + }) +} diff --git a/web-vue/src/assets/reset.css b/web-vue/src/assets/reset.css new file mode 100644 index 000000000..974df8c0d --- /dev/null +++ b/web-vue/src/assets/reset.css @@ -0,0 +1,8 @@ + +/* 全局样式,重置样式 */ +html, body { + width: 100vw; + height: 100vh; + margin: 0; + padding: 0; +} \ No newline at end of file diff --git a/web-vue/src/components/HelloWorld.vue b/web-vue/src/components/HelloWorld.vue deleted file mode 100644 index 879051a29..000000000 --- a/web-vue/src/components/HelloWorld.vue +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - diff --git a/web-vue/src/main.js b/web-vue/src/main.js index 63eb05f71..e556e29a9 100644 --- a/web-vue/src/main.js +++ b/web-vue/src/main.js @@ -1,8 +1,16 @@ -import Vue from 'vue' -import App from './App.vue' +import Vue from 'vue'; +import App from './App.vue'; -Vue.config.productionTip = false +import Antd from 'ant-design-vue'; +import 'ant-design-vue/dist/antd.css'; +import './assets/reset.css'; + +import router from './router'; + +Vue.config.productionTip = false; +Vue.use(Antd); new Vue({ + router, render: h => h(App), }).$mount('#app') diff --git a/web-vue/src/pages/layout/index.vue b/web-vue/src/pages/layout/index.vue new file mode 100644 index 000000000..77e04e9af --- /dev/null +++ b/web-vue/src/pages/layout/index.vue @@ -0,0 +1,67 @@ + + + \ No newline at end of file diff --git a/web-vue/src/pages/login/index.vue b/web-vue/src/pages/login/index.vue new file mode 100644 index 000000000..0d2746a4d --- /dev/null +++ b/web-vue/src/pages/login/index.vue @@ -0,0 +1,51 @@ + + + \ No newline at end of file diff --git a/web-vue/src/router/index.js b/web-vue/src/router/index.js new file mode 100644 index 000000000..f59c1af12 --- /dev/null +++ b/web-vue/src/router/index.js @@ -0,0 +1,20 @@ +import Vue from 'vue'; +import Router from 'vue-router'; + +Vue.use(Router) + +export default new Router({ + mode: 'hash', + routes: [ + { + path: '/login', + name: 'login', + component: () => import('../pages/login') + }, + { + path: '/', + name: 'home', + component: () => import('../pages/layout') + } + ] +}) \ No newline at end of file