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