|
|
|
@ -0,0 +1,312 @@
|
|
|
|
|
<script lang="ts">
|
|
|
|
|
import { defineComponent, ref, computed } from 'vue';
|
|
|
|
|
|
|
|
|
|
interface Message {
|
|
|
|
|
id: number;
|
|
|
|
|
content: string;
|
|
|
|
|
time: string;
|
|
|
|
|
detail: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
|
setup() {
|
|
|
|
|
const messages = ref<Message[]>([
|
|
|
|
|
{ id: 1, content: "这是第一条消息内容,点击查看更多", detail:"哈哈哈哈", time: "2025-05-31 10:30" },
|
|
|
|
|
{ id: 2, content: "这是第二条消息内容,点击查看更多", detail:"哈哈哈哈", time: "2025-05-31 11:15" },
|
|
|
|
|
{ id: 3, content: "这是第三条消息内容,点击查看更多", detail:"哈哈哈哈", time: "2025-05-31 12:00" },
|
|
|
|
|
{ id: 4, content: "这是第四条消息内容,点击查看更多", detail:"哈哈哈哈", time: "2025-05-31 12:45" },
|
|
|
|
|
{ id: 5, content: "这是第五条消息内容,点击查看更多", detail:"哈哈哈哈", time: "2025-05-31 13:30" },
|
|
|
|
|
{ id: 6, content: "这是第六条消息内容,点击查看更多", detail:"哈哈哈哈", time: "2025-05-31 14:15" },
|
|
|
|
|
{ id: 7, content: "这是第七条消息内容,点击查看更多", detail:"哈哈哈哈", time: "2025-05-31 15:00" },
|
|
|
|
|
// 可以添加更多消息
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
const currentPage = ref<number>(1);
|
|
|
|
|
const messagesPerPage = ref<number>(5);
|
|
|
|
|
const isModalOpen = ref<boolean>(false);
|
|
|
|
|
const selectedMessage = ref<Message | null>(null);
|
|
|
|
|
|
|
|
|
|
const totalPages = computed((): number => {
|
|
|
|
|
return Math.ceil(messages.value.length / messagesPerPage.value);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const currentPageMessages = computed((): Message[] => {
|
|
|
|
|
const startIndex = (currentPage.value - 1) * messagesPerPage.value;
|
|
|
|
|
const endIndex = startIndex + messagesPerPage.value;
|
|
|
|
|
return messages.value.slice(startIndex, endIndex);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const changePage = (pageNumber: number): void => {
|
|
|
|
|
if (pageNumber >= 1 && pageNumber <= totalPages.value) {
|
|
|
|
|
currentPage.value = pageNumber;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const openModal = (message : Message) :void => {
|
|
|
|
|
selectedMessage.value = message;
|
|
|
|
|
isModalOpen.value = true;
|
|
|
|
|
document.body.style.overflow="hidden";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const closeModal = () :void => {
|
|
|
|
|
selectedMessage.value = null;
|
|
|
|
|
isModalOpen.value = false;
|
|
|
|
|
document.body.style.overflow='';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
messages,
|
|
|
|
|
currentPage,
|
|
|
|
|
messagesPerPage,
|
|
|
|
|
totalPages,
|
|
|
|
|
currentPageMessages,
|
|
|
|
|
changePage,
|
|
|
|
|
isModalOpen,
|
|
|
|
|
selectedMessage,
|
|
|
|
|
openModal,
|
|
|
|
|
closeModal,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<div class="message-center">
|
|
|
|
|
<!-- 右侧主要内容区域 -->
|
|
|
|
|
<div class="main-content">
|
|
|
|
|
<!-- 顶部标题区域 -->
|
|
|
|
|
<div class="content-header">
|
|
|
|
|
<span class="header-title">评论回复</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 消息框区域 - 现在是垂直排列 -->
|
|
|
|
|
<div class="message-container">
|
|
|
|
|
<div v-for="(message, index) in currentPageMessages"
|
|
|
|
|
:key="index"
|
|
|
|
|
class="message-box"
|
|
|
|
|
@click="openModal(message)">
|
|
|
|
|
<div class="message-content">{{ message.content }}</div>
|
|
|
|
|
<div class="message-time">{{ message.time }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 分页控制区域 -->
|
|
|
|
|
<div class="pagination-controls" v-if="totalPages > 1">
|
|
|
|
|
<button
|
|
|
|
|
class="page-button"
|
|
|
|
|
:disabled="currentPage === 1"
|
|
|
|
|
@click="changePage(currentPage - 1)"
|
|
|
|
|
>
|
|
|
|
|
上一页
|
|
|
|
|
</button>
|
|
|
|
|
<span class="page-indicator">{{ currentPage }} / {{ totalPages }}</span>
|
|
|
|
|
<button
|
|
|
|
|
class="page-button"
|
|
|
|
|
:disabled="currentPage === totalPages"
|
|
|
|
|
@click="changePage(currentPage + 1)"
|
|
|
|
|
>
|
|
|
|
|
下一页
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="isModalOpen" class="modal-overlay">
|
|
|
|
|
<div class="modal-content">
|
|
|
|
|
<div class="modal-header">
|
|
|
|
|
<h3>消息详情</h3>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-body">
|
|
|
|
|
<p>{{ selectedMessage?.detail }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
|
<div class="message-time">{{ selectedMessage?.time }}</div>
|
|
|
|
|
<button class="confirm-button" @click="closeModal">关闭</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.message-center {
|
|
|
|
|
display: flex;
|
|
|
|
|
width: calc(100% - 100px); /* 减去侧边栏宽度 */
|
|
|
|
|
height: calc(100vh - 120px);
|
|
|
|
|
margin: 130px 20px 20px 350px; /* 左侧margin增加到120px,为侧边栏留出空间 */
|
|
|
|
|
padding: 0;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 主要内容区域样式 */
|
|
|
|
|
.main-content {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
flex: 1;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 顶部标题区域样式 */
|
|
|
|
|
.content-header {
|
|
|
|
|
height: 70px;
|
|
|
|
|
width:1267px;
|
|
|
|
|
background: rgba(255, 255, 255, 0.5);
|
|
|
|
|
backdrop-filter: blur(10px);
|
|
|
|
|
border: 2px solid rgba(133, 88, 207, 0.5);
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 0 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.header-title {
|
|
|
|
|
font-size: 30px;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
color: #7e7e7e;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 消息框容器样式 - 修改为垂直排列 */
|
|
|
|
|
.message-container {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column; /* 改为垂直排列 */
|
|
|
|
|
gap: 15px; /* 消息框之间的间距 */
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
overflow-y: auto; /* 如果内容过多可以滚动 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 单个消息框样式 */
|
|
|
|
|
.message-box {
|
|
|
|
|
width: 1275px; /* 宽度占满容器 */
|
|
|
|
|
min-height: 80px; /* 减小高度使垂直排列更紧凑 */
|
|
|
|
|
background: rgba(255, 255, 255, 0.7);
|
|
|
|
|
backdrop-filter: blur(5px);
|
|
|
|
|
border: 1px solid rgba(133, 88, 207, 0.3);
|
|
|
|
|
border-radius: 8px;
|
|
|
|
|
padding: 15px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
|
|
|
|
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.message-box:hover{
|
|
|
|
|
transform: translateY(-3px);
|
|
|
|
|
box-shadow: 0 20px 10px rgba(0, 0, 0, 0.1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.message-content{
|
|
|
|
|
font-size: 24px;
|
|
|
|
|
color:#333;
|
|
|
|
|
margin-bottom: 10px;
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.message-time{
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
color:#888;
|
|
|
|
|
text-align: right;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.pagination-controls{
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page-button{
|
|
|
|
|
background: rgba(133, 88, 207, 0.7);
|
|
|
|
|
color: white;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
padding: 8px 15px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
margin: 0 10px;
|
|
|
|
|
transition:background 0.2s;
|
|
|
|
|
position: relative;
|
|
|
|
|
right: 200px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page-button:hover:not(:disabled){
|
|
|
|
|
background: rgba(133, 88, 207, 0.9);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page-button:disabled{
|
|
|
|
|
background: rgba(133, 88, 207, 0.3);
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page-indicator{
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
color: #666;
|
|
|
|
|
position: relative;
|
|
|
|
|
right: 200px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-overlay{
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
background-color: rgba(255, 255, 255, 0.7);
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
z-index: 1000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-content{
|
|
|
|
|
background: #fff;
|
|
|
|
|
width: 600px;
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: 800px;
|
|
|
|
|
font-size: 28px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-header{
|
|
|
|
|
padding: 15px 20px;
|
|
|
|
|
border-bottom: 1px solid #eee;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-header h3{
|
|
|
|
|
margin: 0;
|
|
|
|
|
color: #333;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-body{
|
|
|
|
|
padding: 20px;
|
|
|
|
|
overflow-y: visible;
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-footer{
|
|
|
|
|
padding: 15px 20px;
|
|
|
|
|
border-top: 1px solid #eee;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.confirm-button{
|
|
|
|
|
background: rgba(133, 88, 207, 0.7);
|
|
|
|
|
color: white;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
padding: 8px 20px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: background 0.2s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.confirm-button:hover{
|
|
|
|
|
background: rgba(133, 88, 207, 0.9);
|
|
|
|
|
}
|
|
|
|
|
</style>
|