feat: 添加后退按钮组件并更新认证路由和视图
This commit is contained in:
28
src/components/back-button.vue
Normal file
28
src/components/back-button.vue
Normal file
@@ -0,0 +1,28 @@
|
||||
<script lang='ts' setup>
|
||||
import { chevronBackOutline } from "ionicons/icons";
|
||||
|
||||
const { text = "返回" } = defineProps<{
|
||||
text?: string;
|
||||
}>();
|
||||
const router = useRouter();
|
||||
|
||||
function onBack() {
|
||||
if (window.history.length > 1) {
|
||||
router.back();
|
||||
}
|
||||
else {
|
||||
router.replace("/");
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button class="z-1 flex items-center" @click="onBack">
|
||||
<slot name="icon">
|
||||
<ion-icon :icon="chevronBackOutline" class="text-2xl" />
|
||||
</slot>
|
||||
<span v-if="text" class="text-base">{{ text }}</span>
|
||||
</button>
|
||||
</template>
|
||||
|
||||
<style lang='css' scoped></style>
|
||||
Reference in New Issue
Block a user