no message

This commit is contained in:
A1300399510
2024-01-18 17:25:40 +08:00
parent e01ac5326b
commit 7390c2fc72
11 changed files with 273 additions and 67 deletions

View File

@@ -4,14 +4,16 @@
<Meta name="keyword" :content="seo['keyword']" />
<Meta name="description" :content="seo['description']" />
</Head>
<TopHead></TopHead>
<TopHead ref="topHeadRef"></TopHead>
<div class="content flexflex" :style="{ '--main-color': colourValue[uniqidIndex]['main'], '--bg-color': colourValue[uniqidIndex]['bg'], '--bc-color': colourValue[uniqidIndex]['bc'] }">
<div class="header flexacenter">
<span>{{ info.title }}</span>
<span class="views flexcenter">
<img class="eye-icon" src="@/assets/img/eye-icon.svg" />
{{ info.views }}
</span>
<ClientOnly>
<span class="views flexcenter">
<img class="eye-icon" src="@/assets/img/eye-icon.svg" />
{{ info.views }}
</span>
</ClientOnly>
</div>
<div class="left">
<div class="info flexacenter">
@@ -19,7 +21,7 @@
<el-popover placement="bottom-start" :width="140" trigger="click" popper-class="avatar-box-popper" :show-arrow="false">
<template #reference>
<div class="flexcenter">
<img class="avatar" v-if="info.avatar" :src="info.avatar" />
<img class="avatar" :src="info.avatar" />
<div class="username">{{ info.nickname }}</div>
</div>
</template>
@@ -49,7 +51,7 @@
</div>
<div class="message">{{ info.message }}</div>
<div class="hint">{{ info.status == 1 && isvote == 0 ? `已有 ${info.votes || ""} 人参与,` : `共有 ${info.votes || 0} 人参与` }} {{ `${isvote == 1 ? "你已投票" : info.status == 1 ? "参与投票即可查看实时结果" : ""}` }}</div>
<div class="hint">{{ info.status == 1 && isvote == 0 ? `已有 ${info.votes || 0} 人参与,` : `共有 ${info.votes || 0} 人参与` }} {{ `${isvote == 1 ? "你已投票" : info.status == 1 ? "参与投票即可查看实时结果" : ""}` }}</div>
<div class="option-list flexflex" v-if="info['status'] == 1 && isvote == 0">
<div class="option-item flexflex" v-for="(item, index) in option" :key="item.id" @click="handleVote(item.id, index)">
@@ -71,7 +73,7 @@
</div>
</div>
</div>
<div class="right"><DetailsComments :token="token"></DetailsComments></div>
<div class="right"><DetailsComments ref="commentsRef" :token="token"></DetailsComments></div>
</div>
<DetailsArea></DetailsArea>
@@ -166,48 +168,82 @@ const redirectToExternalWebsite = url => {
provide("sendMessage", sendMessage)
provide("TAHomePage", TAHomePage)
// 处理点进投票
const handleVote = (token, index) => {
operationCollectHttp({ token }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
return
}
let data = res.data
let optionList = data["optionList"] || []
optionList[index]["selected"] = 1
option.value = optionList
isvote.value = 1
info.value.votes = data["votes"]
const commentsRef = ref(null)
let voteLoading = false
ElMessage.success(res.message)
})
// 处理点击投票
const handleVote = (token, index) => {
if (isNeedLogin.value) {
goLogin()
return
}
if (voteLoading) return
voteLoading = true
topHeadRef.value.count = {}
operationCollectHttp({ token })
.then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
return
}
let data = res.data
let optionList = data["optionList"] || []
optionList[index]["selected"] = 1
option.value = optionList
isvote.value = 1
info.value.votes = data["votes"]
const value = optionList[index]["value"]
commentsRef.value.changeCommentVoteoption(value)
ElMessage.success(res.message)
})
.finally(() => (voteLoading = false))
}
let unvoteVoteIndex = null // 选项下标
// 点击 取消投票
const handleUnvoteVote = (index, selected) => {
if (isNeedLogin.value) {
goLogin()
return
}
if (selected == 0) return
cancelPopoverState.value = true
unvoteVoteIndex = index
}
const unvoteVote = () => {
if (isNeedLogin.value) {
goLogin()
return
}
const token = option.value[unvoteVoteIndex].id
unvoteCollectHttp({ token }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
return
}
let data = res.data
let optionList = data["optionList"] || []
optionList[unvoteVoteIndex]["selected"] = 0
option.value = optionList
isvote.value = 0
info.value.votes = data["votes"]
cancelPopoverState.value = false
})
if (voteLoading) return
voteLoading = true
topHeadRef.value.count = {}
unvoteCollectHttp({ token })
.then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
return
}
let data = res.data
let optionList = data["optionList"] || []
optionList[unvoteVoteIndex]["selected"] = 0
option.value = optionList
isvote.value = 0
info.value.votes = data["votes"]
cancelPopoverState.value = false
commentsRef.value.wipeCommentVoteoption()
})
.finally(() => (voteLoading = false))
}
const clearAllData = () => {
@@ -227,6 +263,7 @@ const unbookmarkSamePage = () => {
iscollection.value = 0
info.value.favs--
}
provide("unbookmarkSamePage", unbookmarkSamePage)
// 删除同页面的投票需要跳转到 首页
@@ -250,6 +287,27 @@ const clearBottom = () => {
indexFooter.style.display = "none"
}
let topHeadRef = ref(null)
provide("topHeadRef", topHeadRef)
try {
if (process.server) {
await detailsHttp({ uniqid: id }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
router.push("/index.html")
return
}
let data = res.data
info.value = data["info"]
option.value = data["option"]
isvote.value = data["isvote"]
seo.value = data.seo
})
}
} catch (error) {}
</script>
<style scoped lang="less">
@@ -288,7 +346,7 @@ const clearBottom = () => {
.left {
width: 658px;
// height: 500px;
min-height: calc(100vh - 165px);
padding: 30px 42px 100px 30px;
border-right: 16px solid #f6f6f6;
.info {