用户上传完善

This commit is contained in:
2023-07-08 01:00:34 +08:00
parent eaffa1ace3
commit fc64a179e8
5 changed files with 106 additions and 30 deletions

View File

@@ -196,7 +196,7 @@
<div v-for="(item,index) in commentContent" :key="index" style="display: flex;flex-direction: row;align-items: center;flex-wrap: nowrap;margin-top: 20px">
<div style="display: flex;flex-direction: row">
<div style="width: 50px;height: 50px;">
<el-avatar :size="50">{{item.username}}</el-avatar>
<el-avatar :size="50" :src="item.userUri">{{item.username}}</el-avatar>
</div>
<div style="display: flex;flex-direction: column;justify-content: space-between">
<div style="display: flex;flex-direction: row;margin-left: 10px;align-items: center">
@@ -222,7 +222,7 @@
<span style="font-size: 14px;color: #9ca3af">{{item.commentTime}}</span>
<div style="display: flex;align-items: center">
<span style="margin-right: 5px;font-size: 14px; color: rgb(156, 163, 175);">{{ formatNumber(item.likeNum) }}</span>
<el-link @click.once="addLike(item.commentId)" icon="el-icon-star-off" :underline="false">点赞</el-link>
<el-link @click="addLike(item.commentId)" icon="el-icon-star-off" :underline="false">点赞</el-link>
</div>
</div>
@@ -235,7 +235,7 @@
<div v-for="(item,index) in commentContent" :key="index" style="display: flex;flex-direction: row;align-items: center;flex-wrap: nowrap;margin-top: 20px">
<div style="display: flex;flex-direction: row">
<div style="width: 50px;height: 50px;">
<el-avatar :size="50">{{item.username}}</el-avatar>
<el-avatar :src="item.userUri" :size="50">{{item.username}}</el-avatar>
</div>
<div style="display: flex;flex-direction: column;justify-content: space-between">
<div style="display: flex;flex-direction: row;margin-left: 10px;align-items: center">
@@ -602,7 +602,7 @@ export default {
trait:'last'
}
}).then(function (res) {
console.log(res);
// console.log(res);
that.commentContent=res.data;
that.commentNum=Object.keys(that.commentContent).length;

View File

@@ -0,0 +1,15 @@
<template>
<div>
</div>
</template>
<script>
export default {
name: "ProjectPublish"
}
</script>
<style scoped>
</style>

View File

@@ -13,7 +13,7 @@
<el-card style="border-radius: 10px;margin-top: 10px;">
<div style="display: flex;flex-direction: row;flex-wrap: nowrap">
<div style="width: 60px;height: 60px;">
<el-avatar :size="60">{{ this.$cookie.get('username') }}</el-avatar>
<el-avatar :size="60" :src="comments.userUri">{{ this.$cookie.get('username') }}</el-avatar>
</div>
<div style="display: flex;flex-direction: column;flex-wrap: nowrap;margin-left: 20px">
<div style="display: flex;flex-direction: row;flex-wrap: nowrap;align-items: center">

View File

@@ -6,7 +6,7 @@
<el-avatar shape="square" style=" cursor: pointer;box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)" :src="imageUrl" size="large">{{this.$cookie.get('username')}}</el-avatar>
<div style="margin-left: 5px;display: flex;flex-direction: column;justify-content: space-evenly">
<span style="cursor: pointer;font-weight: bold">{{this.$cookie.get('username')}}</span>
<span style="cursor: pointer;font-weight: 800;font-size: 13px;color: #3b82f6">Lv.1</span>
<span style="cursor: pointer;font-weight: 800;font-size: 13px;color: #3b82f6">Lv.{{userLevel}}</span>
</div>
</div>
@@ -39,11 +39,20 @@ export default {
switchValue:false,
ContributionValue:0,
imageUrl:'',
userLevel:null,
}
},
created() {
this.updateUserLevel();
this.getUserInfo();
},
mounted() {
this.getContributionValue();
this.getUserInfo();
setTimeout(()=>{
this.updateUserLevel();
this.getUserInfo();
},1000)
},
methods: {
signOut() {
@@ -124,15 +133,29 @@ export default {
username: this.$cookie.get("username")
}
}).then(function (res) {
that.imageUrl = res.data.userAvatar;
that.userLevel=res.data.userLevel;
// that.imageUrl = res.data.userAvatar;
// console.log(res);
});
}else{
return;
}
},
updateUserLevel(){
if(this.$cookie.get("username")!=null){
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/levelup',
// URL 中的查询参数
params: {
}
}
});
}else{
return;
}
},
}
}
</script>

