1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-13 23:20:12 +08:00

fix: Console error when login redirect to window. (#412)

* fix: Console error when login redirect.

* Update file.
This commit is contained in:
Edwin Betancourt 2020-03-24 21:28:51 -04:00 committed by GitHub
parent 83081b6d6d
commit 8258da6001
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 76 additions and 73 deletions

View File

@ -326,14 +326,14 @@ export default {
computed: { computed: {
getterContextMenu() { getterContextMenu() {
const process = this.$store.getters.getContextMenu(this.containerUuid) const process = this.$store.getters.getContextMenu(this.containerUuid)
if (process) { if (process && !this.isEmptyValue(process.actions)) {
return process.actions.filter(menu => { return process.actions.filter(menu => {
if (menu.type === 'process' || menu.type === 'application') { if (menu.type === 'process' || menu.type === 'application') {
return menu return menu
} }
}) })
} }
return false return []
}, },
getShowContextMenuTable() { getShowContextMenuTable() {
return this.$store.getters.getShowContextMenuTable return this.$store.getters.getShowContextMenuTable

View File

@ -22,16 +22,17 @@
> >
{{ $t('table.dataTable.deleteSelection') }} {{ $t('table.dataTable.deleteSelection') }}
</el-menu-item> </el-menu-item>
<el-menu-item <template v-if="isPanelWindow && !isEmptyValue(processMenu)">
v-for="(process, key) in processMenu" <el-menu-item
v-show="isPanelWindow && processMenu" v-for="(process, key) in processMenu"
:key="key" :key="key"
:disabled="process.type === 'application' ? false : Boolean(getDataSelection.length < 1)" :disabled="process.type === 'application' ? false : Boolean(getDataSelection.length < 1)"
index="process" index="process"
@click="process.type === 'application' ? sortTab(process) : showModalTable(process)" @click="process.type === 'application' ? sortTab(process) : showModalTable(process)"
> >
{{ process.name }} {{ process.name }}
</el-menu-item> </el-menu-item>
</template>
<el-menu-item <el-menu-item
@click="exporZipRecordTable" @click="exporZipRecordTable"
> >

View File

@ -40,7 +40,7 @@
{{ $t('login.submit') }} {{ $t('login.submit') }}
</el-button> </el-button>
<el-button type="text" style="float: left" @click.native.prevent="$router.push({ path: 'login' })"> <el-button type="text" style="float: left" @click.native.prevent="pathRedirect('login')">
{{ $t('login.title') }} {{ $t('login.title') }}
</el-button> </el-button>
</el-form> </el-form>
@ -48,11 +48,11 @@
</template> </template>
<script> <script>
import LangSelect from '@/components/LangSelect' import { loginMixin } from '@/views/login/loginMixin'
export default { export default {
name: 'ForgotPassword', name: 'ForgotPassword',
components: { LangSelect }, mixins: [loginMixin],
data() { data() {
return { return {
forgotForm: { forgotForm: {
@ -65,11 +65,6 @@ export default {
} }
}, },
methods: { methods: {
showPwd() {
this.$nextTick(() => {
this.$refs.userName.focus()
})
},
handleSubmit() { handleSubmit() {
if (!this.isEmptyValue(this.forgotForm.userName)) { if (!this.isEmptyValue(this.forgotForm.userName)) {
this.loading = true this.loading = true

View File

@ -59,14 +59,14 @@
<el-button <el-button
type="text" type="text"
style="float: left" style="float: left"
@click.native.prevent="$router.push({ path: 'forgotPassword' })" @click.native.prevent="pathRedirect('forgotPassword')"
> >
{{ $t('route.forgotPassword') }} {{ $t('route.forgotPassword') }}
</el-button> </el-button>
<el-button <el-button
type="text" type="text"
style="float: right" style="float: right"
@click.native.prevent="$router.push({ path: 'userEnrollment' })" @click.native.prevent="pathRedirect('userEnrollment')"
> >
{{ $t('route.userEnrollment') }} {{ $t('route.userEnrollment') }}
</el-button> </el-button>
@ -94,12 +94,13 @@
</template> </template>
<script> <script>
import LangSelect from '@/components/LangSelect' import { loginMixin } from '@/views/login/loginMixin'
import SocialSign from './components/SocialSignin' import SocialSign from './components/SocialSignin'
export default { export default {
name: 'Login', name: 'Login',
components: { LangSelect, SocialSign }, components: { SocialSign },
mixins: [loginMixin],
data() { data() {
const validateUsername = (rule, value, callback) => { const validateUsername = (rule, value, callback) => {
if ((value.trim()).length < 1) { if ((value.trim()).length < 1) {
@ -165,16 +166,6 @@ export default {
this.capsTooltip = false this.capsTooltip = false
} }
}, },
showPwd() {
if (this.passwordType === 'password') {
this.passwordType = ''
} else {
this.passwordType = 'password'
}
this.$nextTick(() => {
this.$refs.password.focus()
})
},
handleLogin() { handleLogin() {
this.$refs.loginForm.validate(valid => { this.$refs.loginForm.validate(valid => {
if (valid) { if (valid) {
@ -186,11 +177,12 @@ export default {
}) })
}) })
.catch(error => { .catch(error => {
let message = this.$t('login.unexpectedError')
if (error.code === 13) { if (error.code === 13) {
this.$message.error(this.$t('login.invalidLogin')) message = this.$t('login.invalidLogin')
} else {
this.$message.error(this.$t('login.unexpectedError'))
} }
this.$message.error(message)
}) })
.finally(() => { .finally(() => {
this.loading = false this.loading = false

View File

@ -0,0 +1,25 @@
import LangSelect from '@/components/LangSelect'
export const loginMixin = {
name: 'loginMixin',
components: {
LangSelect
},
methods: {
showPwd() {
if (this.passwordType === 'password') {
this.passwordType = ''
} else {
this.passwordType = 'password'
}
this.$nextTick(() => {
this.$refs.password.focus()
})
},
pathRedirect(path) {
this.$router.push({
path
})
}
}
}

View File

@ -31,7 +31,7 @@
@keyup.native="checkCapslock" @keyup.native="checkCapslock"
@blur="capsTooltip = false" @blur="capsTooltip = false"
/> />
<span class="show-pwd" @click="showPassword"> <span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span> </span>
</el-form-item> </el-form-item>
@ -61,7 +61,7 @@
</el-tooltip> </el-tooltip>
<el-button <el-button
:disabled="isEmptyValue(changePasswordForm.password) || changePasswordForm.password !== changePasswordForm.passwordConfirm" :disabled="isDisabled"
:loading="loading" :loading="loading"
type="primary" type="primary"
style="width:100%;margin-bottom:30px;" style="width:100%;margin-bottom:30px;"
@ -70,7 +70,7 @@
{{ $t('login.submit') }} {{ $t('login.submit') }}
</el-button> </el-button>
<el-button type="text" style="float: left" @click.native.prevent="$router.push({ path: 'login' })"> <el-button type="text" style="float: left" @click.native.prevent="pathRedirect('login')">
{{ $t('login.title') }} {{ $t('login.title') }}
</el-button> </el-button>
</el-form> </el-form>
@ -78,11 +78,11 @@
</template> </template>
<script> <script>
import LangSelect from '@/components/LangSelect' import { loginMixin } from '@/views/login/loginMixin'
export default { export default {
name: 'ChangePassword', name: 'ChangePassword',
components: { LangSelect }, mixins: [loginMixin],
data() { data() {
const validatePass = (rule, value, callback) => { const validatePass = (rule, value, callback) => {
if (this.isEmptyValue(value)) { if (this.isEmptyValue(value)) {
@ -119,6 +119,15 @@ export default {
computed: { computed: {
formName() { formName() {
return this.$route.name return this.$route.name
},
isDisabled() {
if (this.isEmptyValue(this.changePasswordForm.password)) {
return true
}
if (this.changePasswordForm.password !== this.changePasswordForm.passwordConfirm) {
return true
}
return false
} }
}, },
methods: { methods: {
@ -141,17 +150,7 @@ export default {
} }
}, },
checkCapslockNew({ shiftKey, key } = {}, isNew = true) { checkCapslockNew({ shiftKey, key } = {}, isNew = true) {
this.checkCapslock({ shiftKey: shiftKey, key: key }, true) this.checkCapslock({ shiftKey, key }, true)
},
showPassword() {
if (this.passwordType === 'password') {
this.passwordType = ''
} else {
this.passwordType = 'password'
}
this.$nextTick(() => {
this.$refs.password.focus()
})
}, },
showPasswordConfirm() { showPasswordConfirm() {
if (this.passwordConfirmType === 'password') { if (this.passwordConfirmType === 'password') {

View File

@ -71,7 +71,7 @@
@keyup.native="checkCapslock" @keyup.native="checkCapslock"
@blur="capsTooltip = false" @blur="capsTooltip = false"
/> />
<span class="show-pwd" @click="showPassword"> <span class="show-pwd" @click="showPwd">
<svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" /> <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
</span> </span>
</el-form-item> </el-form-item>
@ -110,7 +110,7 @@
{{ $t('login.submit') }} {{ $t('login.submit') }}
</el-button> </el-button>
<el-button type="text" style="float: left" @click.native.prevent="$router.push({ path: 'login' })"> <el-button type="text" style="float: left" @click.native.prevent="pathRedirect('login')">
{{ $t('login.title') }} {{ $t('login.title') }}
</el-button> </el-button>
</el-form> </el-form>
@ -118,11 +118,11 @@
</template> </template>
<script> <script>
import LangSelect from '@/components/LangSelect' import { loginMixin } from '@/views/login/loginMixin'
export default { export default {
name: 'UserEnrollment', name: 'UserEnrollment',
components: { LangSelect }, mixins: [loginMixin],
data() { data() {
const validateField = (rule, value, callback) => { const validateField = (rule, value, callback) => {
if (this.isEmptyValue(value)) { if (this.isEmptyValue(value)) {
@ -189,20 +189,21 @@ export default {
}, },
computed: { computed: {
isReadyFormSubmit() { isReadyFormSubmit() {
if (this.isEmptyValue(this.enrollmentUserForm.name)) { const { name, userName, eMail, password, passwordConfirm } = this.enrollmentUserForm
if (this.isEmptyValue(name)) {
return false return false
} }
if (this.isEmptyValue(this.enrollmentUserForm.userName)) { if (this.isEmptyValue(userName)) {
return false return false
} }
if (this.isEmptyValue(this.enrollmentUserForm.eMail) || !this.eMailPattern.test(this.enrollmentUserForm.eMail)) { if (this.isEmptyValue(eMail) || !this.eMailPattern.test(eMail)) {
return false return false
} }
if (this.isShowPassword) { if (this.isShowPassword) {
if (this.isEmptyValue(this.enrollmentUserForm.password)) { if (this.isEmptyValue(password)) {
return false return false
} }
if (this.enrollmentUserForm.password !== this.enrollmentUserForm.passwordConfirm) { if (password !== passwordConfirm) {
return false return false
} }
} }
@ -229,17 +230,7 @@ export default {
} }
}, },
checkCapslockNew({ shiftKey, key } = {}, isNew = true) { checkCapslockNew({ shiftKey, key } = {}, isNew = true) {
this.checkCapslock({ shiftKey: shiftKey, key: key }, true) this.checkCapslock({ shiftKey, key }, true)
},
showPassword() {
if (this.passwordType === 'password') {
this.passwordType = ''
} else {
this.passwordType = 'password'
}
this.$nextTick(() => {
this.$refs.password.focus()
})
}, },
showPasswordConfirm() { showPasswordConfirm() {
if (this.passwordConfirmType === 'password') { if (this.passwordConfirmType === 'password') {