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 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'

View File

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

View File

@ -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;

View File

@ -6,14 +6,14 @@
<nav>
<router-link to="/recommend">推荐阅读</router-link>
<router-link to="/collect">收藏的版块</router-link>
<router-link to="/allSections?onefid=1125">全部版块</router-link>
<router-link to="/allSections">全部版块</router-link>
</nav>
<!-- 发帖子 -->
<div class="publish flexcolumn flexcenter">
<svg-icon icon-class="add" class-name="icon-publish"></svg-icon>
发帖
</div>
<router-view />
<router-view :key="key" />
</div>
</template>
@ -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
})
},
}

View File

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

View File

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

View File

@ -54,7 +54,7 @@
</div>
<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">
</el-pagination>
</div>
@ -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()
},
//