yuanjing/src/components/video/VideoTab.vue
2026-04-09 15:04:36 +08:00

94 lines
1.8 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div>
<div class="tabs-container ">
<div
class="tab-item"
:class="{ active: activeTab === 'reference' }"
@click="switchTab('reference')"
>
参考生视频
</div>
<div
class="tab-item"
:class="{ active: activeTab === 'image' }"
@click="switchTab('image')"
>
图生视频
</div>
<div
class="tab-item"
:class="{ active: activeTab === 'text' }"
@click="switchTab('text')"
>
文生视频
</div>
</div>
</div>
</template>
<script setup lang='ts'>
// 定义 Tab 类型,与父组件保持一致
type TabType = 'reference' | 'image' | 'text';
// 接收父组件传递的 activeTab使用联合类型
defineProps<{
activeTab: TabType;
}>();
// 定义事件tab 参数同样使用联合类型
const emit = defineEmits<{
(e: 'tabChange', tab: TabType): void;
}>();
// 切换 tab
const switchTab = (tab: TabType) => {
emit('tabChange', tab);
};
</script>
<style scoped lang='less'>
.tabs-container {
width: 100%;
height: 44x;
display: flex;
background-color: #1a1c20;
border-radius: 12px;
overflow: hidden;
margin-bottom: 16px;
}
.tab-item {
width: 50%;
flex: 1;
padding: 12px 0;
background: transparent;
border: none;
color: rgba(255, 255, 255, 0.6);
font-size: 14px;
font-weight: 500;
cursor: pointer;
transition: all 0.3s;
text-align: center;
position: relative;
}
.tab-item:hover {
color: #fff;
background-color: rgba(255, 255, 255, 0.08);
}
.tab-item.active {
color: #fff;
background-color: rgba(255, 255, 255, 0.15);
}
.tab-item.active::after {
content: '';
position: absolute;
bottom: 0;
left: 20%;
width: 60%;
height: 2px;
border-radius: 2px;
}
</style>