Whalebird-desktop-client-ma.../src/renderer/components/Authorize.vue

111 lines
2.4 KiB
Vue
Raw Normal View History

2018-03-08 09:41:39 +01:00
<template>
<div id="authorize">
<el-header>
<el-row>
<el-col :span="24" class="close">
<el-button type="text" icon="el-icon-close" @click="close" class="close-button">
</el-button>
</el-col>
</el-row>
</el-header>
<el-container>
<el-form ref="form" :model="authorizeForm" label-width="120px" label-position="top" class="authorize-form" v-on:submit.prevent="authorizeSubmit">
<el-form-item label="Please paste authorization code from your browser:">
<el-input v-model="authorizeForm.code"></el-input>
</el-form-item>
<!-- Dummy form to guard submitting with enter -->
<el-form-item class="hidden">
<el-input></el-input>
</el-form-item>
<el-form-item class="submit">
<el-button
type="primary"
@click="authorizeSubmit"
v-loading="submitting"
element-loading-background="rgba(0, 0, 0, 0.8)">
Submit
</el-button>
</el-form-item>
</el-form>
</el-container>
2018-03-08 09:41:39 +01:00
</div>
</template>
<script>
export default {
name: 'authorize',
data () {
return {
authorizeForm: {
code: ''
},
submitting: false
2018-03-08 09:41:39 +01:00
}
},
methods: {
authorizeSubmit () {
this.submitting = true
2018-03-08 09:41:39 +01:00
this.$store.dispatch('Authorize/submit', this.authorizeForm.code)
.finally(() => {
this.submitting = false
})
.then((id) => {
this.$router.push({ path: `/${id}/home` })
})
.catch((err) => {
if (err.name === 'DuplicateRecordError') {
this.$message({
message: 'Can not login the same account of the same domain',
type: 'error'
})
} else {
this.$message({
message: 'Failed to authorize',
type: 'error'
})
}
2018-03-13 14:25:31 +01:00
})
},
close () {
return this.$router.push({ path: '/' })
2018-03-08 09:41:39 +01:00
}
}
}
</script>
<style lang="scss" scoped>
#authorize /deep/ {
2018-03-10 15:11:27 +01:00
background-color: #292f3f;
color: #ffffff;
2018-03-08 09:41:39 +01:00
text-align: center;
min-height: 100%;
2018-03-10 15:11:27 +01:00
.close {
text-align: right;
.close-button {
font-size: 24px;
}
}
2018-03-10 15:11:27 +01:00
.authorize-form {
width: 500px;
margin: 0 auto;
}
.el-form-item__label {
color: #f0f3f9;
}
.el-input__inner {
background-color: #373d48;
color: #ffffff;
border: 0;
}
.hidden {
display: none;
}
2018-03-08 09:41:39 +01:00
}
</style>