Files
vue-ts-example-2025/src/pages/[...path].page.vue
严浩 e7a4a7aff9
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 3m49s
CI/CD Pipeline / build-and-deploy (push) Successful in 2m27s
fix: 优化404页面返回按钮逻辑
2025-11-02 17:19:16 +08:00

35 lines
683 B
Vue

<script lang="ts" setup>
defineProps<{ path: string }>();
declare global {
interface Window {
stack?: ReturnType<typeof createStackGuard>;
}
}
const stack = window?.stack;
const canGoBack = stack && stack.length > 1;
const router = useRouter();
function handleBack() {
if (canGoBack) {
router.back();
} else {
router.push('/');
}
}
</script>
<template>
<main flex-1 class="flex flex-col items-center justify-center h-full space-y-4">
<h1>Not Found</h1>
<p>{{ path }} does not exist.</p>
<Button @click="handleBack">{{ canGoBack ? 'Back' : 'Home' }}</Button>
</main>
</template>
<route lang="yaml">
props: true
meta:
layout: false
</route>