登录界面添加记住用户名功能
This commit is contained in:
parent
b9f5a026d8
commit
ff9858a7cb
1
src/assets/js/prefixfree.min.js
vendored
1
src/assets/js/prefixfree.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
"use strict";"object"!=typeof window.CP&&(window.CP={}),window.CP.PenTimer={programNoLongerBeingMonitored:!1,timeOfFirstCallToShouldStopLoop:0,_loopExits:{},_loopTimers:{},START_MONITORING_AFTER:2e3,STOP_ALL_MONITORING_TIMEOUT:5e3,MAX_TIME_IN_LOOP_WO_EXIT:2200,exitedLoop:function(o){this._loopExits[o]=!0},shouldStopLoop:function(o){if(this.programKilledSoStopMonitoring)return!0;if(this.programNoLongerBeingMonitored)return!1;if(this._loopExits[o])return!1;var t=this._getTime();if(0===this.timeOfFirstCallToShouldStopLoop)return this.timeOfFirstCallToShouldStopLoop=t,!1;var i=t-this.timeOfFirstCallToShouldStopLoop;if(i<this.START_MONITORING_AFTER)return!1;if(i>this.STOP_ALL_MONITORING_TIMEOUT)return this.programNoLongerBeingMonitored=!0,!1;try{this._checkOnInfiniteLoop(o,t)}catch(n){return this._sendErrorMessageToEditor(),this.programKilledSoStopMonitoring=!0,!0}return!1},_sendErrorMessageToEditor:function(){try{if(this._shouldPostMessage()){var o={action:"infinite-loop",line:this._findAroundLineNumber()};parent.postMessage(JSON.stringify(o),"*")}else this._throwAnErrorToStopPen()}catch(t){this._throwAnErrorToStopPen()}},_shouldPostMessage:function(){return document.location.href.match(/boomerang/)},_throwAnErrorToStopPen:function(){throw"We found an infinite loop in your Pen. We've stopped the Pen from running. Please correct it or contact support@codepen.io."},_findAroundLineNumber:function(){var o=new Error,t=0;if(o.stack){var i=o.stack.match(/boomerang\S+:(\d+):\d+/);i&&(t=i[1])}return t},_checkOnInfiniteLoop:function(o,t){if(!this._loopTimers[o])return this._loopTimers[o]=t,!1;var i=t-this._loopTimers[o];if(i>this.MAX_TIME_IN_LOOP_WO_EXIT)throw"Infinite Loop found on loop: "+o},_getTime:function(){return+new Date}},window.CP.shouldStopExecution=function(o){return window.CP.PenTimer.shouldStopLoop(o)},window.CP.exitedLoop=function(o){window.CP.PenTimer.exitedLoop(o)};
|
|
||||||
@ -2,7 +2,7 @@
|
|||||||
<div class="dashboard-container" v-resize="containerResize">
|
<div class="dashboard-container" v-resize="containerResize">
|
||||||
<el-breadcrumb class="app-breadcrumb" separator="">
|
<el-breadcrumb class="app-breadcrumb" separator="">
|
||||||
<transition-group name="breadcrumb" v-if="showNavigation">
|
<transition-group name="breadcrumb" v-if="showNavigation">
|
||||||
<el-breadcrumb-item v-for="(item,index) in pathList" :key="index">
|
<el-breadcrumb-item v-for="(item,index) in pathList" :key="item.folder+index">
|
||||||
<el-tooltip v-if="index===0 && pathList.length > 1" class="item" effect="dark" content="返回上一级" placement="top">
|
<el-tooltip v-if="index===0 && pathList.length > 1" class="item" effect="dark" content="返回上一级" placement="top">
|
||||||
<a @click.prevent="lastLink()"><svg-icon icon-class="back" style="font-size: 24px;"/> </a>
|
<a @click.prevent="lastLink()"><svg-icon icon-class="back" style="font-size: 24px;"/> </a>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import { login, logout, getInfo } from '@/api/user'
|
import { login, logout, getInfo } from '@/api/user'
|
||||||
import { getToken, setToken, getConsumerId, setConsumerId, removeToken, removeConsumerId } from '@/utils/auth'
|
import { getToken, setToken, getConsumerId, setConsumerId, removeToken, removeConsumerId , setRememberName, removeRememberName } from '@/utils/auth'
|
||||||
import { resetRouter } from '@/router'
|
import { resetRouter } from '@/router'
|
||||||
|
|
||||||
const getDefaultState = () => {
|
const getDefaultState = () => {
|
||||||
@ -34,7 +34,7 @@ const mutations = {
|
|||||||
const actions = {
|
const actions = {
|
||||||
// user login
|
// user login
|
||||||
login({ commit }, userInfo) {
|
login({ commit }, userInfo) {
|
||||||
const { username, password } = userInfo
|
const { username, password, rememberMe } = userInfo
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
login({ username: username.trim(), password: password }).then(response => {
|
login({ username: username.trim(), password: password }).then(response => {
|
||||||
const { data } = response
|
const { data } = response
|
||||||
@ -42,6 +42,11 @@ const actions = {
|
|||||||
setToken(data.token)
|
setToken(data.token)
|
||||||
commit('SET_USERID', data.userId)
|
commit('SET_USERID', data.userId)
|
||||||
setConsumerId(data.userId)
|
setConsumerId(data.userId)
|
||||||
|
if(rememberMe){
|
||||||
|
setRememberName(username)
|
||||||
|
} else {
|
||||||
|
removeRememberName()
|
||||||
|
}
|
||||||
resolve()
|
resolve()
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
reject(error)
|
reject(error)
|
||||||
|
|||||||
@ -2,6 +2,19 @@ import Cookies from 'js-cookie'
|
|||||||
|
|
||||||
const TokenKey = 'jmal_token'
|
const TokenKey = 'jmal_token'
|
||||||
const consumerId = 'consumerId'
|
const consumerId = 'consumerId'
|
||||||
|
const rememberName = 'rememberName'
|
||||||
|
|
||||||
|
export function getRememberName() {
|
||||||
|
return Cookies.get(rememberName)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function setRememberName(username) {
|
||||||
|
return Cookies.set(rememberName, username)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function removeRememberName() {
|
||||||
|
return Cookies.remove(rememberName)
|
||||||
|
}
|
||||||
|
|
||||||
export function getToken() {
|
export function getToken() {
|
||||||
return Cookies.get(TokenKey)
|
return Cookies.get(TokenKey)
|
||||||
|
|||||||
@ -52,6 +52,11 @@
|
|||||||
</span>
|
</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item class="remember">
|
||||||
|
<!--<el-switch v-model="loginForm.rememberMe"></el-switch>-->
|
||||||
|
<el-checkbox label="记住我" v-model="loginForm.rememberMe"></el-checkbox>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item v-if="initialize" prop="confirmPassword">
|
<el-form-item v-if="initialize" prop="confirmPassword">
|
||||||
<span class="svg-container">
|
<span class="svg-container">
|
||||||
<svg-icon icon-class="password" />
|
<svg-icon icon-class="password" />
|
||||||
@ -86,11 +91,8 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import { validUsername } from '@/utils/validate'
|
import { hasUser, initialization } from '@/api/user'
|
||||||
import $ from 'jquery'
|
import { getRememberName } from '@/utils/auth'
|
||||||
require('@/assets/js/prefixfree.min.js')
|
|
||||||
require('@/assets/js/stopExecutionOnTimeout.js')
|
|
||||||
import {hasUser,initialization} from '@/api/user'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Login',
|
name: 'Login',
|
||||||
@ -122,6 +124,7 @@ export default {
|
|||||||
loginForm: {
|
loginForm: {
|
||||||
username: '',
|
username: '',
|
||||||
password: '',
|
password: '',
|
||||||
|
rememberMe: false,
|
||||||
confirmPassword: ''
|
confirmPassword: ''
|
||||||
},
|
},
|
||||||
loginRules: {
|
loginRules: {
|
||||||
@ -156,27 +159,11 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
var stars = 800;
|
let rememberName = getRememberName()
|
||||||
var $stars = $('.stars');
|
if(rememberName){
|
||||||
var r = 800;
|
this.loginForm.username = rememberName
|
||||||
for (var i = 0; i < stars; i++) {
|
this.loginForm.rememberMe = true
|
||||||
if (window.CP.shouldStopExecution(1)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
var $star = $('<div/>').addClass('star');
|
|
||||||
$stars.append($star);
|
|
||||||
}
|
}
|
||||||
window.CP.exitedLoop(1);
|
|
||||||
$('.star').each(function () {
|
|
||||||
var cur = $(this);
|
|
||||||
var s = 0.2 + Math.random() * 1;
|
|
||||||
var curR = r + Math.random() * 300;
|
|
||||||
cur.css({
|
|
||||||
transformOrigin: '0 0 ' + curR + 'px',
|
|
||||||
transform: ' translate3d(0,0,-' + curR + 'px) rotateY(' + Math.random() * 360 + 'deg) rotateX(' + Math.random() * -50 + 'deg) scale(' + s + ',' + s + ')'
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showPwd() {
|
showPwd() {
|
||||||
@ -284,6 +271,12 @@ $cursor: #409eff;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.remember {
|
||||||
|
border: unset!important;
|
||||||
|
text-align: start;
|
||||||
|
margin-top: 22px;
|
||||||
|
margin-bottom: -20px;
|
||||||
|
}
|
||||||
.el-form-item {
|
.el-form-item {
|
||||||
border: 1px solid #d9d9d9;
|
border: 1px solid #d9d9d9;
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user