mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-02-25 15:40:49 +08:00
Compare commits
6 Commits
codex/save
...
codex/save
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f27cb5c703 | ||
|
|
642a527dcf | ||
|
|
88afcc5a8e | ||
|
|
2f29946b11 | ||
|
|
e27aa34cfd | ||
|
|
2322b2da15 |
@@ -147,20 +147,17 @@ const categoryOptions = ref([])
|
||||
const isLoadingMore = ref(false)
|
||||
|
||||
const topics = ref(['最新回复', '最新', '排行榜' /*, '热门', '类别'*/])
|
||||
const HOME_TAB_KEY = 'homeTab'
|
||||
const routeDefault =
|
||||
route.query.view === 'ranking' ? '排行榜' : route.query.view === 'latest' ? '最新' : null
|
||||
const selectedTopic = ref(routeDefault || '最新回复')
|
||||
if (import.meta.client) {
|
||||
if (routeDefault) {
|
||||
localStorage.setItem(HOME_TAB_KEY, routeDefault)
|
||||
} else {
|
||||
const stored = localStorage.getItem(HOME_TAB_KEY)
|
||||
if (stored && topics.value.includes(stored)) {
|
||||
selectedTopic.value = stored
|
||||
}
|
||||
}
|
||||
}
|
||||
const selectedTopicCookie = useCookie('homeTab')
|
||||
const selectedTopic = ref(
|
||||
selectedTopicCookie.value
|
||||
? selectedTopicCookie.value
|
||||
: route.query.view === 'ranking'
|
||||
? '排行榜'
|
||||
: route.query.view === 'latest'
|
||||
? '最新'
|
||||
: '最新回复',
|
||||
)
|
||||
if (!selectedTopicCookie.value) selectedTopicCookie.value = selectedTopic.value
|
||||
const articles = ref([])
|
||||
const page = ref(0)
|
||||
const pageSize = 10
|
||||
@@ -186,6 +183,11 @@ onMounted(() => {
|
||||
const { category, tags } = route.query
|
||||
if (category) selectedCategorySet(category)
|
||||
if (tags) selectedTagsSet(tags)
|
||||
|
||||
const saved = localStorage.getItem('homeTab')
|
||||
if (saved) {
|
||||
selectedTopic.value = saved
|
||||
}
|
||||
})
|
||||
|
||||
/** 路由变更时同步筛选 **/
|
||||
@@ -352,9 +354,12 @@ watch([selectedCategory, selectedTags], () => {
|
||||
loadOptions()
|
||||
})
|
||||
watch(selectedTopic, (val) => {
|
||||
if (import.meta.client) localStorage.setItem(HOME_TAB_KEY, val)
|
||||
// 仅当需要额外选项时加载
|
||||
loadOptions()
|
||||
selectedTopicCookie.value = val
|
||||
if (process.client) {
|
||||
localStorage.setItem('homeTab', val)
|
||||
}
|
||||
})
|
||||
|
||||
/** 选项首屏加载:服务端执行一次;客户端兜底 **/
|
||||
|
||||
Reference in New Issue
Block a user