mirror of https://github.com/halo-dev/halo-admin
fix: Token will cause page jump error when reinstalling Halo (#240)
parent
ad0c8fefb9
commit
65c3894321
|
@ -5,13 +5,25 @@ import {
|
|||
setDocumentTitle,
|
||||
domTitle
|
||||
} from '@/utils/domUtil'
|
||||
import adminApi from '@api/admin'
|
||||
|
||||
const whiteList = ['Login', 'Install', 'NotFound', 'ResetPassword'] // no redirect whitelist
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach(async(to, from, next) => {
|
||||
to.meta && (typeof to.meta.title !== 'undefined' && setDocumentTitle(`${to.meta.title} - ${domTitle}`))
|
||||
Vue.$log.debug('Token', store.getters.token)
|
||||
if (store.getters.token) {
|
||||
if (to.name === 'Install') {
|
||||
next()
|
||||
return
|
||||
}
|
||||
const response = await adminApi.isInstalled()
|
||||
if (!response.data.data) {
|
||||
next({
|
||||
name: 'Install'
|
||||
})
|
||||
return
|
||||
}
|
||||
if (to.name === 'Login') {
|
||||
next({
|
||||
name: 'Dashboard'
|
||||
|
|
|
@ -26,6 +26,21 @@ const user = {
|
|||
}
|
||||
},
|
||||
actions: {
|
||||
installCleanToken({
|
||||
commit
|
||||
}, installData) {
|
||||
return new Promise((resolve, reject) => {
|
||||
adminApi
|
||||
.install(installData)
|
||||
.then(response => {
|
||||
commit('CLEAR_TOKEN')
|
||||
resolve(response)
|
||||
})
|
||||
.catch(error => {
|
||||
reject(error)
|
||||
})
|
||||
})
|
||||
},
|
||||
refreshUserCache({
|
||||
commit
|
||||
}) {
|
||||
|
|
|
@ -216,6 +216,7 @@
|
|||
<script>
|
||||
import adminApi from '@/api/admin'
|
||||
import migrateApi from '@/api/migrate'
|
||||
import { mapActions } from 'vuex'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
|
@ -270,6 +271,7 @@ export default {
|
|||
this.$set(this.installation, 'url', window.location.protocol + '//' + window.location.host)
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['installCleanToken']),
|
||||
async handleVerifyIsInstall() {
|
||||
await adminApi.isInstalled().then((response) => {
|
||||
if (response.data.data) {
|
||||
|
@ -305,8 +307,7 @@ export default {
|
|||
})
|
||||
},
|
||||
install() {
|
||||
adminApi
|
||||
.install(this.installation)
|
||||
this.installCleanToken(this.installation)
|
||||
.then((response) => {
|
||||
this.$log.debug('Installation response', response)
|
||||
this.$message.success('安装成功!')
|
||||
|
|
Loading…
Reference in New Issue