This commit is contained in:
xiaoronghao 2023-04-07 18:42:46 +08:00
parent 2049ac392a
commit 9e678d108c
8 changed files with 74 additions and 32 deletions

View File

@ -4,7 +4,7 @@ import router from './router'
import store from './store' import store from './store'
import ElementUI, { Message, Pagination, loading } from 'element-ui'; import ElementUI, { Message, Pagination, loading } from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css'; 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 http from "@/utils/request"
import hintBox from '@/components/Hintbox' import hintBox from '@/components/Hintbox'
@ -26,6 +26,7 @@ Vue.prototype.$copy = copy // 复制
Vue.prototype.$startupUnderLoading = startupUnderLoading // 开启加载提示 element的 Vue.prototype.$startupUnderLoading = startupUnderLoading // 开启加载提示 element的
Vue.prototype.$closeUnderLoading = closeUnderLoading // 关闭加载提示 element的 Vue.prototype.$closeUnderLoading = closeUnderLoading // 关闭加载提示 element的
Vue.prototype.$formattedDate = formattedDate // 时间戳转格式 Vue.prototype.$formattedDate = formattedDate // 时间戳转格式
Vue.prototype.$updateURLSearchParams = updateURLSearchParams // 不刷新的情况下修改url
//svg文件引入 //svg文件引入
import './icons' import './icons'

View File

@ -73,4 +73,14 @@ function formattedDate(timestamp) {
return formattedDate return formattedDate
} }
export { skipUrl, pageStop, pageMove, goTologin, copy, startupUnderLoading, closeUnderLoading, formattedDate } // 不刷新的情况下修改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 }

View File

@ -20,7 +20,7 @@
<!-- --> <!-- -->
<div class="card flexcenter"> <div class="card flexcenter">
<div class="card-item shadow" v-if="false"> <div class="card-item shadow" v-if="postList.page == 1">
<div class="card-head flexacenter"> <div class="card-head flexacenter">
<img class="card-head-icon" :src="info.avatar" /> <img class="card-head-icon" :src="info.avatar" />
<div class="card-head-content flex1 flexflex"> <div class="card-head-content flex1 flexflex">
@ -138,8 +138,10 @@
<div class="card-head-time">{{ $formattedDate(item.dateline) }}</div> <div class="card-head-time">{{ $formattedDate(item.dateline) }}</div>
</div> </div>
<!-- <div class="card-head-fool">{{ `${index + 1 + 1}` }}</div> --> <!-- <div class="card-head-fool">{{ `${index + 1 + 1}` }}</div> -->
<div class="card-head-fool" v-if="postList.page == 1">{{ `${(postList.page - 1) * postList.limit + index + 2 }` }}</div> <div class="card-head-fool" v-if="postList.page == 1">{{ `${(postList.page - 1) * postList.limit +
<div class="card-head-fool" v-else>{{ `${(postList.page - 1) * postList.limit + index + 1 }` }}</div> index + 2}` }}</div>
<div class="card-head-fool" v-else>{{ `${(postList.page - 1) * postList.limit + index + 1}` }}
</div>
<!-- <div class="card-head-fool">{{ index == 0 ? '楼主' : `${index}` }}</div> --> <!-- <div class="card-head-fool">{{ index == 0 ? '楼主' : `${index}` }}</div> -->
</div> </div>

View File

