mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-06-06 01:57:34 +08:00
feat: 首刷返回
This commit is contained in:
@@ -71,7 +71,7 @@
|
|||||||
<div v-if="isLoadingCategory" class="menu-loading-container">
|
<div v-if="isLoadingCategory" class="menu-loading-container">
|
||||||
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
|
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
|
||||||
</div>
|
</div>
|
||||||
<div v-else v-for="c in categories" :key="c.id" class="section-item" @click="gotoCategory(c)">
|
<div v-else v-for="c in categoryData" :key="c.id" class="section-item" @click="gotoCategory(c)">
|
||||||
<template v-if="c.smallIcon || c.icon">
|
<template v-if="c.smallIcon || c.icon">
|
||||||
<img v-if="isImageIcon(c.smallIcon || c.icon)" :src="c.smallIcon || c.icon" class="section-item-icon" :alt="c.name" />
|
<img v-if="isImageIcon(c.smallIcon || c.icon)" :src="c.smallIcon || c.icon" class="section-item-icon" :alt="c.name" />
|
||||||
<i v-else :class="['section-item-icon', c.smallIcon || c.icon]"></i>
|
<i v-else :class="['section-item-icon', c.smallIcon || c.icon]"></i>
|
||||||
@@ -93,7 +93,7 @@
|
|||||||
<div v-if="isLoadingTag" class="menu-loading-container">
|
<div v-if="isLoadingTag" class="menu-loading-container">
|
||||||
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
|
<l-hatch size="28" stroke="4" speed="3.5" color="var(--primary-color)"></l-hatch>
|
||||||
</div>
|
</div>
|
||||||
<div v-else v-for="t in tags" :key="t.id" class="section-item" @click="gotoTag(t)">
|
<div v-else v-for="t in tagData" :key="t.id" class="section-item" @click="gotoTag(t)">
|
||||||
<img v-if="isImageIcon(t.smallIcon || t.icon)" :src="t.smallIcon || t.icon" class="section-item-icon" :alt="t.name" />
|
<img v-if="isImageIcon(t.smallIcon || t.icon)" :src="t.smallIcon || t.icon" class="section-item-icon" :alt="t.name" />
|
||||||
<i v-else class="section-item-icon fas fa-hashtag"></i>
|
<i v-else class="section-item-icon fas fa-hashtag"></i>
|
||||||
<span class="section-item-text">{{ t.name }} <span class="section-item-text-count">x {{ t.count
|
<span class="section-item-text">{{ t.name }} <span class="section-item-text-count">x {{ t.count
|
||||||
@@ -127,40 +127,35 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async setup(props, { emit }) {
|
async setup(props, { emit }) {
|
||||||
// `useRouter` must be called before any `await` to retain Nuxt instance
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
|
|
||||||
const categories = ref([])
|
const categories = ref([])
|
||||||
const tags = ref([])
|
const tags = ref([])
|
||||||
const categoryOpen = ref(true)
|
const categoryOpen = ref(true)
|
||||||
const tagOpen = ref(true)
|
const tagOpen = ref(true)
|
||||||
const { data: categoryData, pending: isLoadingCategory } = await fetch(
|
const isLoadingCategory = ref(false)
|
||||||
`${API_BASE_URL}/api/categories`,
|
const isLoadingTag = ref(false)
|
||||||
{ server: true }
|
const categoryData = ref([])
|
||||||
)
|
const tagData = ref([])
|
||||||
const { data: tagData, pending: isLoadingTag } = await fetch(
|
|
||||||
`${API_BASE_URL}/api/tags?limit=10`,
|
|
||||||
{ server: true }
|
|
||||||
)
|
|
||||||
|
|
||||||
watch(
|
const fetchCategoryData = async () => {
|
||||||
categoryData,
|
isLoadingCategory.value = true
|
||||||
(val) => {
|
const res = await fetch(`${API_BASE_URL}/api/categories`)
|
||||||
categories.value = (val || []).slice(0, 10)
|
const data = await res.json()
|
||||||
},
|
categoryData.value = data
|
||||||
{ immediate: true }
|
isLoadingCategory.value = false
|
||||||
)
|
}
|
||||||
watch(
|
|
||||||
tagData,
|
const fetchTagData = async () => {
|
||||||
(val) => {
|
isLoadingTag.value = true
|
||||||
tags.value = val || []
|
const res = await fetch(`${API_BASE_URL}/api/tags?limit=10`)
|
||||||
},
|
const data = await res.json()
|
||||||
{ immediate: true }
|
tagData.value = data
|
||||||
)
|
isLoadingTag.value = false
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
localStorage.setItem('menu-categories', JSON.stringify(categories.value))
|
// fetchCategoryData()
|
||||||
localStorage.setItem('menu-tags', JSON.stringify(tags.value))
|
// fetchTagData()
|
||||||
})
|
})
|
||||||
|
|
||||||
const iconClass = computed(() => {
|
const iconClass = computed(() => {
|
||||||
@@ -226,9 +221,11 @@ export default {
|
|||||||
handleItemClick()
|
handleItemClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await Promise.all([fetchCategoryData(), fetchTagData()])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
categories,
|
categoryData,
|
||||||
tags,
|
tagData,
|
||||||
categoryOpen,
|
categoryOpen,
|
||||||
tagOpen,
|
tagOpen,
|
||||||
isLoadingCategory,
|
isLoadingCategory,
|
||||||
|
|||||||
@@ -376,8 +376,7 @@ export default {
|
|||||||
|
|
||||||
const sanitizeDescription = text => stripMarkdown(text)
|
const sanitizeDescription = text => stripMarkdown(text)
|
||||||
|
|
||||||
await loadOptions()
|
await Promise.all([loadOptions(), fetchContent()])
|
||||||
await fetchContent()
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
topics,
|
topics,
|
||||||
|
|||||||
Reference in New Issue
Block a user