ai-cut/app/components/base/BaseBackButton.vue

25 lines
574 B
Vue
Raw Normal View History

2025-12-16 10:08:51 +00:00
<template>
<button
@click="handleBack"
class="flex items-center gap-2 px-4 py-2 text-gray-700 hover:bg-gray-100 rounded-lg transition-colors"
>
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
<span>返回</span>
</button>
</template>
<script setup lang="ts">
const router = useRouter()
function handleBack() {
if (window.history.length > 1) {
router.back()
} else {
router.push('/')
}
}
</script>