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 src/assets
public public
dist 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` 目前版本为 `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 ## Extra
如果你想要根据用户角色来动态生成侧边栏和 router你可以使用该分支[permission-control](https://github.com/PanJiaChen/vue-admin-template/tree/permission-control) 如果你想要根据用户角色来动态生成侧边栏和 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`** **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 ```bash
# clone the project # 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) { export function login(data) {
return request({ return request({
url: '/vue-admin-template/user/login', url: '/auth/login',
method: 'post', method: 'post',
data data
}) })
} }
export function sendCode(phone) {
return request({
url: '/auth/sendCode/'+phone,
method: 'post',
data:phone
})
}
export function getInfo(token) { export function getInfo(token) {
return request({ return request({
url: '/vue-admin-template/user/info', url: '/auth/userInfo',
method: 'get', method: 'get',
params: { token } 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', path: '/nested',
component: Layout, component: Layout,
@ -143,6 +156,7 @@ export const constantRoutes = [
{ {
path: 'menu2', path: 'menu2',
component: () => import('@/views/nested/menu2/index'), component: () => import('@/views/nested/menu2/index'),
name: 'Menu2',
meta: { title: 'menu2' } meta: { title: 'menu2' }
} }
] ]

View File

@ -30,9 +30,9 @@ const mutations = {
const actions = { const actions = {
// user login // user login
login({ commit }, userInfo) { login({ commit }, userInfo) {
const { username, password } = userInfo const { phone, code } = userInfo
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
login({ username: username.trim(), password: password }).then(response => { login({ phone: phone.trim(), code: code }).then(response => {
const { data } = response const { data } = response
commit('SET_TOKEN', data.token) commit('SET_TOKEN', data.token)
setToken(data.token) setToken(data.token)
@ -50,7 +50,7 @@ const actions = {
const { data } = response const { data } = response
if (!data) { if (!data) {
reject('Verification failed, please Login again.') return reject('Verification failed, please Login again.')
} }
const { name, avatar } = data const { name, avatar } = data

View File

@ -7,7 +7,7 @@ import { getToken } from '@/utils/auth'
const service = axios.create({ const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
// withCredentials: true, // send cookies when cross-domain requests // withCredentials: true, // send cookies when cross-domain requests
timeout: 5000 // request timeout timeout: 50000 // request timeout
}) })
// request interceptor // request interceptor
@ -19,7 +19,7 @@ service.interceptors.request.use(
// let each request carry token // let each request carry token
// ['X-Token'] is a custom headers key // ['X-Token'] is a custom headers key
// please modify it according to the actual situation // please modify it according to the actual situation
config.headers['X-Token'] = getToken() config.headers['token'] = getToken()
} }
return config return config
}, },
@ -46,9 +46,9 @@ service.interceptors.response.use(
const res = response.data const res = response.data
// if the custom code is not 20000, it is judged as an error. // if the custom code is not 20000, it is judged as an error.
if (res.code !== 20000) { if (res.code !== 200) {
Message({ Message({
message: res.message || 'Error', message: res.msg || 'Error',
type: 'error', type: 'error',
duration: 5 * 1000 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 { } else {
return res return res
} }
@ -74,7 +74,7 @@ service.interceptors.response.use(
error => { error => {
console.log('err' + error) // for debug console.log('err' + error) // for debug
Message({ Message({
message: error.message, message: error.msg,
type: 'error', type: 'error',
duration: 5 * 1000 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> </span>
<el-input <el-input
ref="username" ref="username"
v-model="loginForm.username" v-model="loginForm.phone"
placeholder="Username" placeholder="Username"
name="username" name="username"
type="text" type="text"
@ -26,9 +26,8 @@
<svg-icon icon-class="password" /> <svg-icon icon-class="password" />
</span> </span>
<el-input <el-input
:key="passwordType"
ref="password" ref="password"
v-model="loginForm.password" v-model="loginForm.code"
:type="passwordType" :type="passwordType"
placeholder="Password" placeholder="Password"
name="password" name="password"
@ -41,7 +40,8 @@
</span> </span>
</el-form-item> </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"> <div class="tips">
<span style="margin-right:20px;">username: admin</span> <span style="margin-right:20px;">username: admin</span>
@ -54,32 +54,33 @@
<script> <script>
import { validUsername } from '@/utils/validate' import { validUsername } from '@/utils/validate'
import { sendCode } from '@/api/user'
export default { export default {
name: 'Login', name: 'Login',
data() { data() {
const validateUsername = (rule, value, callback) => { // const validateUsername = (rule, value, callback) => {
if (!validUsername(value)) { // if (!validUsername(value)) {
callback(new Error('Please enter the correct user name')) // callback(new Error('Please enter the correct user name'))
} else { // } else {
callback() // callback()
} // }
} // }
const validatePassword = (rule, value, callback) => { // const validatePassword = (rule, value, callback) => {
if (value.length < 6) { // if (value.length < 6) {
callback(new Error('The password can not be less than 6 digits')) // callback(new Error('The password can not be less than 6 digits'))
} else { // } else {
callback() // callback()
} // }
} // }
return { return {
loginForm: { loginForm: {
username: 'admin', phone: '',
password: '111111' code: ''
}, },
loginRules: { loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }], phone: [{ required: true, trigger: 'blur' }],
password: [{ required: true, trigger: 'blur', validator: validatePassword }] code: [{ required: true, trigger: 'blur' }]
}, },
loading: false, loading: false,
passwordType: 'password', passwordType: 'password',
@ -95,6 +96,13 @@ export default {
} }
}, },
methods: { methods: {
sendCode(){
sendCode(this.loginForm.phone).then(
res=>{
this.$message.success(res.msg);
}
)
},
showPwd() { showPwd() {
if (this.passwordType === 'password') { if (this.passwordType === 'password') {
this.passwordType = '' this.passwordType = ''

View File

@ -36,7 +36,15 @@ module.exports = {
warnings: false, warnings: false,
errors: true 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: { configureWebpack: {
// provide the app's title in webpack's name field, so that // provide the app's title in webpack's name field, so that