View File

@@ -20,7 +20,7 @@
<div style="display: flex;flex-direction: column;margin-left: 15px;">
<div style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;">
<span style="font-size: 20px;font-weight: bold;">{{username}}</span>
<span style="font-size: 15px;font-weight: bold;color: #3b82f6;margin-left: 10px">Lv.1</span>
<span style="font-size: 15px;font-weight: bold;color: #3b82f6;margin-left: 10px">Lv.{{userLevel}}</span>
</div>
<span style="display: flex;justify-content:flex-start;margin-top: 10px;color: #6b7280;font-size: 15px">你是 HelloGitHub 社区的第<span style="font-size: 16px;color:#2b2e33;font-weight: bold "> {{userId}} </span>位用户 {{creatTime}} 加入</span>
<span style="display: flex;justify-content: flex-start;margin-top: 10px;color: #6b7280;font-size: 15px">
@@ -104,7 +104,8 @@
append-to-body
:close-on-click-modal="false"
>
<div style="display: flex;flex-direction: row;align-items: center;justify-content: space-between">
<span style="font-size: 14px;color: #9ca3af">选择一种方式即可</span>
<div style="margin-top: 10px;display: flex;flex-direction: row;align-items: center;justify-content: space-between">
<el-input placeholder="请输入头像链接" style="width: 17vw" v-model="AvatarUrl">
<template slot="prepend">url:</template>
</el-input>
@@ -158,12 +159,25 @@ export default {
article:[],
openChangeAvatar:false,
AvatarUrl:'',
imageUrl:'',
imageUrl:'http://localhost:8082/helloGithub_war_exploded/retUserAv',
userLevel:null,
}
},
mounted() {
this.getUserInfo()
this.getUserDetail();
setTimeout(()=>{
this.updateUserLevel();
this.getUserInfo();
},1000)
// this.changeAvatarByLocal();
},
created() {
this.updateUserLevel();
this.getUserInfo();
},
watch: {
$route () {
@@ -171,7 +185,7 @@ export default {
this.getUserInfo() //重新调用http请求实现页面的重新渲染
this.getUserDetail();
}
}
},
},
computed: {
headers() {
@@ -200,7 +214,8 @@ export default {
that.creatTime=res.data.creatTime;
that.projectNum=res.data.projectNum;
that.userId=res.data.userId;
that.imageUrl=res.data.userAvatar;
// that.imageUrl=res.data.userAvatar;
that.userLevel=res.data.userLevel;
});
},
getUserDetail(){
@@ -219,14 +234,33 @@ export default {
that.commentList=JSON.parse(res.data.comment);
that.like=JSON.parse(res.data.like)
that.article=JSON.parse(res.data.article);
console.log(that.commentList);
// console.log(that.commentList);
});
},
updateUserLevel(){
if(this.$cookie.get("username")!=null){
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/levelup',
// URL 中的查询参数
params: {
}
});
}else{
return;
}
},
changeAvatar(){
this.openChangeAvatar=true;
if(this.$route.query.name!==this.$cookie.get('username')){
return;
}else{
this.openChangeAvatar=true;
}
},
changeAvatarByUrl(){
var that=this;
if(this.AvatarUrl!==''){
axios({
method: 'post',
@@ -244,7 +278,6 @@ export default {
type: 'success',
offset: 50
});
that.$root.URL=that.imageUrl;
}else{
Vue.prototype.$notify.error({
title: '错误',
@@ -265,6 +298,7 @@ export default {
},
upload(params){
var that=this;
const formData = new FormData();
formData.append("file", params.file);
axios({
@@ -273,36 +307,40 @@ export default {
url: '/upload/UploadHandle',
headers:{"Content-Type": "multipart/form-data"},
// URL 中的查询参数
data:formData
data:formData,
params: {
username: this.$cookie.get('username')
}
}).then((res)=>{
console.log(res);
if(res.data.code===200){
Vue.prototype.$notify({
title: '成功',
message: ('i', {style: 'color: teal'}, res.data.msg),
type: 'success',
offset: 50
});
}else{
if(res.data.code===500){
Vue.prototype.$notify.error({
title: '错误',
message: res.data.msg,
offset: 50
});
}else{
Vue.prototype.$notify({
title: '成功',
message: ('i', {style: 'color: teal'}, "上传成功"),
type: 'success',
offset: 50
});
that.openChangeAvatar=false;
}
})
},
changeAvatarByLocal(){
var that=this;
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/retUserAv',
url: '/api/retUserAv',
// URL 中的查询参数
responseType: 'blob',
}).then((res)=>{
console.log(res);
})
},