feat: 添加自定义返回按钮组件并替换现有页面中的返回按钮

This commit is contained in:
2025-12-27 20:38:55 +07:00
parent b355519671
commit 03c923e9d2
24 changed files with 49 additions and 22 deletions

View File

@@ -0,0 +1,26 @@
<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">
<ion-icon :icon="chevronBackOutline" class="text-2xl" />
<span v-if="text" class="text-base">{{ text }}</span>
</button>
</template>
<style lang='css' scoped></style>

View File

@@ -35,5 +35,6 @@ declare module "vue" {
UiTabs: typeof import("./tabs/index.vue")["default"];
UiTag: typeof import("./tag/index.vue")["default"];
UiTextareaLabel: typeof import("./textarea-label/index.vue")["default"];
UiBackButton: typeof import("./back-button/index.vue")["default"];
}
}