diff --git a/src/components/KUNGalgameSearchBox.vue b/src/components/KUNGalgameSearchBox.vue index 7608dc96..6822a822 100644 --- a/src/components/KUNGalgameSearchBox.vue +++ b/src/components/KUNGalgameSearchBox.vue @@ -33,6 +33,8 @@ onBeforeMount(() => { // 定义防抖处理函数 const debouncedSearch = debounce((inputValue: string) => { + // 搜索之前重置页数,是否加载等页面状态 + useKUNGalgameHomeStore().resetPageStatus() keywords.value = inputValue }, 300) // 300 毫秒的防抖延迟 diff --git a/src/store/modules/home.ts b/src/store/modules/home.ts index bece5f7f..4daa7284 100644 --- a/src/store/modules/home.ts +++ b/src/store/modules/home.ts @@ -12,6 +12,8 @@ interface HomeStore { limit: number sortField: string sortOrder: string + // 加载完了是否还需要加载 + isLoading: boolean // 其它的 store // 是否激活主页的左侧交互面板 @@ -41,6 +43,7 @@ export const useKUNGalgameHomeStore = defineStore({ limit: 17, sortField: 'updated', sortOrder: 'desc', + isLoading: true, // 其它的 store // 是否激活主页的左侧交互面板 @@ -57,8 +60,8 @@ export const useKUNGalgameHomeStore = defineStore({ const requestData: HomeTopicRequestData = { keywords: this.keywords, category: this.category, - page: this.page || 1, - limit: this.limit || 17, + page: this.page, + limit: this.limit, sortField: this.sortField || 'updated', sortOrder: this.sortOrder || 'desc', } @@ -72,5 +75,10 @@ export const useKUNGalgameHomeStore = defineStore({ }) }) }, + // 重置页数,是否加载,这样排序才能生效 + resetPageStatus() { + this.page = 1 + this.isLoading = true + }, }, }) diff --git a/src/store/modules/topic.ts b/src/store/modules/topic.ts index d4728846..69b55400 100644 --- a/src/store/modules/topic.ts +++ b/src/store/modules/topic.ts @@ -57,6 +57,8 @@ interface Topic { isShowAdvance: boolean // 是否激活左侧交互面板 isActiveAside: boolean + // 是否滚动到顶部 + isScrollToTop: boolean // 回复的缓存 replyDraft: ReplyDraft @@ -74,6 +76,7 @@ export const useKUNGalgameTopicStore = defineStore({ isEdit: false, isShowAdvance: false, isActiveAside: false, + isScrollToTop: false, replyDraft: { tid: 0, r_uid: 0, diff --git a/src/views/Home/content/article/components/ArticleContent.vue b/src/views/Home/content/article/components/ArticleContent.vue index aac55c48..a1f3c41a 100644 --- a/src/views/Home/content/article/components/ArticleContent.vue +++ b/src/views/Home/content/article/components/ArticleContent.vue @@ -1,5 +1,12 @@