add 用户头像上传

This commit is contained in:
2023-07-07 21:39:51 +08:00
parent 2db7db4aef
commit eaffa1ace3
9 changed files with 399 additions and 67 deletions

View File

@@ -6,7 +6,7 @@
<el-page-header @back="goBack" style="justify-content: center;">
<div slot="title" style="font-size:23px;font-weight: 600;"></div>
<div slot="content" style="font-size:23px;font-weight: 600;">
项目详情
项目详情
</div>
</el-page-header>
</div>
@@ -30,7 +30,7 @@
<span style="font-size: 14px;color: #6b7280;display: flex;justify-content: flex-start">
HelloGitHub 评分
</span>
<el-rate v-model="totalStar" style="display: flex;justify-content: flex-start" disabled show-score text-color="#ff9900"
<el-rate v-model="average" style="display: flex;justify-content: flex-start" disabled show-score text-color="#ff9900"
score-template="{value}"></el-rate>
<span style="font-size: 12px;color: #59A3A4;display: flex;justify-content: flex-start">
{{ commentNum }} 个评分
@@ -118,14 +118,22 @@
<el-tabs v-model="activeName">
<el-tab-pane label="介绍" name="first">
<el-tiptap v-model="projectDescription" :readonly="true" :showMenubar="false" :extensions="extensions" />
<div style="display:flex;align-items: center;flex-direction: row;">
<span style="font-size: 14px;margin-top: 10px">收录于: </span><el-tag style="margin-left: 10px;margin-top: 10px" size="medium"> {{periodicals}} </el-tag>
<div style="display: flex;flex-direction: row;margin-left: 10px;margin-top: 10px;align-items: center">
<span>标签: </span>
<div style="margin-left: 10px">
<el-tag v-for="(item,index) in CategoryName" :key="index" size="medium" style="margin-left: 10px">{{item}}</el-tag>
<div style="display:flex;align-items: center;flex-direction: row;justify-content: space-between">
<div style="display: flex;flex-direction: row;flex-wrap: nowrap;align-items: center">
<span style="font-size: 14px;margin-top: 10px">收录于: </span><el-tag style="margin-left: 10px;margin-top: 10px" size="medium"> {{periodicals}} </el-tag>
<div style="display: flex;flex-direction: row;margin-left: 10px;margin-top: 10px;align-items: center">
<span>标签: </span>
<div style="margin-left: 10px">
<el-tag v-for="(item,index) in CategoryName" :key="index" size="medium" style="margin-left: 10px">{{item}}</el-tag>
</div>
</div>
</div>
<div @click="toUserPage" style="cursor: pointer;display: flex;flex-direction: row;flex-wrap: nowrap;align-items: center">
<span style="font-size: 14px;margin-top: 10px"></span>
<el-avatar class="avatar" style="margin-left: 5px;margin-right: 5px;margin-top: 10px" :src="userUri" :size="30"></el-avatar>
<span style="font-size: 14px;margin-top: 10px">分享</span>
</div>
</div>
</el-tab-pane>
@@ -144,7 +152,7 @@
<div class="text item">
<div style="display: flex;flex-direction: row;flex-wrap: nowrap">
<div style="width: 50px;height: 50px">
<el-avatar v-if="this.$cookie.get('username')!=null" :size="50">{{this.$cookie.get('username')}}</el-avatar>
<el-avatar v-if="this.$cookie.get('username')!=null" :src="imageUrl" :size="50"></el-avatar>
<el-avatar v-if="this.$cookie.get('username')==null" :size="50">未登录</el-avatar>
</div>
<el-input
@@ -227,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 :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">
@@ -346,7 +354,9 @@ export default {
checked:false,
tabCheckedLast:true,
tabCheckedHot:false,
averageStarNum:0,
username:'',
userUri:'',
average:0,
github:{
starNum:null,
language:'',
@@ -362,12 +372,14 @@ export default {
},
totalStar:3.7,
Content:'',
imageUrl:'',
}
},
mounted() {
this.getProjectDetail();
this.getLastComment();
this.isStart();
this.getUserInfo();
},
watch: {
@@ -378,7 +390,15 @@ export default {
}
},
methods:{
toUserPage() {
this.$router.push({
path: '/UserInfoPage',
query: {
name: this.username,
refresh: true
}
})
},
toComment(id){
document.querySelector(id).scrollIntoView(true)
var auchor=this.$el.querySelector(id)
@@ -402,6 +422,7 @@ export default {
id:this.$route.query.id
}
}).then(function (res) {
// console.log(res);
that.CategoryName=res.data.CategoryName;
that.projectName=res.data.project.projectName;
that.projectTitle=res.data.project.projectTitle;
@@ -413,6 +434,10 @@ export default {
that.userId=res.data.project.userId;
that.projectId=res.data.project.projectId;
that.num=res.data.project.num;
that.average=res.data.project.average;
that.username=res.data.project.username;
that.userUri=res.data.project.userUri;
that.getDetailByGitHub();
});
},
@@ -435,7 +460,6 @@ export default {
trait:tab.name
}
}).then(function (res) {
console.log(res);
that.commentContent=res.data;
that.commentNum=Object.keys(that.commentContent).length;
if(tab.name==='last'){
@@ -471,6 +495,7 @@ export default {
offset: 50
});
that.getLastComment();
that.getProjectDetail();
that.reload();
} else {
Vue.prototype.$notify.error({
@@ -501,6 +526,27 @@ export default {
formatNumber(num) {
return num >= 1e3 && num < 1e4 ? (num / 1e3).toFixed(1) + 'k' : num >= 1e4 ? (num / 1e4).toFixed(1) + 'w' : num
},
getUserInfo() {
var that = this;
if(this.$cookie.get("username")!=null){
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/retUser',
// URL 中的查询参数
params: {
username: this.$cookie.get("username")
}
}).then(function (res) {
that.imageUrl = res.data.userAvatar;
// console.log(res);
});
}else{
return;
}
},
addLike(id){
var that=this;
@@ -556,6 +602,7 @@ export default {
trait:'last'
}
}).then(function (res) {
console.log(res);
that.commentContent=res.data;
that.commentNum=Object.keys(that.commentContent).length;
@@ -593,6 +640,7 @@ export default {
offset: 50
});
} else {
this.getProjectDetail();
this.isStart();
this.$router.push({
path:'/ProjectDetail',
@@ -620,6 +668,7 @@ export default {
offset: 50
});
} else {
this.getProjectDetail();
this.isStart();
// window.location.reload()
this.$router.push({
@@ -638,13 +687,12 @@ export default {
axios({
method: 'get',
// 请求的地址
url: '/api/'+this.projectName,
url: '/github/'+this.projectName,
// URL 中的查询参数
params: {
}
}).then((res)=>{
// console.log(res)
that.github.starNum=res.data.stargazers_count;
that.github.language=res.data.language;
that.github.watchers_count=res.data.watchers_count;
@@ -740,4 +788,8 @@ export default {
::v-deep .el-card__header{
border-bottom: none;
}
::v-deep .avatar :hover{
transform: rotate(360deg);
}
</style>