Compare commits

...

10 Commits

Author SHA1 Message Date
Zhang Hang 0b8a61baf3 前端 2023-12-17 09:21:41 +08:00
花裤衩 4c18a3f47b docs: update readme 2021-11-19 15:21:54 +08:00
花裤衩 714ded1155 docs: remove gitads 2020-08-30 22:59:10 +08:00
花裤衩 785f19f551
Update README.md 2020-07-26 10:07:01 +08:00
花裤衩 75ba8cf038 docs: update ads url 2020-07-13 10:42:23 +08:00
花裤衩 abcd5d810d docs: add gitads 2020-07-05 10:57:28 +08:00
花裤衩 8c4e38fb1f
Update README.md 2020-06-30 21:30:58 +08:00
花裤衩 fe326aa2b0
Update README.md 2020-06-30 21:20:43 +08:00
morrxy c9cb7db3ce
perf[getInfo]:stop run after reject (#599) 2020-06-26 18:40:32 +08:00
morrxy cd8d52bfbd
fix: add route name(#598) 2020-06-25 13:51:25 +08:00
11 changed files with 151 additions and 35 deletions

View File

@ -2,3 +2,4 @@ build/*.js
src/assets
public
dist
*

View File

@ -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)

View File

@ -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

9
src/api/dorm.js 100644
View File

@ -0,0 +1,9 @@
import request from '@/utils/request'
export function AppList(data) {
return request({
url: '/dorm/list',
method: 'post',
data
})
}

View File

@ -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 }
})

View File

@ -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' }
}
]

View File

@ -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

View File

@ -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
})

View File

@ -0,0 +1,51 @@
<template>
<div>
</div>
</template>
<script>
//jsjsjson,
//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>

View File

@ -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 = ''

View File

@ -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