@ -69,19 +69,20 @@ export default {
stairname: "",// stairname: "",//
subsectionsname: "",// subsectionsname: "",//
}, },
loading: null, //
} }
}, },
mounted() { mounted() {
console.log("gggkgkgk");
this.$store.subscribe((mutation, state) => { this.$store.subscribe((mutation, state) => {
if (mutation.type == "setAllForumList") this.list = this.$store.state.allForumList 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 (onefid) this.onefid = onefid
if (twofid) this.twofid = twofid if (twofid) this.twofid = twofid
if (invitationPage) this.invitationPage = Number(invitationPage)
if (Number(onefid) > 0) this.a() if (Number(onefid) > 0) this.a()
@ -168,17 +169,12 @@ export default {
stairname: this.list[this.allActive].name, stairname: this.list[this.allActive].name,
subsectionsname, subsectionsname,
} }
this.getInvitationList() this.$router.push({ path: `/allSections`, query: { onefid: this.list[this.allActive].fid, twofid: this.twofid } })
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);
}, },
// //
getInvitationList() { getInvitationList() {
this.$startupUnderLoading(this)
this.$http.post("/api/home/threadList", { this.$http.post("/api/home/threadList", {
page: this.invitationPage, page: this.invitationPage,
limit: this.invitationLimit, limit: this.invitationLimit,
@ -191,12 +187,14 @@ export default {
document.documentElement.scrollTop = 0; document.documentElement.scrollTop = 0;
document.body.scrollTop = 0; document.body.scrollTop = 0;
}).finally(() => {
this.$closeUnderLoading(this)
}) })
}, },
// //
currentChange() { 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; margin-top: 0.666667rem;
filter: drop-shadow(0.05rem 0 0.09rem rgba(0, 0, 0, 0.1)); filter: drop-shadow(0.05rem 0 0.09rem rgba(0, 0, 0, 0.1));
margin: .64rem 0.35rem; margin: .64rem 0.35rem;
height: calc(100vh - 3rem);
overflow: auto;
} }
.allSections-left { .allSections-left {
width: 35%; width: 35%;
border-left: 0.013333rem solid #ddd; border-left: 0.013333rem solid #ddd;
background-color: rgba(235, 235, 235, 0.556862745098039); 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; display: flex;
flex-direction: column; flex-direction: column;
text-align: center; text-align: center;
overflow-y: auto;
overflow-x: hidden;
span { span {
height: 1.28rem; height: 1.28rem;
line-height: 1.28rem; line-height: 1.28rem;
@ -285,11 +289,13 @@ export default {
.allSections-right { .allSections-right {
width: 65%; width: 65%;
background-color: #fff; background-color: #fff;
border-radius: 0 0.32rem 0.32rem 0; // border-radius: 0 0.32rem 0.32rem 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
z-index: 1; z-index: 1;
padding-bottom: 0.4rem; padding-bottom: 0.4rem;
overflow-x: hidden;
overflow-y: auto;
&.active { &.active {
display: block; display: block;

View File

@ -6,14 +6,14 @@
<nav> <nav>
<router-link to="/recommend">推荐阅读</router-link> <router-link to="/recommend">推荐阅读</router-link>
<router-link to="/collect">收藏的版块</router-link> <router-link to="/collect">收藏的版块</router-link>
<router-link to="/allSections?onefid=1125">全部版块</router-link> <router-link to="/allSections">全部版块</router-link>
</nav> </nav>
<!-- 发帖子 --> <!-- 发帖子 -->
<div class="publish flexcolumn flexcenter"> <div class="publish flexcolumn flexcenter">
<svg-icon icon-class="add" class-name="icon-publish"></svg-icon> <svg-icon icon-class="add" class-name="icon-publish"></svg-icon>
发帖 发帖
</div> </div>
<router-view /> <router-view :key="key" />
</div> </div>
</template> </template>
@ -25,8 +25,15 @@ export default {
return { return {
favorite: [], // favorite: [], //
recommend: [], // recommend: [], //
query: {},
}; };
}, },
computed: {
key() {
return this.$route.path + Math.random()
}
},
mounted() { mounted() {
this.init() this.init()
}, },
@ -39,7 +46,6 @@ export default {
let data = res.data let data = res.data
this.favorite = data.favorite this.favorite = data.favorite
this.recommend = data.recommend this.recommend = data.recommend
}) })
}, },
} }

View File

@ -42,15 +42,19 @@ export default {
] ]
} }
}, },
components: { mounted() {
plateNavigation, console.log(this.$parent);
indexList,
}, },
methods: { methods: {
hotLabelClick(index) { hotLabelClick(index) {
this.hotActive = index this.hotActive = index
} }
} },
components: {
plateNavigation,
indexList,
},
} }
</script> </script>
@ -72,6 +76,6 @@ export default {
} }
section { section {
height: 5.3333rem; height: 10.3333rem;
} }
</style> </style>

View File

@ -3,7 +3,7 @@
<header-nav :issearch="false" :needgetuser="true"> <header-nav :issearch="false" :needgetuser="true">
<template slot="header-title">搜索帖子</template> <template slot="header-title">搜索帖子</template>
</header-nav> </header-nav>
<router-view /> <router-view :key="key" />
</div> </div>
</template> </template>
@ -19,6 +19,12 @@ export default {
}; };
}, },
computed: {
key() {
return this.$route.path + Math.random()
}
},
mounted() { mounted() {
}, },

View File

@ -54,7 +54,7 @@
</div> </div>
<div v-if="count > limit" class="paging flexcenter"> <div v-if="count > limit" class="paging flexcenter">
<el-pagination small background layout="prev, pager, next" @current-change="currentChange" <el-pagination small background layout="prev, pager, next" @current-change="currentChange()"
:current-page.sync="page" :page-size="limit" :total="count"> :current-page.sync="page" :page-size="limit" :total="count">
</el-pagination> </el-pagination>
</div> </div>
@ -82,10 +82,11 @@ export default {
}, },
mounted() { mounted() {
this.kw = this.$route.query.kw let { kw, page } = this.$route.query
this.kw = kw
if (page) this.page = Number(page)
this.getSearchResult() this.getSearchResult()
}, },
watch: { watch: {
@ -106,7 +107,10 @@ export default {
handleSearchResult() { handleSearchResult() {
let kw = this.kw let kw = this.kw
if (!kw) return if (!kw) return
this.page = 1
this.getSearchResult() this.getSearchResult()
this.$updateURLSearchParams({ kw: this.kw, page: this.page })
}, },
// //
@ -137,7 +141,10 @@ export default {
// //
currentChange() { currentChange() {
this.getSearchResult()
this.$router.push({ path: `/searchResult`, query: { kw: this.kw, page: this.page } })
// this.getSearchResult()
}, },
// //