Skip to content

Commit

Permalink
feat: use halo install page
Browse files Browse the repository at this point in the history
  • Loading branch information
Gem Xli committed Mar 7, 2021
1 parent 1916294 commit e57ef81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
11 changes: 0 additions & 11 deletions client/pages/error.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,11 @@

<script>
import { defineComponent, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { isSSR } from '~/utils'
export default defineComponent({
setup() {
const errorMsg = ref('')
if (!isSSR) {
const isInstalled = window.__INITIAL_STATE__?.isInstalled
const router = useRouter()
if (!isInstalled) {
router.push('/install')
}
}
onMounted(() => {
errorMsg.value =
window.__INITIAL_STATE__?.storeState?.error || 'Unknown Error'
Expand Down
13 changes: 11 additions & 2 deletions server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import path from 'path'
import { haloAccessKey, haloTarget, isDev } from './config'
import { router } from './router'
import { serveViteBuild, serveViteDev } from './vite'
import { haloProxy } from './halo'
import { checkInstall, haloProxy } from './halo'
import { ViteDevServer } from 'vite'

const url = new URL(haloTarget)
Expand Down Expand Up @@ -44,10 +44,19 @@ async function main() {
.use(haloProxy(proxyConf))

app.use(async (ctx, next) => {
const reqPath = ctx.request.path
if (reqPath.startsWith('/admin')) {
return
}

await next()

if (ctx.status === 500) {
if (ctx.request.path !== '/error') {
const isInstalled = await checkInstall()

if (!isInstalled) {
ctx.redirect('/admin')
} else if (ctx.request.path !== '/error') {
ctx.redirect('/error')
}
}
Expand Down

0 comments on commit e57ef81

Please sign in to comment.