Skip to content

Commit

Permalink
fix: 路由跳转问题
Browse files Browse the repository at this point in the history
  • Loading branch information
dxhuii committed Sep 18, 2023
1 parent 9f72bcb commit 5356055
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
16 changes: 0 additions & 16 deletions composables/count.ts

This file was deleted.

30 changes: 30 additions & 0 deletions error.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script setup>
const props = defineProps({
error: Object,
})
const message = computed(() => String(props.error?.message || ''))
const is404 = computed(() => props.error?.statusCode === 404 || message.value?.includes('404'))
const isDev = process.dev
function handleError() {
return clearError({ redirect: '/' })
}
</script>
<template>
<NuxtLayout>
<div flex="~ col" h-screen text-center items-center justify-center gap4>
<div text-3xl>
{{ is404 ? 'This page could not be found' : 'An error occurred' }}
</div>
<div text-xl op50>
Looks like you've followed a broken link or entered a URL that doesn't exist on this site.
</div>
<pre v-if="isDev">{{ error }}</pre>
<button n-link border px4 py1 rounded @click="handleError">
Go Back
</button>
</div>
</NuxtLayout>
</template>
16 changes: 7 additions & 9 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { pwa } from './config/pwa'

const isDev = process.env.NODE_ENV === 'development'

export default defineNuxtConfig({
modules: [
'@vueuse/nuxt',
Expand All @@ -25,16 +27,12 @@ export default defineNuxtConfig({
colorMode: {
classSuffix: '',
},
routeRules: {
'/**': isDev ? {} : { cache: { swr: true, maxAge: 120, staleMaxAge: 60, headersOnly: true } },
},
nitro: {
esbuild: {
options: {
target: 'esnext',
},
},
prerender: {
crawlLinks: false,
routes: ['/'],
ignore: ['/hi'],
routeRules: {
'/**': { isr: false },
},
},
app: {
Expand Down

0 comments on commit 5356055

Please sign in to comment.