QMZ 1 month ago
commit a6c74706a7

@ -1,17 +1,35 @@
/* 设置进入和离开的过渡效果 */
/* 离开动画 */
.post-list .fade-leave-active {
transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}
.post-list .fade-leave-to /* 离开完成后状态 */
{
.post-list .fade-enter-active {
transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
}
/* 元素进入时,缩放并渐变 */
.post-list .fade-leave-to /* .fade-leave-active in Vue 2.x */ {
opacity: 0;
transform: translateX(100%) scale(0.5); /* 离开时从右边滑出并缩小 */
transform: scale(0.5); /* 初始状态为缩小 */
}
.post-list .fade-enter{
opacity: 0;
transform: scale(0.5); /* 初始状态为缩小 */
}
/* 元素进入时恢复到原尺寸 */
.post-list .fade-enter-to {
opacity: 1;
transform: scale(1); /* 变大恢复正常尺寸 */
}
/* 元素离开时,继续保持缩小状态 */
.post-list .fade-leave-to {
opacity: 0;
transform: scale(0.5); /* 离开时缩小 */
}

@ -4,9 +4,8 @@ import {getToken} from '@/token/auth' // 注意这里使用了解构赋值来导
// 创建axios实例
const service = axios.create({
// baseURL: 'http://47.122.59.26:8080/api',
// baseURL: 'http://10.205.10.22:8081/loveforest/api/',
// baseURL: 'http://10.133.13.52:8082/loveforest',
// 去vue.config.js文件改baseurl
baseURL: '/api', // 注意!! 这里全局统一加上了 '/api' 前缀但是vue.config.js文件在发送请求时去掉了/api所以页面的请求接口若有/api还是要携带/api
timeout: 5000, // 请求超时时间
});

@ -176,6 +176,7 @@ export default {
this.showSearchList = this.friendsInfoList
this.get_friendsInfoList()
this.long_poll_serve()
},
components:{
HonneyBtn,
@ -184,6 +185,42 @@ export default {
ChatList
},
methods:{
async long_poll_serve(){
try{
const UserId = getUserId()
const token = 'Bearer '+getToken()
const response = await axios.get(`messages/poll/${UserId}`,{
headers:{Authorization : token}
})
if(response.data == '')
{
this.long_poll_serve()
}else{
const senderId = response.data[response.data.length-1].senderId
console.log(senderId)
for(let i = 0;i<this.friendsInfoList.length;i++){
if(this.friendsInfoList[i].id == senderId){
if(this.chatWith != this.friendsInfoList[i].name){
this.friendsInfoList[i].unreading_num += 1
this.new_msg_nums += 1
}
let tempt_chat = {name:'',content:'',time:''}
let response2 = await axios.get(`/messages/chat/${UserId}/${senderId}`,{
headers:{Authorization : token}
})
tempt_chat.name = this.friendsInfoList[i].name
tempt_chat.content = response2.data[response2.data.length-1].content
tempt_chat.time = response2.data[response2.data.length-1].timestamp.replace('T',' ')
this.friendsInfoList[i].chatHistory.push(tempt_chat)
break
}
}
this.long_poll_serve()
}
}catch(error){
alert('长轮询失败',error)
}
},
async revise_honneyBtn_status(userId1,userId2,status){
//
try{

@ -1,5 +1,4 @@
<template>
<div class="post-card">
<div class="post-header">
<img :src="avatarUrl" alt="avatar" class="avatar" />
@ -16,31 +15,11 @@
</div>
</button>
<span>{{ timestamp }}</span>
</div>
<div style="right: -50%;position: relative;">
<button class="deletebutto" @click="openModal" v-if="this.userid===this.postuserid&&!showModal">
×
删除
</button>
<transition name="fade" @before-enter="beforeEnter" @enter="enter" @leave="leave">
<div v-if="showModal">
<button @click="deletebutton" class="deletebutto">确定</button>
<button @click="cancelDelete" class="deletebutto">取消</button>
</div>
</transition>
</div>
<div v-if="isfamilystory" class="ribbon-8">
<span>
家族故事
@ -72,8 +51,7 @@
<transition name="fade" @before-enter="beforeEnter" @enter="enter" @leave="leave">
<div v-if="isCommentsVisible" class="comments-section">
<div v-for="(comment, index) in comments" :key="index" class="comment">
<p><strong>{{ comment.userid}}:</strong> {{ comment.content }} <button v-if="comment.userid==this.userid" style="color:#FE4E96;"
@click="deletecomment(comment.commentid)">删除</button> </p>
<p><strong>{{ comment.userid}}:</strong> {{ comment.content }}</p>
</div>
<!-- 发布评论 -->
@ -85,7 +63,7 @@
<script>
import CommentInput from './CommentInput.vue';
import axios from '@/utils/axiosConfig';
import axios from 'axios';
export default {
@ -116,11 +94,11 @@
},
created() {
if (this.userlikelist.some(follow => follow.postid === this.postid)) {// postid
if (this.userlikelist.some(follow => follow.postid === this.postid)) {
this.isLiked = true;
}
if (this.myfollows.some(follow => follow.myfollowid === this.postuserid)) {// postuserid
if (this.myfollows.some(follow => follow.myfollowid === this.postuserid)) {
this.followsbuttonActive = true;
}
@ -134,7 +112,6 @@
},
data() {
return {
showModal: false,
isActive: false,
isLiked: false,
isClicked: false,
@ -143,56 +120,7 @@
};
},
methods: {
async deletecomment(commentid) {
try {
const response = await axios.delete(`/comments/commentid=${commentid}`);
if (response === "删除评论成功!!") {
this.$message.success("删除评论成功!!可刷新后查看");
}
else {
this.$message.error(response);
}
} catch (error) {
this.$message.error("删除评论失败");
console.log(error);
}
},
cancelDelete() {
//
this.showModal = false;
},
openModal() {
this.showModal = true;
},
async deletebutton() {
try {
const response = await axios.delete(`/posts/postid=${this.postid}`);
if (response === "删除动态成功 ") {
this.$message.success("删除动态成功 !!可刷新后查看");
}
else {
this.$message.error(response);
}
} catch (error) {
this.$message.error("删除动态失败");
console.log(error);
}
this.showModal = false;
},
async followsbutton() {//
// active
const useride = this.userid;
@ -200,14 +128,14 @@
if (this.followsbuttonActive == false) {
try {
const response = await axios.post(`/Myfollows/userid=${useride}/myfollowid=${this.postuserid}`);
if (response === "关注成功!") {
const response = await axios.post(`http://localhost:8082/loveforest/Myfollows/userid=${useride}/myfollowid=${this.postuserid}`);
if (response.data === "关注成功!") {
this.$message.success(response);
this.$message.success(response.data);
this.followsbuttonActive = true;
}
else {
this.$message.error(response);
this.$message.error(response.data);
}
} catch (error) {
@ -221,14 +149,14 @@
else {
try {
const response = await axios.delete(`/Myfollows/userid=${useride}/myfollowid=${this.postuserid}`);
if (response === "取消关注成功!") {
this.$message.success(response);
const response = await axios.delete(`http://localhost:8082/loveforest/Myfollows/userid=${useride}/myfollowid=${this.postuserid}`);
if (response.data === "取消关注成功!") {
this.$message.success(response.data);
this.followsbuttonActive = false;
}
else {
this.$message.error(response);
this.$message.error(response.data);
}
} catch (error) {
@ -252,15 +180,15 @@
async increaseLikeCount() {//
if (!this.isLiked) {//
try {
const response = await axios.post(`/likes/userid=${this.userid}/postid=${this.postid}`);
if (response === "点赞成功!") {
this.$message.success(response);
const response = await axios.post(`http://localhost:8082/loveforest/likes/userid=${this.userid}/postid=${this.postid}`);
if (response.data === "点赞成功!") {
this.$message.success(response.data);
this.$emit('updateLikeCount', this.likeCount + 1);
this.isLiked = !this.isLiked;
}
else {
this.$message.error(response);
this.$message.error(response.data);
}
} catch (error) {
@ -270,16 +198,16 @@
}
else {//
try {
const response = await axios.delete(`/likes/userid=${this.userid}/postid=${this.postid}`);
if (response === "取消点赞成功!") {
const response = await axios.delete(`http://localhost:8082/loveforest/likes/userid=${this.userid}/postid=${this.postid}`);
if (response.data === "取消点赞成功!") {
this.$message.success("取消点赞成功");
this.$message.error("取消点赞成功");
this.$emit('updateLikeCount', this.likeCount - 1);
this.isLiked = !this.isLiked;
}
else {
this.$message.error(response);
this.$message.error(response.data);
}
} catch (error) {
@ -317,80 +245,6 @@
</script>
<style scoped>
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.5s ease-in-out;
/* 渐变动画 */
}
.fade-enter,
.fade-leave-to {
opacity: 0;
/* 初始透明度 */
}
/* 可选:按钮在进入时的缩放效果 */
.fade-enter {
transform: scale(0.8);
}
.fade-enter-active {
transition: opacity 0.3s ease, transform 0.3s ease;
}
.fade-leave-active {
transition: opacity 0.3s ease, transform 0.3s ease;
}
.fade-leave-to {
opacity: 0;
transform: scale(0.8);
}
/* 控制显示时的定位变化 */
.fade-enter-to {
transform: translateY(0);
}
.fade-leave-to {
transform: translateY(-10px);
}
.modal-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0);
display: flex;
justify-content: center;
align-items: center;
z-index: 999;
}
.deletebutto {
margin-left: 10px;
margin-right: 10px;
position: relative;
width: 70px;
height: 30px;
line-height: 30px;
/* 修改 line-height 为与高度一致 */
border: none;
border-radius: 30px;
background: #FE4E96;
color: #fff;
text-align: center;
cursor: pointer;
font-size: 14px;
}
.postimage {
max-width: 600px;
max-height: 600px;
@ -494,12 +348,12 @@
}
.post-card {
opacity: 0.9;
opacity: 0.95;
margin: 20px;
border: 1px solid #ddd;
padding: 15px;
border-radius: 15px;
background-color: #FFFBFB;
border-radius: 8px;
background-color: #fff;
}
.post-header {

@ -238,9 +238,8 @@
}
.animate-card__layer {
height: 16px;
width: 7%;
font-size: 14px;
height: 5%;
width: 5%;
background-color: #FE4E96;
border: none;
}

@ -76,7 +76,7 @@
</div>
<div class=heatlist style="margin-top:20px;display: flex;flex-direction:row;">
<div
style="position:relative; display: flex;flex-direction:column; color: white; font-weight: bold;margin-left: 20px ;gap:51px;margin-top:10px">
style="position:relative; display: flex;flex-direction:column; color: white; font-weight: bold;margin-left: 20px ;gap:51px">
<div class=Hotsearchnum style="background-color:red;">1</div>
<div class=Hotsearchnum style="background-color:#ff8e51;">2</div>
<div class=Hotsearchnum style="background-color:#ffc74fd2;">3</div>
@ -85,16 +85,16 @@
</div>
<div
style="font-size: 14px; font-weight: 500; margin-left: 20px; display: flex; flex-direction: column; gap: 17px;width: 100%; ">
style="font-size: 14px; font-weight: 500; margin-left: 30px; display: flex; flex-direction: column; gap: 17px;width: 100%;">
<div
style="overflow: hidden; list-style-type: none; width: 90%; height: 20%;max-height: 60px; background-color: rgba(255, 225, 240, 0.7); border-radius: 10%; position: relative; cursor: pointer;"
style="overflow: hidden; list-style-type: none; width: 90%; height: 20%; background-color: rgba(255, 225, 240, 0.7); border-radius: 10%; position: relative; cursor: pointer;"
v-for="(Hotsearch, index) in HotsearchList" :key="index" @click="checkbypostid(Hotsearch.postid)">
<div style=" font-weight: bold; margin-left: 10%; margin-top: 1%; ">{{ Hotsearch.username }}:</div>
<div style="left:10%;width: 70%; font-size: 12px;position: relative;">{{ Hotsearch.content}}</div>
<svg width="20" height="20" viewBox="0 0 15 15" xmlns="http://www.w3.org/2000/svg" id="fire-station"
style="position: absolute;right:5.8% ;top:20%;fill:red ">
style="position: absolute;right:7% ;top:20%;fill:red ">
<path
d="M7.5 14C11.0899 14 14 11 14 7.50003C14 4.5 11.5 2 11.5 2L10.5 5.5L7.5 1L4.5 5.5L3.5 2C3.5 2 1 4.5 1 7.50003C1 11 3.91015 14 7.5 14ZM7.5 12.5C6.11929 12.5 5 11.3807 5 10C5 8.61929 7.5 5.5 7.5 5.5C7.5 5.5 10 8.61929 10 10C10 11.3807 8.88071 12.5 7.5 12.5Z" />
</svg>
@ -123,8 +123,8 @@
</div>
<div class="familystorelist"
style="margin-top: 20px; display: flex; justify-content: center; flex-direction: column; gap: 10px;margin-left: 20px;">
<div v-for="(story, index) in checkfamilystories" :key="index" class="familystore"
style="margin-top: 20px; display: flex; justify-content: center; flex-direction: column; gap: 10px;">
<div v-for="(story, index) in familystories" :key="index" class="familystore"
style="width: 95%; height: 70px; background-color: rgba(255, 225, 240, 0.7); border-radius: 10%; position: relative;cursor: pointer;"
@click="checkbypostid(story.postid)">
<img class="touxiang" src="../../assets/pictures/touxiang.png" />
@ -157,13 +157,12 @@
hoverIndex: -1,
selectedIndex: -1,
isloading: false,
loaddone: 0,
checkPostsindex: 0,
checkPosts: [],
page: 1,
userid: 1,
totalPages: 1,
familystoriespage:0,
checkfamilystories:[],
posts: [
{
@ -211,14 +210,14 @@
async fllowlist() {
const userid = this.userid;//id
axios.get(`/Myfollows/userid=${userid}`)
axios.get(`http://localhost:8082/loveforest/Myfollows/userid=${userid}`)
.then(response => {
this.myfollows.splice(0, this.myfollows.length);
this.myfollows.push(...response);
this.myfollows.push(...response.data);
return response;
return response.data;
})
.catch(error => {
console.error('Error:', error);
@ -227,20 +226,20 @@
},
submitPost(newpost) {//
this.checkPosts.unshift(newpost);
this.checkPosts = [newpost, ...this.checkPosts];
},
async load() {//
if (this.isloading) {
try {
const response = await axios.get(`/posts`, {
const response = await axios.get(`http://localhost:8082/loveforest/posts`, {
params: {
page: this.page,
size: 5,
},
});
const filteredPostsList = response.records;
const filteredPostsList = response.data.records;
this.$message("动态加载中page" + this.page);
@ -257,16 +256,14 @@
try {
const response = await axios.get(`/posts/postid=${postid}`);
const response = await axios.get(`http://localhost:8082/loveforest/posts/postid=${postid}`);
this.isloading = false;
console.error('动态动态!!!!:',response);
this.checkPosts.splice(0, this.checkPosts.length);
this.checkPosts.push(response);
this.checkPosts.push(response.data);
} catch (error) {
console.error('动态获取失败', error);
}
@ -274,13 +271,13 @@
async loaduserlikes() {//user
const userid = this.userid;//id
axios.get(`/likes/userid=${userid}`)
axios.get(`http://localhost:8082/loveforest/likes/userid=${userid}`)
.then(response => {
this.userlikelist.splice(0, this.userlikelist.length);
this.userlikelist.push(...response);
this.userlikelist.splice(0, this.myfollows.length);
this.userlikelist.push(...response.data);
return response;
return response.data;
})
.catch(error => {
console.error('Error:', error);
@ -299,9 +296,9 @@
},
async loadhotpost() {//
try {
const response = await axios.get(`/posts/topposts`);
this.HotsearchList.push(...response);
const response = await axios.get(`http://localhost:8082/loveforest/posts/topposts`);
this.HotsearchList.push(...response.data);
console.log(response.data);
} catch (error) {
this.$message.error("热门动态获取失败");
@ -312,9 +309,8 @@
async loadhotfamilystory() {//
try {
const response = await axios.get(`/posts/topfamilystory`);
this.familystories.push(...response);
this.checkfamilystories.push(...response.slice(0, 4));
const response = await axios.get(`http://localhost:8082/loveforest/posts/topfamilystory`);
this.familystories.push(...response.data);
} catch (error) {
@ -330,12 +326,12 @@
this.selectedIndex = index; //
try {
const response = await axios.get(`/posts/userid=${userid}`);
const response = await axios.get(`http://localhost:8082/loveforest/posts/userid=${userid}`);
this.isloading = false;
this.checkPosts.splice(0, this.checkPosts.length);
this.checkPosts.push(...response);
if (response.length === 0) {
this.checkPosts.push(...response.data);
if (response.data.length === 0) {
this.$message("对方还没有发过动态哦");
}
@ -372,7 +368,7 @@
async addComment(index, commentText, postid) {//
try {
const response = await axios.post('/comments/addcomments', {
const response = await axios.post('http://localhost:8082/loveforest/comments/addcomments', {
userid: this.userid,
postid: postid,
content: commentText
@ -395,7 +391,7 @@
this.checkPosts[index].commentCount += 1;
}
else {
this.$message.error(response);
this.$message.error(response.data);
}
} catch (error) {
@ -409,14 +405,6 @@
refresh() {//
//
console.log('Refreshing...');
this.familystoriespage+=4;
if(this.familystoriespage>12){
this.familystoriespage=0;
}
this.checkfamilystories.splice(0, this.checkfamilystories.length);
this.checkfamilystories.push(...this.familystories.slice(this.familystoriespage, this.familystoriespage+4));
this.triggerAnimation();
},

@ -246,7 +246,7 @@ export default {
this.$router.push('/main');
} catch (error) {
//
console.error('登录错误:', error);
alert('登录错误:', error);
}
}else{
alert("验证码错误")
@ -262,18 +262,16 @@ export default {
}
try {
//
const response = await axios.post('', null, {
params:{
username: this.regUser.regUsername,
password: this.regUser.regPwd,
}
});
const response = await axios.post('/auth/register', {
username: this.regUser.regUsername,
password: this.regUser.regPwd
}, {});
//
alert('注册成功');
console.log('注册成功', response);
} catch (error) {
//
console.error('注册失败', error);
alert('注册失败'+ error);
}
}
},

@ -5,31 +5,48 @@ module.exports = defineConfig({
port: 8080,
https: false,
proxy:{
//登录接口
'/auth/login':{
target : 'https://911fb0525ms3.vicp.fun/loveforest/api',
changeOrigin : true,
'/api': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
//获取好友列表接口
'/relationships':{
target : 'https://911fb0525ms3.vicp.fun/loveforest/api',
changeOrigin : true
'/relationships': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
//获取相应的聊天记录的接口
'/messages/chat':{
target : 'https://911fb0525ms3.vicp.fun/loveforest/api',
changeOrigin : true
'/messages/chat': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
//保存聊天的一条消息接口
'/messages/send':{
target : 'https://911fb0525ms3.vicp.fun/loveforest/api',
changeOrigin : true
'/messages/mark-as-read': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
'/messages/send': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
'messages/poll': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
//新消息是否被已读的接口
'/messages/mark-as-read':{
target : 'https://911fb0525ms3.vicp.fun/loveforest/api',
changeOrigin : true
}
}
},
transpileDependencies: true

Loading…
Cancel
Save