mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-18 18:07:24 +08:00
Reapply "feat: reuse server data on home page"
This reverts commit 6d277b5809.
This commit is contained in:
@@ -109,6 +109,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import { useRoute } from 'vue-router'
|
||||||
|
import { useState } from '#app'
|
||||||
import { useScrollLoadMore } from '~/utils/loadMore'
|
import { useScrollLoadMore } from '~/utils/loadMore'
|
||||||
import { stripMarkdown } from '~/utils/markdown'
|
import { stripMarkdown } from '~/utils/markdown'
|
||||||
import { API_BASE_URL } from '~/main'
|
import { API_BASE_URL } from '~/main'
|
||||||
@@ -152,8 +153,8 @@ export default {
|
|||||||
.map(v => (isNaN(v) ? v : Number(v)))
|
.map(v => (isNaN(v) ? v : Number(v)))
|
||||||
}
|
}
|
||||||
|
|
||||||
const tagOptions = ref([])
|
const tagOptions = useState('index-tagOptions', () => [])
|
||||||
const categoryOptions = ref([])
|
const categoryOptions = useState('index-categoryOptions', () => [])
|
||||||
const isLoadingPosts = ref(false)
|
const isLoadingPosts = ref(false)
|
||||||
const topics = ref(['最新回复', '最新', '排行榜' /*, '热门', '类别'*/])
|
const topics = ref(['最新回复', '最新', '排行榜' /*, '热门', '类别'*/])
|
||||||
const selectedTopic = ref(
|
const selectedTopic = ref(
|
||||||
@@ -164,11 +165,12 @@ export default {
|
|||||||
: '最新回复'
|
: '最新回复'
|
||||||
)
|
)
|
||||||
|
|
||||||
const articles = ref([])
|
const articles = useState('index-articles', () => [])
|
||||||
const page = ref(0)
|
const page = useState('index-page', () => 0)
|
||||||
const pageSize = 10
|
const pageSize = 10
|
||||||
|
const allLoaded = useState('index-allLoaded', () => false)
|
||||||
|
const initialized = useState('index-initialized', () => false)
|
||||||
const isMobile = useIsMobile()
|
const isMobile = useIsMobile()
|
||||||
const allLoaded = ref(false)
|
|
||||||
|
|
||||||
const loadOptions = async () => {
|
const loadOptions = async () => {
|
||||||
if (selectedCategory.value && !isNaN(selectedCategory.value)) {
|
if (selectedCategory.value && !isNaN(selectedCategory.value)) {
|
||||||
@@ -381,7 +383,10 @@ export default {
|
|||||||
|
|
||||||
const sanitizeDescription = text => stripMarkdown(text)
|
const sanitizeDescription = text => stripMarkdown(text)
|
||||||
|
|
||||||
await Promise.all([loadOptions(), fetchContent()])
|
if (!initialized.value) {
|
||||||
|
await Promise.all([loadOptions(), fetchContent()])
|
||||||
|
initialized.value = true
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
topics,
|
topics,
|
||||||
|
|||||||
Reference in New Issue
Block a user