fix(MyPopup): 修复收藏和发布列表显示问题,优化数据更新逻辑
refactor(app): 改进用户信息获取方式,使用事件监听替代轮询 style(details): 移除多余空格,优化HTML结构 perf(index): 替换nextTick为setTimeout延迟布局计算,提升性能 chore: 更新依赖和构建文件,清理无用资源
This commit is contained in:
@@ -15,10 +15,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="empty-box flexcenter" v-loading="true" v-if="(MyPopupState == 'collect' && collectLoading) || (MyPopupState == 'mj' && publisloading)"></div>
|
||||
<div class="empty-box flexcenter" v-else-if="showList.length == 0">
|
||||
<div class="empty-box flexcenter" v-if="(MyPopupState == 'collect' && !collectLoading && collectList.length == 0) || (MyPopupState == 'mj' && !publisloading && publishList.length == 0)">
|
||||
<Empty></Empty>
|
||||
</div>
|
||||
<div class="content" v-else @scroll="handleListScroll">
|
||||
<div class="content" v-if="showList.length > 0" @scroll="handleListScroll">
|
||||
<div class="item flexflex" v-for="(item, index) in showList" :key="index" @click="goDetails(item['uniqid'] || item?.data?.uniqid)">
|
||||
<div class="left flexflex">
|
||||
<div class="name">{{ item["school"] || item["data"]["school"] }}</div>
|
||||
@@ -82,7 +82,7 @@ onMounted(() => {
|
||||
// 展示的 列表数据
|
||||
let showList = ref([])
|
||||
|
||||
let collectList = []
|
||||
let collectList = ref([])
|
||||
let collectPage = 1
|
||||
let collectLoading = ref(false)
|
||||
let collectCount = ref(0)
|
||||
@@ -94,10 +94,10 @@ const getCollect = () => {
|
||||
.then(res => {
|
||||
if (res.code != 200) return
|
||||
let data = res.data
|
||||
collectList = collectList.concat(data.data)
|
||||
showList.value = collectList
|
||||
collectList.value = collectList.value.concat(data.data)
|
||||
showList.value = collectList.value
|
||||
|
||||
if (collectList.length < data["count"]) collectPage++
|
||||
if (collectList.value.length < data["count"]) collectPage++
|
||||
else collectPage = 0
|
||||
|
||||
collectCount.value = data["count"]
|
||||
@@ -108,7 +108,7 @@ const getCollect = () => {
|
||||
.finally(() => (collectLoading.value = false))
|
||||
}
|
||||
|
||||
let publishList = []
|
||||
let publishList = ref([])
|
||||
let publisPage = 1
|
||||
let publisloading = ref(false)
|
||||
const getPublish = () => {
|
||||
@@ -119,10 +119,10 @@ const getPublish = () => {
|
||||
.then(res => {
|
||||
if (res.code != 200) return
|
||||
let data = res.data
|
||||
publishList = publishList.concat(data.data)
|
||||
if (publishList.length < data["count"]) publisPage++
|
||||
publishList.value = publishList.value.concat(data.data)
|
||||
if (publishList.value.length < data["count"]) publisPage++
|
||||
else publisPage = 0
|
||||
showList.value = publishList
|
||||
showList.value = publishList.value
|
||||
|
||||
// MyPopupState.value = "mj"
|
||||
// show.value = true
|
||||
@@ -133,16 +133,16 @@ const getPublish = () => {
|
||||
// 切换 isEmpty 是否清空收藏数据, 因为不确定用户是否有新收藏
|
||||
const cutMy = (key, isEmpty) => {
|
||||
if (isEmpty) {
|
||||
collectList = []
|
||||
collectList.value = []
|
||||
collectPage = 1
|
||||
collectCount.value = 0
|
||||
}
|
||||
|
||||
if (key == "collect" && collectList.length == 0) getCollect()
|
||||
else if (key == "mj" && publishList.length == 0) getPublish()
|
||||
if (key == "collect" && collectList.value.length == 0) getCollect()
|
||||
else if (key == "mj" && publishList.value.length == 0) getPublish()
|
||||
|
||||
if (key == "collect") showList.value = collectList
|
||||
else if (key == "mj") showList.value = publishList
|
||||
if (key == "collect") showList.value = collectList.value
|
||||
else if (key == "mj") showList.value = publishList.value
|
||||
|
||||
MyPopupState.value = key
|
||||
|
||||
@@ -151,27 +151,27 @@ const cutMy = (key, isEmpty) => {
|
||||
|
||||
// 打开匿名弹窗
|
||||
const openAnonymousState = index => {
|
||||
publishList.forEach(element => {
|
||||
publishList.value.forEach(element => {
|
||||
element["anonymousState"] = false
|
||||
})
|
||||
publishList[index]["anonymousState"] = true
|
||||
showList.value = [...publishList]
|
||||
publishList.value[index]["anonymousState"] = true
|
||||
showList.value = [...publishList.value]
|
||||
}
|
||||
|
||||
// 关闭全部匿名弹窗
|
||||
const closeAllAnonymousState = () => {
|
||||
publishList.forEach(element => {
|
||||
publishList.value.forEach(element => {
|
||||
element["anonymousState"] = false
|
||||
})
|
||||
showList.value = [...publishList]
|
||||
showList.value = [...publishList.value]
|
||||
}
|
||||
// 修改匿名状态
|
||||
const handleAnonymousState = (token, index, anonymous) => {
|
||||
changeAnonymousHttp({ token, anonymous }).then(res => {
|
||||
if (res.code != 200) return
|
||||
|
||||
publishList[index]["anonymous"] = anonymous
|
||||
showList.value = [...publishList]
|
||||
publishList.value[index]["anonymous"] = anonymous
|
||||
showList.value = [...publishList.value]
|
||||
closeAllAnonymousState()
|
||||
|
||||
ElMessage.success(res.message)
|
||||
@@ -225,8 +225,8 @@ const cancelCollection = (token, index, uniqid) => {
|
||||
return
|
||||
}
|
||||
|
||||
collectList.splice(index, 1)
|
||||
showList.value = [...collectList]
|
||||
collectList.value.splice(index, 1)
|
||||
showList.value = [...collectList.value]
|
||||
count.value.collect--
|
||||
collectCount.value--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user