feat: create BaseTabs component

This commit is contained in:
Tim
2025-08-27 12:26:35 +08:00
parent 013d47e8e4
commit 0fc1415a14
6 changed files with 160 additions and 145 deletions

View File

@@ -1,15 +1,16 @@
<template>
<div class="about-page">
<div class="about-tabs">
<div
v-for="tab in tabs"
:key="tab.name"
:class="['about-tabs-item', { selected: selectedTab === tab.name }]"
@click="selectTab(tab.name)"
>
<BaseTabs
v-model="selectedTab"
:tabs="tabs"
class="about-tabs"
item-class="about-tabs-item"
active-class="selected"
>
<template #tab="{ tab }">
<div class="about-tabs-item-label">{{ tab.label }}</div>
</div>
</div>
</template>
</BaseTabs>
<div class="about-loading" v-if="isFetching">
<l-hatch-spinner size="100" stroke="10" speed="1" color="var(--primary-color)" />
</div>
@@ -23,11 +24,13 @@
</template>
<script>
import { onMounted, ref } from 'vue'
import { ref, watch } from 'vue'
import BaseTabs from '~/components/BaseTabs.vue'
import { handleMarkdownClick, renderMarkdown } from '~/utils/markdown'
export default {
name: 'AboutPageView',
components: { BaseTabs },
setup() {
const isFetching = ref(false)
const tabs = [
@@ -71,21 +74,20 @@ export default {
}
}
const selectTab = (name) => {
selectedTab.value = name
const tab = tabs.find((t) => t.name === name)
if (tab) loadContent(tab.file)
}
onMounted(() => {
loadContent(tabs[0].file)
})
watch(
selectedTab,
(name) => {
const tab = tabs.find((t) => t.name === name)
if (tab) loadContent(tab.file)
},
{ immediate: true },
)
const handleContentClick = (e) => {
handleMarkdownClick(e)
}
return { tabs, selectedTab, content, renderMarkdown, selectTab, isFetching, handleContentClick }
return { tabs, selectedTab, content, renderMarkdown, isFetching, handleContentClick }
},
}
</script>