Compare commits
10 Commits
879318692c
...
0b8a61baf3
Author | SHA1 | Date |
---|---|---|
|
0b8a61baf3 | |
|
4c18a3f47b | |
|
714ded1155 | |
|
785f19f551 | |
|
75ba8cf038 | |
|
abcd5d810d | |
|
8c4e38fb1f | |
|
fe326aa2b0 | |
|
c9cb7db3ce | |
|
cd8d52bfbd |
|
@ -2,3 +2,4 @@ build/*.js
|
|||
src/assets
|
||||
public
|
||||
dist
|
||||
*
|
||||
|
|
|
@ -8,6 +8,15 @@
|
|||
|
||||
目前版本为 `v4.0+` 基于 `vue-cli` 进行构建,若你想使用旧版本,可以切换分支到[tag/3.11.0](https://github.com/PanJiaChen/vue-admin-template/tree/tag/3.11.0),它不依赖 `vue-cli`。
|
||||
|
||||
<p align="center">
|
||||
<b>SPONSORED BY</b>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://finclip.com?from=vue_element" title="FinClip" target="_blank">
|
||||
<img height="200px" src="https://gitee.com/panjiachen/gitee-cdn/raw/master/vue%E8%B5%9E%E5%8A%A9.png" title="FinClip">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## Extra
|
||||
|
||||
如果你想要根据用户角色来动态生成侧边栏和 router,你可以使用该分支[permission-control](https://github.com/PanJiaChen/vue-admin-template/tree/permission-control)
|
||||
|
|
10
README.md
10
README.md
|
@ -9,8 +9,16 @@ English | [简体中文](./README-zh.md)
|
|||
|
||||
**The current version is `v4.0+` build on `vue-cli`. If you want to use the old version , you can switch branch to [tag/3.11.0](https://github.com/PanJiaChen/vue-admin-template/tree/tag/3.11.0), it does not rely on `vue-cli`**
|
||||
|
||||
## Build Setup
|
||||
<p align="center">
|
||||
<b>SPONSORED BY</b>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://finclip.com?from=vue_element" title="FinClip" target="_blank">
|
||||
<img height="200px" src="https://gitee.com/panjiachen/gitee-cdn/raw/master/vue%E8%B5%9E%E5%8A%A9.png" title="FinClip">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## Build Setup
|
||||
|
||||
```bash
|
||||
# clone the project
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
export function AppList(data) {
|
||||
return request({
|
||||
url: '/dorm/list',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
|
@ -2,15 +2,23 @@ import request from '@/utils/request'
|
|||
|
||||
export function login(data) {
|
||||
return request({
|
||||
url: '/vue-admin-template/user/login',
|
||||
url: '/auth/login',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function sendCode(phone) {
|
||||
return request({
|
||||
url: '/auth/sendCode/'+phone,
|
||||
method: 'post',
|
||||
data:phone
|
||||
})
|
||||
}
|
||||
|
||||
export function getInfo(token) {
|
||||
return request({
|
||||
url: '/vue-admin-template/user/info',
|
||||
url: '/auth/userInfo',
|
||||
method: 'get',
|
||||
params: { token }
|
||||
})
|
||||
|
|
|
@ -90,6 +90,19 @@ export const constantRoutes = [
|
|||
]
|
||||
},
|
||||
|
||||
{
|
||||
path: '/dorm',
|
||||
component: Layout,
|
||||
children: [
|
||||
{
|
||||
path: 'index',
|
||||
name: '宿舍管理',
|
||||
component: () => import('@/views/dorm/index'),
|
||||
meta: { title: '宿舍管理', icon: 'el-icon-platform-eleme' }
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
path: '/nested',
|
||||
component: Layout,
|
||||
|
@ -143,6 +156,7 @@ export const constantRoutes = [
|
|||
{
|
||||
path: 'menu2',
|
||||
component: () => import('@/views/nested/menu2/index'),
|
||||
name: 'Menu2',
|
||||
meta: { title: 'menu2' }
|
||||
}
|
||||
]
|
||||
|
|
|
@ -30,9 +30,9 @@ const mutations = {
|
|||
const actions = {
|
||||
// user login
|
||||
login({ commit }, userInfo) {
|
||||
const { username, password } = userInfo
|
||||
const { phone, code } = userInfo
|
||||
return new Promise((resolve, reject) => {
|
||||
login({ username: username.trim(), password: password }).then(response => {
|
||||
login({ phone: phone.trim(), code: code }).then(response => {
|
||||
const { data } = response
|
||||
commit('SET_TOKEN', data.token)
|
||||
setToken(data.token)
|
||||
|
@ -50,7 +50,7 @@ const actions = {
|
|||
const { data } = response
|
||||
|
||||
if (!data) {
|
||||
reject('Verification failed, please Login again.')
|
||||
return reject('Verification failed, please Login again.')
|
||||
}
|
||||
|
||||
const { name, avatar } = data
|
||||
|
|
|
@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
|
|||
const service = axios.create({
|
||||
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
|
||||
// withCredentials: true, // send cookies when cross-domain requests
|
||||
timeout: 5000 // request timeout
|
||||
timeout: 50000 // request timeout
|
||||
})
|
||||
|
||||
// request interceptor
|
||||
|
@ -19,7 +19,7 @@ service.interceptors.request.use(
|
|||
// let each request carry token
|
||||
// ['X-Token'] is a custom headers key
|
||||
// please modify it according to the actual situation
|
||||
config.headers['X-Token'] = getToken()
|
||||
config.headers['token'] = getToken()
|
||||
}
|
||||
return config
|
||||
},
|
||||
|
@ -46,9 +46,9 @@ service.interceptors.response.use(
|
|||
const res = response.data
|
||||
|
||||
// if the custom code is not 20000, it is judged as an error.
|
||||
if (res.code !== 20000) {
|
||||
if (res.code !== 200) {
|
||||
Message({
|
||||
message: res.message || 'Error',
|
||||
message: res.msg || 'Error',
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
|
@ -66,7 +66,7 @@ service.interceptors.response.use(
|
|||
})
|
||||
})
|
||||
}
|
||||
return Promise.reject(new Error(res.message || 'Error'))
|
||||
return Promise.reject(new Error(res.msg || 'Error'))
|
||||
} else {
|
||||
return res
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ service.interceptors.response.use(
|
|||
error => {
|
||||
console.log('err' + error) // for debug
|
||||
Message({
|
||||
message: error.message,
|
||||
message: error.msg,
|
||||
type: 'error',
|
||||
duration: 5 * 1000
|
||||
})
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
<template>
|
||||
<div>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
//这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等),
|
||||
//例如:import 《组件名称》 from '《组件路径》,
|
||||
export default {
|
||||
//import引入的组件需要注入到对象中才能使用"
|
||||
components: {},
|
||||
props: {},
|
||||
data() {
|
||||
//这里存放数据"
|
||||
|
||||
return {};
|
||||
},
|
||||
//计算属性 类似于data概念",
|
||||
computed: {},
|
||||
//监控data中的数据变化",
|
||||
watch: {},
|
||||
//方法集合",
|
||||
methods: {},
|
||||
//生命周期 - 创建完成(可以访问当前this实例)",
|
||||
created() {
|
||||
},
|
||||
//生命周期 - 挂载完成(可以访问DOM元素)",
|
||||
mounted() {
|
||||
},
|
||||
beforeCreate() {
|
||||
}, //生命周期 - 创建之前",
|
||||
beforeMount() {
|
||||
}, //生命周期 - 挂载之前",
|
||||
beforeUpdate() {
|
||||
}, //生命周期 - 更新之前",
|
||||
updated() {
|
||||
}, //生命周期 - 更新之后",
|
||||
beforeDestroy() {
|
||||
}, //生命周期 - 销毁之前",
|
||||
destroyed() {
|
||||
}, //生命周期 - 销毁完成",
|
||||
activated() {
|
||||
} //如果页面有keep-alive缓存功能,这个函数会触发",
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
</style>
|
|
@ -12,7 +12,7 @@
|
|||
</span>
|
||||
<el-input
|
||||
ref="username"
|
||||
v-model="loginForm.username"
|
||||
v-model="loginForm.phone"
|
||||
placeholder="Username"
|
||||
name="username"
|
||||
type="text"
|
||||
|
@ -26,9 +26,8 @@
|
|||
<svg-icon icon-class="password" />
|
||||
</span>
|
||||
<el-input
|
||||
:key="passwordType"
|
||||
ref="password"
|
||||
v-model="loginForm.password"
|
||||
v-model="loginForm.code"
|
||||
:type="passwordType"
|
||||
placeholder="Password"
|
||||
name="password"
|
||||
|
@ -41,7 +40,8 @@
|
|||
</span>
|
||||
</el-form-item>
|
||||
|
||||
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">Login</el-button>
|
||||
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="sendCode">获取验证码</el-button>
|
||||
<el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">登录</el-button>
|
||||
|
||||
<div class="tips">
|
||||
<span style="margin-right:20px;">username: admin</span>
|
||||
|
@ -54,32 +54,33 @@
|
|||
|
||||
<script>
|
||||
import { validUsername } from '@/utils/validate'
|
||||
import { sendCode } from '@/api/user'
|
||||
|
||||
export default {
|
||||
name: 'Login',
|
||||
data() {
|
||||
const validateUsername = (rule, value, callback) => {
|
||||
if (!validUsername(value)) {
|
||||
callback(new Error('Please enter the correct user name'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
const validatePassword = (rule, value, callback) => {
|
||||
if (value.length < 6) {
|
||||
callback(new Error('The password can not be less than 6 digits'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
// const validateUsername = (rule, value, callback) => {
|
||||
// if (!validUsername(value)) {
|
||||
// callback(new Error('Please enter the correct user name'))
|
||||
// } else {
|
||||
// callback()
|
||||
// }
|
||||
// }
|
||||
// const validatePassword = (rule, value, callback) => {
|
||||
// if (value.length < 6) {
|
||||
// callback(new Error('The password can not be less than 6 digits'))
|
||||
// } else {
|
||||
// callback()
|
||||
// }
|
||||
// }
|
||||
return {
|
||||
loginForm: {
|
||||
username: 'admin',
|
||||
password: '111111'
|
||||
phone: '',
|
||||
code: ''
|
||||
},
|
||||
loginRules: {
|
||||
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
|
||||
password: [{ required: true, trigger: 'blur', validator: validatePassword }]
|
||||
phone: [{ required: true, trigger: 'blur' }],
|
||||
code: [{ required: true, trigger: 'blur' }]
|
||||
},
|
||||
loading: false,
|
||||
passwordType: 'password',
|
||||
|
@ -95,6 +96,13 @@ export default {
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
sendCode(){
|
||||
sendCode(this.loginForm.phone).then(
|
||||
res=>{
|
||||
this.$message.success(res.msg);
|
||||
}
|
||||
)
|
||||
},
|
||||
showPwd() {
|
||||
if (this.passwordType === 'password') {
|
||||
this.passwordType = ''
|
||||
|
|
|
@ -36,7 +36,15 @@ module.exports = {
|
|||
warnings: false,
|
||||
errors: true
|
||||
},
|
||||
before: require('./mock/mock-server.js')
|
||||
proxy:{
|
||||
[process.env.VUE_APP_BASE_API]: {
|
||||
target: 'http://127.0.0.1:18080',
|
||||
changeOrigin: true,
|
||||
pathRewrite: {
|
||||
['^' + process.env.VUE_APP_BASE_API]: ''
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
configureWebpack: {
|
||||
// provide the app's title in webpack's name field, so that
|
||||
|
|
Loading…
Reference in New Issue