From 9e678d108c5694858f10dc970845ce9d2df31435 Mon Sep 17 00:00:00 2001 From: xiaoronghao <1300399510@qq.com> Date: Fri, 7 Apr 2023 18:42:46 +0800 Subject: [PATCH] =?UTF-8?q?=C2=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.js | 3 +- src/utils/common.js | 12 +++++++- src/views/detail/detailIndex.vue | 12 ++++---- src/views/index/allSections/AllSections.vue | 30 +++++++++++-------- src/views/index/index.vue | 12 ++++++-- src/views/index/recommend/Recommend.vue | 14 +++++---- src/views/search/search.vue | 8 ++++- .../search/searchResult/SearchResult.vue | 15 +++++++--- 8 files changed, 74 insertions(+), 32 deletions(-) diff --git a/src/main.js b/src/main.js index 8881831..56f9b90 100755 --- a/src/main.js +++ b/src/main.js @@ -4,7 +4,7 @@ import router from './router' import store from './store' import ElementUI, { Message, Pagination, loading } from 'element-ui'; import 'element-ui/lib/theme-chalk/index.css'; -import { skipUrl, pageStop, pageMove, goTologin, copy, startupUnderLoading, closeUnderLoading, formattedDate } from "@/utils/common.js" +import { skipUrl, pageStop, pageMove, goTologin, copy, startupUnderLoading, closeUnderLoading, formattedDate, updateURLSearchParams } from "@/utils/common.js" import http from "@/utils/request" import hintBox from '@/components/Hintbox' @@ -26,6 +26,7 @@ Vue.prototype.$copy = copy // 复制 Vue.prototype.$startupUnderLoading = startupUnderLoading // 开启加载提示 element的 Vue.prototype.$closeUnderLoading = closeUnderLoading // 关闭加载提示 element的 Vue.prototype.$formattedDate = formattedDate // 时间戳转格式 +Vue.prototype.$updateURLSearchParams = updateURLSearchParams // 不刷新的情况下修改url //svg文件引入 import './icons' diff --git a/src/utils/common.js b/src/utils/common.js index 7d76c26..80c0b26 100755 --- a/src/utils/common.js +++ b/src/utils/common.js @@ -73,4 +73,14 @@ function formattedDate(timestamp) { return formattedDate } -export { skipUrl, pageStop, pageMove, goTologin, copy, startupUnderLoading, closeUnderLoading, formattedDate } \ No newline at end of file +// 不刷新的情况下修改url +function updateURLSearchParams(obj = {}) { + const params = new URLSearchParams(window.location.search); + for (const key in obj) { + params.set(key, obj[key]); + } + const newUrl = window.location.pathname + '?' + params.toString(); + window.history.pushState({}, '', newUrl); +} + +export { skipUrl, pageStop, pageMove, goTologin, copy, startupUnderLoading, closeUnderLoading, formattedDate, updateURLSearchParams } \ No newline at end of file diff --git a/src/views/detail/detailIndex.vue b/src/views/detail/detailIndex.vue index 28c4227..8d101fe 100755 --- a/src/views/detail/detailIndex.vue +++ b/src/views/detail/detailIndex.vue @@ -20,7 +20,7 @@
-
+
@@ -138,8 +138,10 @@
{{ $formattedDate(item.dateline) }}
-
{{ `${(postList.page - 1) * postList.limit + index + 2 }楼` }}
-
{{ `${(postList.page - 1) * postList.limit + index + 1 }楼` }}
+
{{ `${(postList.page - 1) * postList.limit + + index + 2}楼` }}
+
{{ `${(postList.page - 1) * postList.limit + index + 1}楼` }} +
@@ -652,9 +654,9 @@ export default { if (key == "collect") this.info.isfav = 1 if (key == "uncollect") this.info.isfav = 0 this.$message.success(res.message) - + }) - + }, // 点击转发 diff --git a/src/views/index/allSections/AllSections.vue b/src/views/index/allSections/AllSections.vue index 6a0f9b6..f9a36de 100755 --- a/src/views/index/allSections/AllSections.vue +++ b/src/views/index/allSections/AllSections.vue @@ -69,19 +69,20 @@ export default { stairname: "",// 一级版块名称 subsectionsname: "",// 子版块名称 }, + loading: null, // 加载状态 } }, mounted() { - console.log("gggkgkgk"); this.$store.subscribe((mutation, state) => { if (mutation.type == "setAllForumList") this.list = this.$store.state.allForumList }); - let { onefid, twofid } = this.$route.query + let { onefid, twofid, invitationPage } = this.$route.query if (onefid) this.onefid = onefid if (twofid) this.twofid = twofid + if (invitationPage) this.invitationPage = Number(invitationPage) if (Number(onefid) > 0) this.a() @@ -168,17 +169,12 @@ export default { stairname: this.list[this.allActive].name, subsectionsname, } - this.getInvitationList() - - const params = new URLSearchParams(window.location.search); - params.set('onefid', this.list[this.allActive].fid,); - params.set('twofid', this.twofid); - const newUrl = window.location.pathname + '?' + params.toString(); - window.history.pushState({}, '', newUrl); + this.$router.push({ path: `/allSections`, query: { onefid: this.list[this.allActive].fid, twofid: this.twofid } }) }, // 获取帖子列表 getInvitationList() { + this.$startupUnderLoading(this) this.$http.post("/api/home/threadList", { page: this.invitationPage, limit: this.invitationLimit, @@ -191,12 +187,14 @@ export default { document.documentElement.scrollTop = 0; document.body.scrollTop = 0; + }).finally(() => { + this.$closeUnderLoading(this) }) }, // 点击页数 currentChange() { - this.getInvitationList() + this.$router.push({ path: `/allSections`, query: { onefid: this.list[this.allActive].fid, twofid: this.twofid, invitationPage: this.invitationPage } }) }, }, @@ -221,17 +219,23 @@ export default { margin-top: 0.666667rem; filter: drop-shadow(0.05rem 0 0.09rem rgba(0, 0, 0, 0.1)); margin: .64rem 0.35rem; + + height: calc(100vh - 3rem); + overflow: auto; } .allSections-left { width: 35%; border-left: 0.013333rem solid #ddd; background-color: rgba(235, 235, 235, 0.556862745098039); - border-radius: 0.32rem 0 0 0.32rem; + // border-radius: 0.32rem 0 0 0.32rem; display: flex; flex-direction: column; text-align: center; + overflow-y: auto; + overflow-x: hidden; + span { height: 1.28rem; line-height: 1.28rem; @@ -285,11 +289,13 @@ export default { .allSections-right { width: 65%; background-color: #fff; - border-radius: 0 0.32rem 0.32rem 0; + // border-radius: 0 0.32rem 0.32rem 0; display: flex; flex-direction: column; z-index: 1; padding-bottom: 0.4rem; + overflow-x: hidden; + overflow-y: auto; &.active { display: block; diff --git a/src/views/index/index.vue b/src/views/index/index.vue index b18f9ec..f85336a 100755 --- a/src/views/index/index.vue +++ b/src/views/index/index.vue @@ -6,14 +6,14 @@
发帖
- +
@@ -25,8 +25,15 @@ export default { return { favorite: [], // 收藏 recommend: [], // 推荐 + query: {}, }; }, + + computed: { + key() { + return this.$route.path + Math.random() + } + }, mounted() { this.init() }, @@ -39,7 +46,6 @@ export default { let data = res.data this.favorite = data.favorite this.recommend = data.recommend - }) }, } diff --git a/src/views/index/recommend/Recommend.vue b/src/views/index/recommend/Recommend.vue index 41c2905..6082377 100755 --- a/src/views/index/recommend/Recommend.vue +++ b/src/views/index/recommend/Recommend.vue @@ -42,15 +42,19 @@ export default { ] } }, - components: { - plateNavigation, - indexList, + mounted() { + console.log(this.$parent); }, + methods: { hotLabelClick(index) { this.hotActive = index } - } + }, + components: { + plateNavigation, + indexList, + }, } @@ -72,6 +76,6 @@ export default { } section { - height: 5.3333rem; + height: 10.3333rem; } \ No newline at end of file diff --git a/src/views/search/search.vue b/src/views/search/search.vue index 7222c8a..3b56ce6 100755 --- a/src/views/search/search.vue +++ b/src/views/search/search.vue @@ -3,7 +3,7 @@ - +
@@ -19,6 +19,12 @@ export default { }; }, + computed: { + key() { + return this.$route.path + Math.random() + } + }, + mounted() { }, diff --git a/src/views/search/searchResult/SearchResult.vue b/src/views/search/searchResult/SearchResult.vue index e841035..1a2fa80 100755 --- a/src/views/search/searchResult/SearchResult.vue +++ b/src/views/search/searchResult/SearchResult.vue @@ -54,7 +54,7 @@
-
@@ -82,10 +82,11 @@ export default { }, mounted() { - this.kw = this.$route.query.kw + let { kw, page } = this.$route.query + this.kw = kw + if (page) this.page = Number(page) this.getSearchResult() - }, watch: { @@ -106,7 +107,10 @@ export default { handleSearchResult() { let kw = this.kw if (!kw) return + this.page = 1 this.getSearchResult() + + this.$updateURLSearchParams({ kw: this.kw, page: this.page }) }, // 获取搜索结果数据 @@ -137,7 +141,10 @@ export default { // 点击改变页数 currentChange() { - this.getSearchResult() + + this.$router.push({ path: `/searchResult`, query: { kw: this.kw, page: this.page } }) + // this.getSearchResult() + }, // 跳转详情