mirror of
https://github.com/eyebluecn/tank-front
synced 2024-04-21 12:31:55 +00:00
Refine the user model.
This commit is contained in:
@@ -46,7 +46,6 @@
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="row mt10">
|
||||
<label class="col-md-2 control-label mt5">zip下载数量限制</label>
|
||||
<div class="col-md-10">
|
||||
@@ -54,6 +53,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row mt10">
|
||||
<label class="col-md-2 control-label mt5">zip下载大小限制(B) </label>
|
||||
<div class="col-md-10">
|
||||
@@ -72,6 +72,19 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row mt10">
|
||||
<label class="col-md-2 control-label mt5">用户默认总大小限制</label>
|
||||
<div class="col-md-10">
|
||||
<input type="text" class="form-control" v-model="preference.defaultTotalSizeLimit">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt10">
|
||||
<label class="col-md-2 control-label mt5">允许自主注册</label>
|
||||
<div class="col-md-10">
|
||||
<NbSwitcher v-model="preference.allowRegister"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mt10">
|
||||
<div class="col-md-12">
|
||||
|
||||
@@ -52,6 +52,11 @@
|
||||
<span v-html="preference.downloadDirMaxNum"></span>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 form-info">
|
||||
<span>是否允许用户自主注册:</span>
|
||||
<span>{{preference.allowRegister?'是':'否'}}</span>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12 form-info">
|
||||
<span>zip下载大小限制:</span>
|
||||
<span>
|
||||
@@ -67,6 +72,12 @@
|
||||
</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-12 form-info">
|
||||
<span>用户默认总大小限制:</span>
|
||||
<span v-html="preference.defaultTotalSizeLimit"></span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
+38
-38
@@ -1,55 +1,55 @@
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3 mt100">
|
||||
<div class="text-primary f25 text-center mb20">欢迎登录</div>
|
||||
<!--输入框开始-->
|
||||
<div class="input-group mb15">
|
||||
<span class="input-group-addon"><i class="fa fa-user w14"></i></span>
|
||||
<input type="text" class="form-control" placeholder="用户名" v-model="username"
|
||||
@keyup.enter="login">
|
||||
</div>
|
||||
<div class="input-group mb15">
|
||||
<span class="input-group-addon"><i class="fa fa-unlock-alt w14"></i></span>
|
||||
<input type="password" class="form-control" placeholder="密码" v-model="password"
|
||||
@keyup.enter="login">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3 mt100">
|
||||
<div class="text-primary f25 text-center mb20">欢迎登录</div>
|
||||
<!--输入框开始-->
|
||||
<div class="input-group mb15">
|
||||
<span class="input-group-addon"><i class="fa fa-user w14"></i></span>
|
||||
<input type="text" class="form-control" placeholder="用户名" v-model="user.username"
|
||||
@keyup.enter="login">
|
||||
</div>
|
||||
<div class="input-group mb15">
|
||||
<span class="input-group-addon"><i class="fa fa-unlock-alt w14"></i></span>
|
||||
<input type="password" class="form-control" placeholder="密码" v-model="user.localPassword"
|
||||
@keyup.enter="login">
|
||||
</div>
|
||||
|
||||
<div class="mb15">
|
||||
<button class="btn btn-primary button full-width" @click.prevent.stop="login" :disabled="user.loading">
|
||||
<div class="mb15">
|
||||
<button class="btn btn-primary button full-width" @click.prevent.stop="login"
|
||||
:disabled="user.loading">
|
||||
<span v-if="user.loading">
|
||||
<i class="fa fa-spinner fa-spin"></i>
|
||||
正在登录...
|
||||
</span>
|
||||
<span v-else>
|
||||
<span v-else>
|
||||
<i class="fa fa-user-circle-o"></i>
|
||||
登录
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb15 text-right">
|
||||
<router-link to="/user/register">立即注册</router-link>
|
||||
</div>
|
||||
|
||||
</button>
|
||||
<div class="mb15" v-show="user.errorMessage">
|
||||
<div class="alert alert-danger">
|
||||
{{user.errorMessage}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb15" v-show="user.errorMessage">
|
||||
<div class="alert alert-danger">
|
||||
{{user.errorMessage}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { startWith } from '../../common/filter/str'
|
||||
import { Notification } from 'element-ui'
|
||||
import {startWith} from '../../common/filter/str'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
username: null,
|
||||
password: null,
|
||||
user: this.$store.state.user,
|
||||
captchaValue: null,
|
||||
redirect: this.$route.query.redirect
|
||||
@@ -60,11 +60,11 @@
|
||||
computed: {},
|
||||
components: {},
|
||||
methods: {
|
||||
login () {
|
||||
login() {
|
||||
let that = this
|
||||
this.user.httpLogin(function () {
|
||||
|
||||
|
||||
this.user.httpLogin(that.username, that.password, function () {
|
||||
//自动跳转到之前的页面中去。
|
||||
if (that.redirect) {
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
})
|
||||
|
||||
},
|
||||
logout () {
|
||||
logout() {
|
||||
|
||||
if (this.user.role !== 'GUEST') {
|
||||
this.user.httpLogout(function () {
|
||||
@@ -101,7 +101,7 @@
|
||||
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
mounted() {
|
||||
//到登录页面了需要先做一次退出操作。因为退出就是直接跳转到登录页面的。
|
||||
this.logout()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
<template>
|
||||
<div class="row animated fadeIn backyard-user-register">
|
||||
|
||||
<div class="col-lg-4 col-lg-offset-4 col-md-6 col-md-offset-3 mt100">
|
||||
<div class="text-primary f25 text-center mb20">欢迎注册</div>
|
||||
<!--输入框开始-->
|
||||
<div class="input-group mb15">
|
||||
<span class="input-group-addon"><i class="fa fa-user w14"></i></span>
|
||||
<input type="text" class="form-control" placeholder="用户名" v-model="username"
|
||||
@keyup.enter="register">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb15">
|
||||
<span class="input-group-addon"><i class="fa fa-unlock-alt w14"></i></span>
|
||||
<input type="password" class="form-control" placeholder="密码" v-model="password"
|
||||
@keyup.enter="register">
|
||||
</div>
|
||||
|
||||
<div class="input-group mb15">
|
||||
<span class="input-group-addon"><i class="fa fa-unlock-alt w14"></i></span>
|
||||
<input type="password" class="form-control" placeholder="确认密码" v-model="rePassword"
|
||||
@keyup.enter="register">
|
||||
</div>
|
||||
|
||||
<div class="mb15">
|
||||
<button class="btn btn-primary button full-width" @click.prevent.stop="register" :disabled="user.loading">
|
||||
<span v-if="user.loading">
|
||||
<i class="fa fa-spinner fa-spin"></i>
|
||||
正在登录...
|
||||
</span>
|
||||
<span v-else>
|
||||
<i class="fa fa-user-circle-o"></i>
|
||||
登录
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mb15 text-right">
|
||||
<router-link to="/user/login">前往登录</router-link>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="mb15" v-show="user.errorMessage">
|
||||
<div class="alert alert-danger">
|
||||
{{user.errorMessage}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {startWith} from '../../common/filter/str'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
username: null,
|
||||
password: null,
|
||||
rePassword: null,
|
||||
user: this.$store.state.user,
|
||||
captchaValue: null,
|
||||
redirect: this.$route.query.redirect
|
||||
}
|
||||
},
|
||||
props: {},
|
||||
watch: {},
|
||||
computed: {},
|
||||
components: {},
|
||||
methods: {
|
||||
register() {
|
||||
let that = this
|
||||
|
||||
this.user.httpRegister(that.username, that.password, that.rePassword, function () {
|
||||
//自动跳转到之前的页面中去。
|
||||
if (that.redirect) {
|
||||
|
||||
if (startWith(that.redirect, '/')) {
|
||||
that.$router.push(that.redirect)
|
||||
} else {
|
||||
location.href = that.redirect
|
||||
}
|
||||
} else {
|
||||
//自动进入到首页。
|
||||
that.$router.push('/')
|
||||
}
|
||||
|
||||
//登录成功啦。
|
||||
}, function (err) {
|
||||
|
||||
that.$message.error({
|
||||
title: '错误',
|
||||
message: err.data.msg
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
},
|
||||
logout() {
|
||||
|
||||
if (this.user.role !== 'GUEST') {
|
||||
this.user.httpLogout(function () {
|
||||
|
||||
}, function () {
|
||||
console.error('退出失败!')
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
//到登录页面了需要先做一次退出操作。因为退出就是直接跳转到登录页面的。
|
||||
this.logout()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" rel="stylesheet/less">
|
||||
.backyard-user-register {
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@@ -22,6 +22,12 @@ export default class Preference extends BaseEntity {
|
||||
this.downloadDirMaxSize = -1
|
||||
//文件数量
|
||||
this.downloadDirMaxNum = -1
|
||||
//用户默认总大小限制
|
||||
this.defaultTotalSizeLimit = -1
|
||||
//是否允许自主注册
|
||||
this.allowRegister = false
|
||||
//后台版本
|
||||
this.version = null
|
||||
|
||||
this.validatorSchema = {
|
||||
name: {
|
||||
@@ -45,7 +51,9 @@ export default class Preference extends BaseEntity {
|
||||
copyright: this.copyright,
|
||||
record: this.record,
|
||||
downloadDirMaxNum: this.downloadDirMaxNum,
|
||||
downloadDirMaxSize: this.downloadDirMaxSize
|
||||
downloadDirMaxSize: this.downloadDirMaxSize,
|
||||
defaultTotalSizeLimit: this.defaultTotalSizeLimit,
|
||||
allowRegister: this.allowRegister
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ export default class User extends BaseEntity {
|
||||
|
||||
static LOCAL_STORAGE_KEY = "user";
|
||||
static URL_LOGIN = '/api/user/login'
|
||||
static URL_REGISTER = '/api/user/register'
|
||||
static URL_LOGOUT = '/api/user/logout'
|
||||
static URL_USER_CHANGE_PASSWORD = '/api/user/change/password'
|
||||
static URL_USER_RESET_PASSWORD = '/api/user/reset/password'
|
||||
@@ -37,9 +38,6 @@ export default class User extends BaseEntity {
|
||||
//local fields
|
||||
this.isLogin = false
|
||||
|
||||
//登录的密码,服务器返回字段中没有密码
|
||||
this.localPassword = null
|
||||
|
||||
this.validatorSchema = {
|
||||
username: {
|
||||
rules: [
|
||||
@@ -184,45 +182,21 @@ export default class User extends BaseEntity {
|
||||
|
||||
}
|
||||
|
||||
loginValidate() {
|
||||
httpLogin(username, password, successCallback, errorCallback) {
|
||||
|
||||
if (!this.username) {
|
||||
this.errorMessage = '账号必填'
|
||||
let that = this
|
||||
|
||||
if (!username) {
|
||||
this.errorMessage = '用户名必填'
|
||||
return false
|
||||
}
|
||||
|
||||
if (!this.localPassword) {
|
||||
if (!password) {
|
||||
this.errorMessage = '密码必填'
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
getLoginForm() {
|
||||
|
||||
return {
|
||||
username: this.username,
|
||||
password: this.localPassword
|
||||
}
|
||||
}
|
||||
|
||||
getResetForm() {
|
||||
return {
|
||||
phone: this.phone,
|
||||
password: this.password
|
||||
}
|
||||
}
|
||||
|
||||
httpLogin(successCallback, errorCallback) {
|
||||
|
||||
let that = this
|
||||
|
||||
if (!this.loginValidate()) {
|
||||
return
|
||||
}
|
||||
|
||||
let form = this.getLoginForm()
|
||||
let form = {username, password}
|
||||
|
||||
this.httpPost(User.URL_LOGIN, form, function (response) {
|
||||
|
||||
@@ -233,6 +207,33 @@ export default class User extends BaseEntity {
|
||||
}, errorCallback)
|
||||
}
|
||||
|
||||
httpRegister(username, password, rePassword, successCallback, errorCallback) {
|
||||
|
||||
let that = this
|
||||
|
||||
if (!username) {
|
||||
this.errorMessage = '用户名必填'
|
||||
return
|
||||
}
|
||||
|
||||
if (!password) {
|
||||
this.errorMessage = '密码必填'
|
||||
return
|
||||
}
|
||||
|
||||
if (rePassword !== password) {
|
||||
this.errorMessage = '两次密码输入不一致'
|
||||
return
|
||||
}
|
||||
|
||||
let form = {username, password}
|
||||
|
||||
this.httpPost(User.URL_REGISTER, form, function (response) {
|
||||
that.innerLogin(response)
|
||||
that.safeCallback(successCallback)(response)
|
||||
}, errorCallback)
|
||||
}
|
||||
|
||||
httpLogout(successCallback, errorCallback) {
|
||||
|
||||
let that = this
|
||||
|
||||
@@ -5,7 +5,8 @@ import ShareList from '../../backyard/share/List'
|
||||
import ShareDetail from '../../backyard/share/Detail'
|
||||
import MatterList from '../../backyard/matter/List'
|
||||
import MatterDetail from '../../backyard/matter/Detail'
|
||||
import UserLogin from '../../backyard/user/Login.vue'
|
||||
import UserLogin from '../../backyard/user/Login'
|
||||
import UserRegister from '../../backyard/user/Register'
|
||||
import UserList from '../../backyard/user/List'
|
||||
import UserDetail from '../../backyard/user/Detail'
|
||||
import UserChangePassword from '../../backyard/user/ChangePassword'
|
||||
@@ -44,7 +45,6 @@ const router = new Router({
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
path: 'matter/detail/:uuid',
|
||||
name: 'MatterDetail',
|
||||
@@ -74,6 +74,16 @@ const router = new Router({
|
||||
breadcrumbs: []
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'user/register',
|
||||
name: 'UserRegister',
|
||||
component: UserRegister,
|
||||
meta: {
|
||||
title: '注册',
|
||||
requiresAuth: false,
|
||||
breadcrumbs: []
|
||||
}
|
||||
},
|
||||
{
|
||||
path: 'user/list',
|
||||
name: 'UserList',
|
||||
@@ -183,8 +193,7 @@ const router = new Router({
|
||||
meta: {
|
||||
title: '分享详情',
|
||||
requiresAuth: false,
|
||||
breadcrumbs: [
|
||||
]
|
||||
breadcrumbs: []
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user