helloworld180 1 month ago
parent 0504222892
commit 7808e0d3d3

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 KiB

@ -17,7 +17,7 @@
<el-menu-item index="2-1">私信聊天</el-menu-item>
<el-menu-item index="2-2">社区动态</el-menu-item>
</el-sub-menu>
<el-menu-item index="3" disabled>情感助手</el-menu-item>
<!-- <el-menu-item index="3" disabled>情感助手</el-menu-item> -->
<el-menu-item index="4">个人空间</el-menu-item>
<div class="tu">
<img src="@/assets/pictures/tu.png" alt="tu" />

@ -202,7 +202,7 @@
</template>
<script>
import axios from '../utils/axiosConfig';
// import axios from '../utils/axiosConfig';
export default {
name: "PreferenceForm",
data() {
@ -331,17 +331,17 @@ export default {
const isValid = await this.$refs.form.validate();
if (isValid) {
//
const response = await axios.post('/auth/login', {
formData:this.formData
})
if (response.code === 200) {
// const response = await axios.post('/auth/login', {
// formData:this.formData
// })
// if (response.code === 200) {
// Recommenduser
this.$router.push('/main/recommend/recommenduser');
this.$message({
type: "success",
message: "偏好已生成",
});
}
// }
} else {
//
this.$message.error("请检查表单填写是否正确");

@ -4,7 +4,7 @@
<div class="rectangle-box">
<h1 class="title">推荐用户</h1>
<p class="subtitle">根据你的恋爱偏好为您推荐以下用户</p>
<button class="add-button">添加</button>
<div class="add-button" @click="addBtn"></div>
<div class="user-card">
<img class="avatar" src="@/assets/pictures/touxiang.png" alt="用户头像">
@ -137,6 +137,12 @@ export default {
return {
//
}
},
methods: {
addBtn() {
alert('此功能仅对VIP用户开放');
console.log('Add button clicked');
}
}
}
</script>

@ -5,7 +5,7 @@ import {getToken} from '@/token/auth' // 注意这里使用了解构赋值来导
// 创建axios实例
const service = axios.create({
// 去vue.config.js文件改baseurl
baseURL: 'http://10.133.25.59:8083/loveforest/api', // 注意!! 这里全局统一加上了 '/api' 前缀但是vue.config.js文件在发送请求时去掉了/api所以页面的请求接口若有/api还是要携带/api
baseURL: 'http://10.133.102.216:8080/loveforest/api', // 注意!! 这里全局统一加上了 '/api' 前缀但是vue.config.js文件在发送请求时去掉了/api所以页面的请求接口若有/api还是要携带/api
timeout: 5000, // 请求超时时间
});
@ -20,6 +20,7 @@ service.interceptors.request.use(
config.headers['Authorization'] = `Bearer ${token}`; // 设置token
// axios.defaults.headers.common['Authorization'] = 'Bearer ' + token;
}
// console.log('请求头:',config.headers);
config.headers['Accept'] = 'application/json';
return config;
},

@ -88,7 +88,7 @@ import HonneyBtn from './HonneyBtn.vue';
import ChatCard from './ChatCard.vue';
import ChatList from './ChatList.vue';
import {getToken,getUserId} from '@/token/auth'
import axios from 'axios';
import axios from '../../utils/axiosConfig';
export default {
name: 'chatIndex', //
data(){
@ -213,29 +213,29 @@ export default {
const response = await axios.get(`messages/poll/${UserId}`,{
headers:{Authorization : token}
})
if(response.data == '')
if(response == '')
{
this.long_poll_serve()
}else{
const senderId = response.data[response.data.length-1].senderId
const senderId = response[response.length-1].senderId
console.log(senderId)
for(let i = 0;i<this.friendsInfoList.length;i++){
if(this.friendsInfoList[i].id == senderId){
let response2 = await axios.get(`/messages/chat/${UserId}/${senderId}`,{
headers:{Authorization : token}
})
if(this.friendsInfoList[i].chatHistory.slice(-1)[0].time == response2.data[response2.data.length-1].timestamp.replace('T',' ')){
if(this.friendsInfoList[i].chatHistory.slice(-1)[0].time == response2[response2.length-1].timestamp.replace('T',' ')){
break
}
console.log(this.friendsInfoList[i].chatHistory.slice(-1),response2.data[response2.data.length-1].timestamp.replace('T',' '))
console.log(this.friendsInfoList[i].chatHistory.slice(-1),response2[response2.length-1].timestamp.replace('T',' '))
if(this.chatWith != this.friendsInfoList[i].name){
this.friendsInfoList[i].unreading_num += 1
this.new_msg_nums += 1
}
let tempt_chat = {name:'',content:'',time:''}
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',' ')
tempt_chat.content = response2[response2.length-1].content
tempt_chat.time = response2[response2.length-1].timestamp.replace('T',' ')
this.friendsInfoList[i].chatHistory.push(tempt_chat)
break
}
@ -243,7 +243,7 @@ export default {
this.long_poll_serve()
}
}catch(error){
alert('长轮询失败',error)
// alert('',error)
}
},
async revise_honneyBtn_status(userId1,userId2,status){
@ -256,7 +256,7 @@ export default {
},{
headers:{Authorization : 'Bearer '+getToken()}
})
console.log(response.data)
console.log(response)
}catch(error){
alert('好友状态修改失败',error)
}
@ -267,7 +267,7 @@ export default {
const response = await axios.post(`/messages/mark-as-read/${senderId}/${receiverId}`,{},{
headers:{Authorization : 'Bearer '+getToken()}
})
console.log(response.data)
console.log(response)
}catch(error){
alert('消息已读失败',error)
}
@ -282,7 +282,7 @@ export default {
},{
headers:{Authorization : 'Bearer '+getToken()}
})
console.log(response.data)
console.log(response)
}catch(error){
alert('消息保存失败',error)
}
@ -297,7 +297,7 @@ export default {
const response1 =await axios.get(`/relationships/${UserId}`,{
headers:{Authorization : token}
})
const data = response1.data
const data = response1
console.log(data)
for(let i = 0;i< data.length;i++)
@ -319,7 +319,7 @@ export default {
})
}
let chat_history = response2.data
let chat_history = response2
console.log(chat_history)
if(chat_history.length != 0){

@ -196,6 +196,7 @@ export default {
regRePwd:'',
regPwd:'',
code:'',
photos:''
},
styleObj:{
bordertoprightradius:'15px',
@ -261,17 +262,21 @@ export default {
alert('验证码错误')
}
try {
const defaultAvatarUrl = "https://file.moyublog.com/d/file/2023-03-03/d06a216a9182eb9f13843c222c7d86bb.jpg";
//
const response = await axios.post('/auth/register', {
username: this.regUser.regUsername,
password: this.regUser.regPwd
password: this.regUser.regPwd,
photos: defaultAvatarUrl
}, {});
//
// this.isShow = true;
alert('注册成功');
console.log('注册成功', response);
} catch (error) {
//
alert('注册失败'+ error);
console.log('注册失败', error);
}
}
},

@ -4,7 +4,7 @@
<div class="rectangle-box">
<h1 class="title">推荐用户</h1>
<p class="subtitle">根据你的恋爱偏好为您推荐以下用户</p>
<button class="add-button"></button>
<button class="add-button" @click="addBtn"></button>
<div class="user-card">
<img class="avatar" src="@/assets/pictures/touxiang.png" alt="用户头像">
@ -137,6 +137,11 @@ export default {
return {
//
}
},
methods: {
addBtn() {
alert('该功能仅对VIP用户开放')
}
}
}
</script>

@ -129,10 +129,11 @@
</template>
<script>
import {getUserId} from '@/token/auth'
import TreeChart from 'vue-tree-chart-3'
import { ElMessage } from 'element-plus'
import { Plus } from '@element-plus/icons-vue'
import request from '@/utils/axiosConfig'
import request from '../../utils/axiosConfig'
import { flattenTree } from '@/utils/treeUtils'
export default {
@ -288,6 +289,7 @@ export default {
},
created() {
this.fetchTreeData()
this.userId = getUserId();
},
methods: {
//
@ -307,10 +309,10 @@ export default {
// avatar image_url使 require
try {
// 使 require
node.image_url = node.image_url ? require('@/assets/pictures/space/' + node.image_url) : require('@/assets/pictures/space/Inbase.png')
node.image_url = node.image_url ? require('@/assets/pictures/space/' + node.image_url) : require('@/assets/pictures/1.png')
} catch (e) {
// require 使
node.image_url = require('@/assets/pictures/space/Inbase.png')
node.image_url = require('@/assets/pictures/1.png')
}
//
@ -378,13 +380,12 @@ export default {
this.currentMember.image_url = e.target.result
}
reader.readAsDataURL(file)
this.currentMember.file = file;
//
// const formData = new FormData()
// formData.append('file', file)
// API...
},
//
async saveMember() {
const isValid = await new Promise((resolve) => {
@ -398,18 +399,49 @@ export default {
}
try {
const formData = new FormData();
// FormData
formData.append('name', this.currentMember.name);
formData.append('parentId', this.currentMember.parentId);
formData.append('relation', this.currentMember.relation);
formData.append('birthDate', this.currentMember.birthDate);
formData.append('phone', this.currentMember.phone);
formData.append('isCurrentUser', this.currentMember.isCurrentUser);
// FormData
if (this.currentMember.file) {
formData.append('file', this.currentMember.file);
}
const url = this.currentMember.id ?
`/family-tree/${this.currentMember.id}` :
'/family-tree'
'/family-tree';
await request({
url,
method: this.currentMember.id ? 'put' : 'post',
data: this.currentMember
})
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
}
});
ElMessage.success('保存成功');
this.dialogVisible = false;
this.fetchTreeData();
// const url = this.currentMember.id ?
// `/family-tree/${this.currentMember.id}` :
// '/family-tree'
// await request({
// url,
// method: this.currentMember.id ? 'put' : 'post',
// data: this.currentMember
// })
// console.log(':',response) response
ElMessage.success('保存成功')
this.dialogVisible = false
this.fetchTreeData()
// ElMessage.success('')
// this.dialogVisible = false
// this.fetchTreeData()
} catch (error) {
console.log('新增成员失败', this.currentMember)
ElMessage.error('保存失败')

@ -10,7 +10,7 @@
<img :src="user.avatar || defaultAvatar" alt="Avatar" class="avatar">
<!-- 编辑头像 -->
<label for="avatar-upload" class="edit-icon">
<input type="file" id="avatar-upload" @change="uploadImage" hidden>
<input type="file" id="avatar-upload" @change="uploadImage" accept="image/*" hidden>
</label>
</div>
@ -53,10 +53,10 @@ export default {
return {
user: {
avatar: '',
account: 'Charlene Reed',
account: '用户',
email: 'charlenereed@gmail.com',
birthday: '1990-01-25',
job: 'San Jose, California, USA',
job: '程序员',
name: 'Charlene Reed',
password: '',
location: 'San Jose, California, USA',
@ -67,11 +67,32 @@ export default {
},
methods: {
//
uploadImage(event) {
async uploadImage(event) {
const file = event.target.files[0];
if (file) {
this.user.avatar = URL.createObjectURL(file);
}
// if (!file) return;
// const formData = new FormData();
// formData.append('file', file);
// try {
// const response = await axios.post('/api/upload', formData, {
// headers: {
// 'Content-Type': 'multipart/form-data'
// }
// });
// if (response.data.url) {
// this.user.avatar = response.data.url;
// } else {
// throw new Error('');
// }
// } catch (error) {
// console.error(':', error);
// alert('');
// }
},
//
async fetchUserInfo() {

@ -7,7 +7,7 @@
<div class="avatar-container">
<img :src="userInfo.avatar || defaultAvatar" alt="Avatar" class="avatar">
<!-- 更多信息按钮 -->
<button @click="editProfile" class="showFamilytree-btn" v-if="!this.userId">
<button @click="editProfile" class="showFamilytree-btn" v-if="!userId">
<img src="../../assets/pictures/space/more.png" alt="" style="width: 80px;">
</button>
<!-- 族谱树按钮 -->
@ -19,15 +19,15 @@
<!-- 基本信息 -->
<div class="user-info">
<h2 style="margin-bottom: 30px;">{{ userInfo.name || "加载中..." }}</h2>
<h2 style="margin-bottom: 30px;">{{ userInfo.name || "用户" }}</h2>
<div class="info-container">
<p style="margin-right: 20px;">
<img src="../../assets/pictures/space/map.png" style="width: 19px; margin-right: 5px;">
{{ userInfo.location || "加载中..." }}
{{ userInfo.location || "San Jose,California,USA" }}
</p>
<p>
<img src="../../assets/pictures/space/calendar.png" style="width: 17px; margin-right: 5px">
{{ userInfo.joinedDate || "加载中..." }}
{{ userInfo.joinedDate || "1990/01/25" }}
</p>
</div>
</div>
@ -38,29 +38,29 @@
<img src="../../assets/pictures/space/interest.png" alt="">
<span class="in-text">
<span class="title">兴趣爱好:</span>
<span class="text-content" id="interest">{{ userInfo.interests || "加载中..." }}</span>
<span class="text-content" id="interest">{{ userInfo.interests || "gali建帅 马思唯最好" }}</span>
</span>
</p>
<p>
<img src="../../assets/pictures/space/double.png" alt="">
<span class="in-text">
<span class="title">择偶期望:</span>
<span class="text-content" id="expectation">{{ userInfo.expectation || "加载中..." }}</span>
<span class="text-content" id="expectation">{{ userInfo.expectation || "长期关系" }}</span>
</span>
</p>
<p>
<img src="../../assets/pictures/space/career.png" alt="">
<span class="in-text">
<span class="title">职业:</span>
<span class="text-content" id="career">{{ userInfo.career || "加载中..." }}</span>
<span class="text-content" id="career">{{ userInfo.career || "程序员" }}</span>
</span>
</p>
</div>
<!-- 操作按钮 -->
<div class="actions">
<button @click="logout" v-if="!this.userId">退</button>
<button @click="privateChat" v-if="this.userId"></button>
<button @click="logout" v-if="!userId">退</button>
<button @click="privateChat" v-if="userId"></button>
</div>
</div>
@ -112,10 +112,8 @@
name:'spaceIndex',
data() {
return {
myId: 0,
userlikelist:[],
// myfollows: [],
userInfo: {
name: "", //
avatar:"",
@ -160,14 +158,14 @@
isLiked:false,
},
],
defaultAvatar: "https://via.placeholder.com/150", //
defaultAvatar: require("../../assets/pictures/space/avatar.png"), //
};
},
methods: {
async loaduserlikes() {//user
const userid = this.userId;//id
const requestId = this.userId || this.myId;//id
try {
const response = await axios.get(`/likes/userid=${userid}`);
const response = await axios.get(`/likes/userid=${requestId}`);
this.userlikelist = response; // Store the liked post IDs
// Update isLiked status for all posts
@ -180,9 +178,8 @@
console.error('Error:', error);
}
axios.get(`/likes/userid=${userid}`)
axios.get(`/likes/userid=${requestId}`)
.then(response => {
// this.userlikelist.splice(0, this.myfollows.length);
this.userlikelist.push(...response);
return response;
})
@ -194,12 +191,11 @@
}
},
async handleLike(post) {//
const requestId = this.userId || this.myId;
if (!post.isLiked) {//
try {
const response = await axios.post(`/likes/userid=${this.userId}/postid=${post.id}`);
const response = await axios.post(`/likes/userid=${requestId}/postid=${post.id}`);
if (response === "点赞成功!") {
// this.$message.success(response);
// this.$emit('updateLikeCount', this.likeCount + 1);
post.isLiked = !post.isLiked;
post.likeCount = post.likeCount + 1 ;
}
@ -213,10 +209,8 @@
}
else {//
try {
const response = await axios.delete(`/likes/userid=${this.userId}/postid=${post.id}`);
const response = await axios.delete(`/likes/userid=${requestId}/postid=${post.id}`);
if (response === "取消点赞成功!") {
// this.$message.success("");
// this.$emit('updateLikeCount', this.likeCount - 1);
post.isLiked = !post.isLiked;
post.likeCount = post.likeCount - 1;
}
@ -233,24 +227,14 @@
async fetchUserInfo() {
await this.loaduserlikes();
try {
const requestId = this.userId || this.myId;
//
const response = await axios.get("/api/getUserInfo", {
const response = await axios.get("/getUserInfo", {
params: {
userId: this.userId, // ID
userId: requestId,
},
});
//
// {
// avatar: "https://example.com/avatar.jpg",
// name: "John Doe",
// location: "San Jose, California",
// joinedDate: "2021-01-01",
// interests: ", , ",
// expectation: "",
// career: ""
// }
//
this.userInfo.avatar = response.data.avatar;
this.userInfo.name = response.data.name;
@ -261,17 +245,12 @@
this.userInfo.career = response.data.career;
} catch (error) {
console.error("获取用户信息失败:", error);
// alert("");
}
},
async fetchPostInfo() {
try {
// const userId = this.userId; //
const postResponse = await axios.get(`/posts/userid=${this.userId}`, {
// params: {
// userId: userId
// }
});
const requestId = this.userId || this.myId;
const postResponse = await axios.get(`/posts/userid=${requestId}`);
//
this.posts = postResponse.map(post => ({
id: post.postid,
@ -300,13 +279,14 @@
},
logout() {
this.$router.push('/')
}
},
},
mounted() {
// ID
this.myId = getUserId();
//
this.fetchUserInfo();
this.fetchPostInfo();
this.myId = getUserId();
},
};
</script>

@ -6,42 +6,42 @@ module.exports = defineConfig({
https: false,
proxy:{
'/api': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'http://10.133.25.59:8083/loveforest', //代理的目标地址
target: 'http://10.133.102.216:8080/loveforest', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
'/relationships': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
target: 'http://10.133.102.216:8080/loveforest', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
'/messages/chat': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
target: 'http://10.133.102.216:8080/loveforest', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
'/messages/mark-as-read': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
target: 'http://10.133.102.216:8080/loveforest', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
'/messages/send': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
target: 'http://10.133.102.216:8080/loveforest', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容
}
},
'messages/poll': { //设置拦截器 拦截器格式 斜杠+拦截器名字,名字可以自己定
target: 'https://911fb0525ms3.vicp.fun/loveforest/api/', //代理的目标地址
target: 'http://10.133.102.216:8080/loveforest', //代理的目标地址
changeOrigin: true, //是否设置同源,输入是的
pathRewrite: { //路径重写
'^/api': '' //选择忽略拦截器里面的内容

Loading…
Cancel
Save