mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-03-21 03:27:25 +08:00
fix: 解决tag与类别切换需要reload整个页面的bug
This commit is contained in:
@@ -210,17 +210,13 @@ export default {
|
|||||||
|
|
||||||
const gotoCategory = (c) => {
|
const gotoCategory = (c) => {
|
||||||
const value = encodeURIComponent(c.id ?? c.name)
|
const value = encodeURIComponent(c.id ?? c.name)
|
||||||
router.push({ path: '/', query: { category: value } }).then(() => {
|
router.push({ path: '/', query: { category: value } })
|
||||||
window.location.reload()
|
|
||||||
})
|
|
||||||
handleItemClick()
|
handleItemClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
const gotoTag = (t) => {
|
const gotoTag = (t) => {
|
||||||
const value = encodeURIComponent(t.id ?? t.name)
|
const value = encodeURIComponent(t.id ?? t.name)
|
||||||
router.push({ path: '/', query: { tags: value } }).then(() => {
|
router.push({ path: '/', query: { tags: value } })
|
||||||
window.location.reload()
|
|
||||||
})
|
|
||||||
handleItemClick()
|
handleItemClick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -113,18 +113,17 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { useRoute } from 'vue-router'
|
import ArticleCategory from '~/components/ArticleCategory.vue'
|
||||||
import { useScrollLoadMore } from '~/utils/loadMore'
|
import ArticleTags from '~/components/ArticleTags.vue'
|
||||||
import { stripMarkdown } from '~/utils/markdown'
|
import CategorySelect from '~/components/CategorySelect.vue'
|
||||||
|
import SearchDropdown from '~/components/SearchDropdown.vue'
|
||||||
|
import TagSelect from '~/components/TagSelect.vue'
|
||||||
import { API_BASE_URL } from '~/main'
|
import { API_BASE_URL } from '~/main'
|
||||||
import { getToken } from '~/utils/auth'
|
import { getToken } from '~/utils/auth'
|
||||||
import TimeManager from '~/utils/time'
|
import { useScrollLoadMore } from '~/utils/loadMore'
|
||||||
import CategorySelect from '~/components/CategorySelect.vue'
|
import { stripMarkdown } from '~/utils/markdown'
|
||||||
import TagSelect from '~/components/TagSelect.vue'
|
|
||||||
import ArticleTags from '~/components/ArticleTags.vue'
|
|
||||||
import ArticleCategory from '~/components/ArticleCategory.vue'
|
|
||||||
import SearchDropdown from '~/components/SearchDropdown.vue'
|
|
||||||
import { useIsMobile } from '~/utils/screen'
|
import { useIsMobile } from '~/utils/screen'
|
||||||
|
import TimeManager from '~/utils/time'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'HomePageView',
|
name: 'HomePageView',
|
||||||
@@ -150,22 +149,9 @@ export default {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
const route = useRoute()
|
|
||||||
const selectedCategory = ref('')
|
const selectedCategory = ref('')
|
||||||
if (route.query.category) {
|
|
||||||
const c = decodeURIComponent(route.query.category)
|
|
||||||
selectedCategory.value = isNaN(c) ? c : Number(c)
|
|
||||||
}
|
|
||||||
const selectedTags = ref([])
|
const selectedTags = ref([])
|
||||||
if (route.query.tags) {
|
const route = useRoute()
|
||||||
const t = Array.isArray(route.query.tags) ? route.query.tags.join(',') : route.query.tags
|
|
||||||
selectedTags.value = t
|
|
||||||
.split(',')
|
|
||||||
.filter((v) => v)
|
|
||||||
.map((v) => decodeURIComponent(v))
|
|
||||||
.map((v) => (isNaN(v) ? v : Number(v)))
|
|
||||||
}
|
|
||||||
|
|
||||||
const tagOptions = ref([])
|
const tagOptions = ref([])
|
||||||
const categoryOptions = ref([])
|
const categoryOptions = ref([])
|
||||||
const isLoadingPosts = ref(false)
|
const isLoadingPosts = ref(false)
|
||||||
@@ -177,13 +163,50 @@ export default {
|
|||||||
? '最新'
|
? '最新'
|
||||||
: '最新回复',
|
: '最新回复',
|
||||||
)
|
)
|
||||||
|
|
||||||
const articles = ref([])
|
const articles = ref([])
|
||||||
const page = ref(0)
|
const page = ref(0)
|
||||||
const pageSize = 10
|
const pageSize = 10
|
||||||
const isMobile = useIsMobile()
|
const isMobile = useIsMobile()
|
||||||
const allLoaded = ref(false)
|
const allLoaded = ref(false)
|
||||||
|
|
||||||
|
const selectedCategorySet = (category) => {
|
||||||
|
const c = decodeURIComponent(category)
|
||||||
|
selectedCategory.value = isNaN(c) ? c : Number(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedTagsSet = (tags) => {
|
||||||
|
const t = Array.isArray(tags) ? tags.join(',') : tags
|
||||||
|
selectedTags.value = t
|
||||||
|
.split(',')
|
||||||
|
.filter((v) => v)
|
||||||
|
.map((v) => decodeURIComponent(v))
|
||||||
|
.map((v) => (isNaN(v) ? v : Number(v)))
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const query = route.query
|
||||||
|
const category = query.category
|
||||||
|
const tags = query.tags
|
||||||
|
|
||||||
|
if (category) {
|
||||||
|
selectedCategorySet(category)
|
||||||
|
}
|
||||||
|
if (tags) {
|
||||||
|
selectedTagsSet(tags)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => route.query,
|
||||||
|
() => {
|
||||||
|
const query = route.query
|
||||||
|
const category = query.category
|
||||||
|
const tags = query.tags
|
||||||
|
category && selectedCategorySet(category)
|
||||||
|
tags && selectedTagsSet(tags)
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
const loadOptions = async () => {
|
const loadOptions = async () => {
|
||||||
if (selectedCategory.value && !isNaN(selectedCategory.value)) {
|
if (selectedCategory.value && !isNaN(selectedCategory.value)) {
|
||||||
try {
|
try {
|
||||||
@@ -696,6 +719,7 @@ export default {
|
|||||||
.header-item.activity {
|
.header-item.activity {
|
||||||
width: 10%;
|
width: 10%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.article-member-avatar-item:nth-child(n + 4) {
|
.article-member-avatar-item:nth-child(n + 4) {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user