Merge pull request #1029 from h3poteto/iss-1027
closes #1027 Block to root path when user use brower-back
This commit is contained in:
commit
0421674c29
|
@ -1,11 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div id="authorize">
|
<div id="authorize">
|
||||||
<div>
|
<div>
|
||||||
<el-header>
|
<el-header>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24" class="close">
|
<el-col :span="24" class="close">
|
||||||
<el-button type="text" icon="el-icon-close" @click="close" class="close-button">
|
<el-button type="text" icon="el-icon-close" @click="close" class="close-button"> </el-button>
|
||||||
</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-header>
|
</el-header>
|
||||||
|
@ -15,7 +14,14 @@
|
||||||
<p>{{ $t('authorize.manually_2') }}</p>
|
<p>{{ $t('authorize.manually_2') }}</p>
|
||||||
<p class="url">{{ $route.query.url }}</p>
|
<p class="url">{{ $route.query.url }}</p>
|
||||||
</div>
|
</div>
|
||||||
<el-form ref="form" :model="authorizeForm" label-width="120px" label-position="top" class="authorize-form" v-on:submit.prevent="authorizeSubmit">
|
<el-form
|
||||||
|
ref="form"
|
||||||
|
:model="authorizeForm"
|
||||||
|
label-width="120px"
|
||||||
|
label-position="top"
|
||||||
|
class="authorize-form"
|
||||||
|
v-on:submit.prevent="authorizeSubmit"
|
||||||
|
>
|
||||||
<el-form-item :label="$t('authorize.code_label')">
|
<el-form-item :label="$t('authorize.code_label')">
|
||||||
<el-input v-model="authorizeForm.code"></el-input>
|
<el-input v-model="authorizeForm.code"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -24,18 +30,14 @@
|
||||||
<el-input></el-input>
|
<el-input></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item class="submit">
|
<el-form-item class="submit">
|
||||||
<el-button
|
<el-button type="primary" @click="authorizeSubmit" v-loading="submitting" element-loading-background="rgba(0, 0, 0, 0.8)">
|
||||||
type="primary"
|
|
||||||
@click="authorizeSubmit"
|
|
||||||
v-loading="submitting"
|
|
||||||
element-loading-background="rgba(0, 0, 0, 0.8)">
|
|
||||||
{{ $t('authorize.submit') }}
|
{{ $t('authorize.submit') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-main>
|
</el-main>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -47,7 +49,7 @@ export default {
|
||||||
default: ''
|
default: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data () {
|
data() {
|
||||||
return {
|
return {
|
||||||
authorizeForm: {
|
authorizeForm: {
|
||||||
code: ''
|
code: ''
|
||||||
|
@ -55,20 +57,21 @@ export default {
|
||||||
submitting: false
|
submitting: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted() {
|
||||||
console.log(this.url)
|
console.log(this.url)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
authorizeSubmit () {
|
authorizeSubmit() {
|
||||||
this.submitting = true
|
this.submitting = true
|
||||||
this.$store.dispatch('Authorize/submit', this.authorizeForm.code)
|
this.$store
|
||||||
|
.dispatch('Authorize/submit', this.authorizeForm.code)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.submitting = false
|
this.submitting = false
|
||||||
})
|
})
|
||||||
.then((id) => {
|
.then(id => {
|
||||||
this.$router.push({ path: `/${id}/home` })
|
this.$router.push({ path: `/${id}/home` })
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch(err => {
|
||||||
if (err.name === 'DuplicateRecordError') {
|
if (err.name === 'DuplicateRecordError') {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.authorize_duplicate_error'),
|
message: this.$t('message.authorize_duplicate_error'),
|
||||||
|
@ -82,8 +85,8 @@ export default {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
close () {
|
close() {
|
||||||
return this.$router.push({ path: '/' })
|
return this.$router.push({ path: '/', query: { redirect: 'home' } })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<el-container id="login">
|
<el-container id="login">
|
||||||
<el-header>
|
<el-header>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24" class="close">
|
<el-col :span="24" class="close">
|
||||||
<el-button type="text" icon="el-icon-close" @click="close" class="close-button">
|
<el-button type="text" icon="el-icon-close" @click="close" class="close-button"> </el-button>
|
||||||
</el-button>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-header>
|
</el-header>
|
||||||
|
@ -12,7 +11,7 @@
|
||||||
<div v-shortkey="['esc']" @shortkey="close"></div>
|
<div v-shortkey="['esc']" @shortkey="close"></div>
|
||||||
<login-form></login-form>
|
<login-form></login-form>
|
||||||
</el-container>
|
</el-container>
|
||||||
</el-container>
|
</el-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -28,9 +27,9 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
close () {
|
close() {
|
||||||
this.$store.dispatch('Login/pageBack')
|
this.$store.dispatch('Login/pageBack')
|
||||||
return this.$router.push({ path: '/' })
|
return this.$router.push({ path: '/', query: { redirect: 'home' } })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
class="setting-menu"
|
class="setting-menu"
|
||||||
:text-color="primaryColor"
|
:text-color="primaryColor"
|
||||||
:background-color="backgroundColor"
|
:background-color="backgroundColor"
|
||||||
:router="true">
|
:router="true"
|
||||||
|
>
|
||||||
<el-menu-item index="/preferences/general">
|
<el-menu-item index="/preferences/general">
|
||||||
<icon name="cog" class="icon" scale="1.3"></icon>
|
<icon name="cog" class="icon" scale="1.3"></icon>
|
||||||
<span>{{ $t('preferences.general.title') }}</span>
|
<span>{{ $t('preferences.general.title') }}</span>
|
||||||
|
@ -60,10 +61,10 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
close () {
|
close() {
|
||||||
this.$router.push('/')
|
this.$router.push({ path: '/', query: { redirect: 'home' } })
|
||||||
},
|
},
|
||||||
activeRoute () {
|
activeRoute() {
|
||||||
return this.$route.path
|
return this.$route.path
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,13 @@ const actions: ActionTree<GlobalHeaderState, RootState> = {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
const accounts = await dispatch('listAccounts')
|
const accounts = await dispatch('listAccounts')
|
||||||
|
// Block to root path when user use browser-back, like mouse button.
|
||||||
|
// Because any contents are not rendered when browser back to / from home.
|
||||||
|
router.beforeEach((to, from, next) => {
|
||||||
|
if (!(to.fullPath === '/' && from.name)) {
|
||||||
|
return next()
|
||||||
|
}
|
||||||
|
})
|
||||||
return accounts
|
return accounts
|
||||||
},
|
},
|
||||||
startStreamings: async ({ dispatch }) => {
|
startStreamings: async ({ dispatch }) => {
|
||||||
|
|
Loading…
Reference in New Issue