fix: 优化404页面返回按钮逻辑
All checks were successful
CI/CD Pipeline / playwright (push) Successful in 3m49s
CI/CD Pipeline / build-and-deploy (push) Successful in 2m27s

This commit is contained in:
严浩
2025-11-02 17:19:16 +08:00
parent 0d1a20d88d
commit e7a4a7aff9

View File

@@ -1,11 +1,29 @@
<script lang="ts" setup> <script lang="ts" setup>
defineProps<{ path: string }>(); 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> </script>
<template> <template>
<main flex-1 class="flex flex-col items-center justify-center h-full space-y-4"> <main flex-1 class="flex flex-col items-center justify-center h-full space-y-4">
<h1>Not Found</h1> <h1>Not Found</h1>
<p>{{ path }} does not exist.</p> <p>{{ path }} does not exist.</p>
<Button @click="$router.back()">Back</Button> <Button @click="handleBack">{{ canGoBack ? 'Back' : 'Home' }}</Button>
</main> </main>
</template> </template>