mirror of
https://gitee.com/dromara/Jpom.git
synced 2024-11-30 19:08:18 +08:00
添加 login 页面 路由地址:${url}/#login
* 修改前端项目结构,添加路由管理
This commit is contained in:
parent
d05cefed3d
commit
0743bd3835
@ -1,5 +1,11 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@vue/cli-plugin-babel/preset'
|
||||
]
|
||||
],
|
||||
// plugins: [
|
||||
// [
|
||||
// 'import',
|
||||
// { libraryName: 'ant-design-vue', libraryDirectory: 'es', style: 'css' }
|
||||
// ]
|
||||
// ]
|
||||
}
|
||||
|
@ -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"
|
||||
|
@ -1,17 +1,13 @@
|
||||
<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
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -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;
|
||||
}
|
||||
</style>
|
||||
|
24
web-vue/src/api/config.js
Normal file
24
web-vue/src/api/config.js
Normal file
@ -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
|
9
web-vue/src/api/user.js
Normal file
9
web-vue/src/api/user.js
Normal file
@ -0,0 +1,9 @@
|
||||
import axios from './config';
|
||||
|
||||
export function login(params) {
|
||||
return axios({
|
||||
url: '/userLogin',
|
||||
method: 'post',
|
||||
data: params
|
||||
})
|
||||
}
|
8
web-vue/src/assets/reset.css
Normal file
8
web-vue/src/assets/reset.css
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
/* 全局样式,重置样式 */
|
||||
html, body {
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
@ -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>
|
@ -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')
|
||||
|
67
web-vue/src/pages/layout/index.vue
Normal file
67
web-vue/src/pages/layout/index.vue
Normal file
@ -0,0 +1,67 @@
|
||||
<template>
|
||||
<a-layout id="app-layout">
|
||||
<a-layout-sider v-model="collapsed" :trigger="null" collapsible>
|
||||
<div class="logo">Jpom</div>
|
||||
<a-menu theme="dark" mode="inline" :default-selected-keys="['1']">
|
||||
<a-menu-item key="1">
|
||||
<a-icon type="user" />
|
||||
<span>nav 1</span>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="2">
|
||||
<a-icon type="video-camera" />
|
||||
<span>nav 2</span>
|
||||
</a-menu-item>
|
||||
<a-menu-item key="3">
|
||||
<a-icon type="upload" />
|
||||
<span>nav 3</span>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</a-layout-sider>
|
||||
<a-layout>
|
||||
<a-layout-header style="background: #fff; padding: 0">
|
||||
<a-icon
|
||||
class="trigger"
|
||||
:type="collapsed ? 'menu-unfold' : 'menu-fold'"
|
||||
@click="() => (collapsed = !collapsed)"
|
||||
/>
|
||||
</a-layout-header>
|
||||
<a-layout-content
|
||||
:style="{ margin: '24px 16px', padding: '24px', background: '#fff', minHeight: '280px' }"
|
||||
>
|
||||
Content
|
||||
</a-layout-content>
|
||||
</a-layout>
|
||||
</a-layout>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
collapsed: false
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
#app-layout {
|
||||
height: 100vh;
|
||||
}
|
||||
#app-layout .trigger {
|
||||
float: left;
|
||||
font-size: 18px;
|
||||
line-height: 64px;
|
||||
padding: 0 24px;
|
||||
cursor: pointer;
|
||||
transition: color 0.3s;
|
||||
}
|
||||
|
||||
#app-layout .trigger:hover {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
#app-layout .logo {
|
||||
height: 32px;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
margin: 16px;
|
||||
}
|
||||
</style>
|
51
web-vue/src/pages/login/index.vue
Normal file
51
web-vue/src/pages/login/index.vue
Normal file
@ -0,0 +1,51 @@
|
||||
<template>
|
||||
<a-card class="login-card" hoverable style="width: 400px">
|
||||
<a-card-meta title="Jpom Dashboard" description=""/>
|
||||
<br/>
|
||||
<a-form :form="loginForm" :label-col="{ span: 0 }" @submit="handleLogin">
|
||||
<a-form-item :wrapper-col="{span: 24}">
|
||||
<a-input v-decorator="['userName', { rules: [{ required: true, message: 'Please input your name!' }] }]" placeholder="User Name"/>
|
||||
</a-form-item>
|
||||
<a-form-item :wrapper-col="{span: 24}">
|
||||
<a-input-password v-decorator="['userPwd', { rules: [{ required: true, message: 'Please input your password!' }] }]" placeholder="Password"/>
|
||||
</a-form-item>
|
||||
<a-form-item :wrapper-col="{ span: 24 }">
|
||||
<a-button type="primary" html-type="submit">
|
||||
登录
|
||||
</a-button>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</template>
|
||||
<script>
|
||||
import { login } from '../../api/user'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
loginForm: this.$form.createForm(this, { name: 'login-form' }),
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
handleLogin(e) {
|
||||
e.preventDefault();
|
||||
this.loginForm.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
console.log('Received values of form: ', values);
|
||||
}
|
||||
login(values).then(res => {
|
||||
console.log(res);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
.login-card {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%,-50%);
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
20
web-vue/src/router/index.js
Normal file
20
web-vue/src/router/index.js
Normal file
@ -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')
|
||||
}
|
||||
]
|
||||
})
|
Loading…
Reference in New Issue
Block a user