Merge pull request #1029 from h3poteto/iss-1027

closes #1027 Block to root path when user use brower-back
This commit is contained in:
AkiraFukushima 2019-09-06 00:53:36 +09:00 committed by GitHub
commit 0421674c29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 63 deletions

View File

@ -4,8 +4,7 @@
<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,11 +30,7 @@
<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>
@ -61,14 +63,15 @@ export default {
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'),
@ -83,7 +86,7 @@ export default {
}) })
}, },
close() { close() {
return this.$router.push({ path: '/' }) return this.$router.push({ path: '/', query: { redirect: 'home' } })
} }
} }
} }

View File

@ -3,8 +3,7 @@
<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>
@ -30,7 +29,7 @@ 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' } })
} }
} }
} }

View File

@ -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>
@ -61,7 +62,7 @@ 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

View File

@ -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 }) => {