mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-11 21:27:31 +08:00
feat: create BaseTabs component
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user