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

@@ -17,6 +17,7 @@
</div> </div>
<div v-if="historySearch!==null" v-show="this.$cookie.get('username')!=null"> <div v-if="historySearch!==null" v-show="this.$cookie.get('username')!=null">
<el-tag <el-tag
v-show="historySearch.length!==0"
v-for="(tag,index) in historySearch" v-for="(tag,index) in historySearch"
:key="index" :key="index"
size="small" size="small"
@@ -87,7 +88,7 @@ export default {
isMouseOver: false, isMouseOver: false,
search: '', search: '',
tipsWord: '', tipsWord: '',
historySearch: null, historySearch: [],
searchResults:[], searchResults:[],
update:true, update:true,
} }
@@ -102,6 +103,7 @@ export default {
this.searchResults=[]; this.searchResults=[];
}, },
clearHistory() { clearHistory() {
var that=this;
axios({ axios({
method: 'post', method: 'post',
// 请求的地址 // 请求的地址
@@ -117,6 +119,9 @@ export default {
type: 'success', type: 'success',
offset: 50 offset: 50
}); });
setTimeout(()=>{
that.gethistorySearch();
})
} else { } else {
Vue.prototype.$notify.error({ Vue.prototype.$notify.error({
title: '错误', title: '错误',
@@ -149,6 +154,7 @@ export default {
}); });
}, },
handleClose(tag){ handleClose(tag){
var that=this;
axios({ axios({
method: 'post', method: 'post',
// 请求的地址 // 请求的地址
@@ -165,6 +171,9 @@ export default {
type: 'success', type: 'success',
offset: 50 offset: 50
}); });
setTimeout(()=>{
that.gethistorySearch();
})
}else{ }else{
Vue.prototype.$notify.error({ Vue.prototype.$notify.error({
title: '错误', title: '错误',

View File

@@ -3,7 +3,7 @@
<div style="display: flex;flex-direction:column;flex-wrap: nowrap"> <div style="display: flex;flex-direction:column;flex-wrap: nowrap">
<div class="PageHeader"> <div class="PageHeader">
<br/> <br/>
<el-page-header @back="goBack" style="margin-left: 20px"> <el-page-header @back="goBack" style="margin-left: 50px;justify-content: center;">
<div slot="title" style="font-size:23px;font-weight: 600;"></div> <div slot="title" style="font-size:23px;font-weight: 600;"></div>
<div slot="content" style=";display: flex;flex-direction:row;justify-content: flex-start;font-size:23px;font-weight: 600;"> <div slot="content" style=";display: flex;flex-direction:row;justify-content: flex-start;font-size:23px;font-weight: 600;">
{{ArticleTitle}} {{ArticleTitle}}

View File

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

View File

@@ -19,7 +19,7 @@
<div> <div>
<div class="circle" :style="{'background-color':colorlists[Math.floor(Math.random() * colorlists.length)]}" ></div> <div class="circle" :style="{'background-color':colorlists[Math.floor(Math.random() * colorlists.length)]}" ></div>
</div> </div>
<el-tag size="mini" style="margin-left: 5px" v-html="projectLists.categoryName"></el-tag><span style="color: rgb(156 163 175);margin-left: 5px"> </span> <el-tag size="mini" style="border-radius: 10px;margin-left: 5px" v-html="projectLists.categoryName"></el-tag><span style="color: rgb(156 163 175);margin-left: 5px"> </span>
<div style="margin-left: 10px"> <div style="margin-left: 10px">
<span style="color: rgb(156 163 175); ">{{ formatTime }}</span> <span style="color: rgb(156 163 175); ">{{ formatTime }}</span>
</div> </div>

View File

@@ -1,15 +1,72 @@
<template> <template>
<div style="display: flex;flex-direction: row;flex-wrap: nowrap"> <el-card style="border-radius: 10px;margin-top: 10px">
<div @click="goToArticleDetail" class="UserArticle" style="display: flex;flex-direction: row;flex-wrap: nowrap;cursor: pointer">
<div style="width: 60px;height: 60px;display: flex;flex-direction: row;align-content: center">
<el-avatar :src="article.articleico" style="display: flex;align-items: center;justify-content: center" shape="square" :size="60"></el-avatar>
</div>
<div style="margin-left: 10px;display: flex;flex-wrap: nowrap;flex-direction: column;">
<span style="display: flex;flex-direction: row;justify-content: flex-start;font-size: 18px;font-weight: bold;">
{{article.ArticleTitle}}
</span>
<span style="font-size: 14px;color: #9ca3af;display: flex;flex-direction: row;justify-content: flex-start;flex-wrap: nowrap">
{{brief}}
</span>
<div style="margin-top: 2.5px;display: flex;flex-direction: row;justify-content: space-between;align-content: center;align-items: center">
<div style="display: flex;flex-direction: row;align-content: center">
<span style="font-size: 13px;color: #9ca3af">
作者: {{article.username}}
</span>
<span style="margin-left: 10px;text-align: center;font-size: 13px;color: #9ca3af">
发布于: {{article.publishtime}}
</span>
</div>
<div style="margin-left: 5px;align-items: center;font-size: 13px;color: #9ca3af">
<i class="el-icon-view"></i> <span>{{formatNumber(article.ReadCount)}}</span>
</div>
</div>
</div>
</div>
</el-card>
</div>
</template> </template>
<script> <script>
export default { export default {
name: "UserArticles" name: "UserArticles",
props:{
article:Object
},
data(){
return{
}
},
computed:{
brief: function() {
return this.article.ArticleContent.substr(0, 48) + '...';
},
},
methods:{
formatNumber(num) {
return num >= 1e3 && num < 1e4 ? (num / 1e3).toFixed(1) + 'k' : num >= 1e4 ? (num / 1e4).toFixed(1) + 'w' : num
},
goToArticleDetail(){
this.$router.push({
path:'/ArticleDetail',
query: {
id: this.article.ArticleId,
refresh: true
}})
// console.log(this.$route.query.id)
},
}
} }
</script> </script>
<style scoped> <style scoped>
.UserArticle:hover{
background-color: #eeeeee;
border-radius: 10px;
}
</style> </style>

View File

@@ -2,7 +2,8 @@
<div style="display: flex;flex-direction: column;flex-wrap: nowrap" v-show="this.$cookie.get('username')!=null"> <div style="display: flex;flex-direction: column;flex-wrap: nowrap" v-show="this.$cookie.get('username')!=null">
<div style="display: flex;flex-direction: row;align-items: center;width: 11vw;justify-content: space-between"> <div style="display: flex;flex-direction: row;align-items: center;width: 11vw;justify-content: space-between">
<div @click="toUserPage" style="display: flex;flex-direction: row;align-items: center"> <div @click="toUserPage" style="display: flex;flex-direction: row;align-items: center">
<el-avatar shape="square" style=" cursor: pointer;background-color: #59A3A4;box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)" size="large">{{this.$cookie.get('username')}}</el-avatar> <!-- <el-avatar v-if="imageUrl===''" shape="square" style=" cursor: pointer;box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)" size="large"></el-avatar>-->
<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"> <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: 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.1</span>
@@ -37,13 +38,15 @@ export default {
return{ return{
switchValue:false, switchValue:false,
ContributionValue:0, ContributionValue:0,
imageUrl:'',
} }
}, },
mounted() { mounted() {
this.getContributionValue(); this.getContributionValue();
this.getUserInfo();
}, },
methods:{ methods: {
signOut(){ signOut() {
this.$cookie.delete('username'); this.$cookie.delete('username');
// deletecookie // deletecookie
axios({ axios({
@@ -51,29 +54,27 @@ export default {
// 请求的地址 // 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/deletesession', url: 'http://localhost:8082/helloGithub_war_exploded/deletesession',
// URL 中的查询参数 // URL 中的查询参数
params: { params: {}
}
}); });
if(this.$cookie.get('username')===null){ if (this.$cookie.get('username') === null) {
Vue.prototype.$notify({ Vue.prototype.$notify({
title: '成功', title: '成功',
message: ('i', {style: 'color: teal'}, "退出成功!"), message: ('i', {style: 'color: teal'}, "退出成功!"),
type: 'success', type: 'success',
offset: 50 offset: 50
}); });
if(this.$route.path!=='/home'){ if (this.$route.path !== '/home') {
setTimeout(()=>{ setTimeout(() => {
this.$router.push({ this.$router.push({
path:'/home' path: '/home'
}) })
},800) }, 800)
}else { } else {
window.location.reload(); window.location.reload();
} }
} else {
}else{
Vue.prototype.$notify.error({ Vue.prototype.$notify.error({
title: '错误', title: '错误',
message: ('i', {style: 'color: teal'}, "退出失败!"), message: ('i', {style: 'color: teal'}, "退出失败!"),
@@ -84,33 +85,53 @@ export default {
}, },
toUserPage(){ toUserPage() {
this.$router.push({ this.$router.push({
path:'/UserInfoPage', path: '/UserInfoPage',
query: { query: {
name: this.$cookie.get('username'), name: this.$cookie.get('username'),
refresh: true refresh: true
}}) }
})
}, },
getContributionValue(){ getContributionValue() {
var that=this; var that = this;
axios({ axios({
method: 'post', method: 'post',
// 请求的地址 // 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/contributionValue', url: 'http://localhost:8082/helloGithub_war_exploded/contributionValue',
// URL 中的查询参数 // URL 中的查询参数
params: { params: {}
}).then((res) => {
}
}).then((res)=>{
// console.log(res); // console.log(res);
if(res.data.code===500){ if (res.data.code === 500) {
return; return;
}else{ } else {
that.ContributionValue=res.data; that.ContributionValue = res.data;
} }
}); });
},
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;
}
} }
} }
} }

View File

@@ -14,8 +14,8 @@
<el-card class="box-card" style="border: none;"> <el-card class="box-card" style="border: none;">
<div style="display: flex;flex-direction: row;flex-wrap: nowrap;justify-content: flex-start"> <div style="display: flex;flex-direction: row;flex-wrap: nowrap;justify-content: flex-start">
<div style="display: flex;flex-direction: row;justify-content: space-between"> <div style="display: flex;flex-direction: row;justify-content: space-between">
<div style="width: 100px;height: 100px;display: flex;flex-direction: row;align-items: center"> <div @click="changeAvatar" style="cursor: pointer;width: 100px;height: 100px;display: flex;flex-direction: row;align-items: center">
<el-avatar style="display: flex;align-items: center;justify-content: center" :size="90">{{username}}</el-avatar> <el-avatar style="display: flex;align-items: center;justify-content: center" :src="imageUrl" :size="90"></el-avatar>
</div> </div>
<div style="display: flex;flex-direction: column;margin-left: 15px;"> <div style="display: flex;flex-direction: column;margin-left: 15px;">
<div style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;"> <div style="display: flex;flex-direction: row;align-items: center;justify-content: flex-start;">
@@ -24,17 +24,21 @@
</div> </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">你是 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"> <span style="display: flex;justify-content: flex-start;margin-top: 10px;color: #6b7280;font-size: 15px">
分享 分享
<span v-if="projectNum!=null" style="font-size: 16px;color:#2b2e33;font-weight: bold ">{{projectNum}}</span> <span v-if="projectNum!=null" style="font-size: 16px;color:#2b2e33;font-weight: bold ">{{projectNum}}</span>
<span v-if="projectNum==null" style="font-size: 16px;color:#2b2e33;font-weight: bold ">0</span> <span v-if="projectNum==null" style="font-size: 16px;color:#2b2e33;font-weight: bold ">0</span>
个开源项目 个开源项目,
<span v-if="Object.keys(commentList).length!==0" style="font-size: 16px;color:#2b2e33;font-weight: bold ">{{Object.keys(commentList).length}}</span> <span v-if="Object.keys(commentList).length!==0" style="font-size: 16px;color:#2b2e33;font-weight: bold ">{{Object.keys(commentList).length}}</span>
<span v-if="Object.keys(commentList).length===0" style="font-size: 16px;color:#2b2e33;font-weight: bold ">0</span> <span v-if="Object.keys(commentList).length===0" style="font-size: 16px;color:#2b2e33;font-weight: bold ">0</span>
项目评价 份评价,
共获得 共获得
<span v-if="contributionValue!=null" style="font-size: 16px;color:#2b2e33;font-weight: bold ">{{contributionValue}}</span> <span v-if="contributionValue!=null" style="font-size: 16px;color:#2b2e33;font-weight: bold ">{{contributionValue}}</span>
<span v-if="contributionValue==null" style="font-size: 16px;color:#2b2e33;font-weight: bold ">0</span> <span v-if="contributionValue==null" style="font-size: 16px;color:#2b2e33;font-weight: bold ">0</span>
点贡献值 点贡献值.
<span style="font-size: 16px;color:#2b2e33;font-weight: bold ">
{{Object.keys(article).length}}
</span>
篇文章
</span> </span>
</div> </div>
<el-progress type="circle" :percentage="contributionValue" :width="100" :show-text="true"></el-progress> <el-progress type="circle" :percentage="contributionValue" :width="100" :show-text="true"></el-progress>
@@ -82,16 +86,49 @@
<el-card style="border: none;display: flex;flex-direction: row;justify-content: flex-start;align-items: flex-start"> <el-card style="border: none;display: flex;flex-direction: row;justify-content: flex-start;align-items: flex-start">
<span style="font-size: 16px;font-weight: bold">总文章: {{Object.keys(article).length}} </span> <span style="font-size: 16px;font-weight: bold">总文章: {{Object.keys(article).length}} </span>
</el-card> </el-card>
<el-empty v-show="like.length===0" description="暂无点赞" :image-size="115"></el-empty> <el-empty v-show="Object.keys(article).length===0" description="暂无点赞" :image-size="115"></el-empty>
<!-- <div v-show="like.length!==0" v-for="(item,index) in like" :key="index">--> <div v-show="Object.keys(article).length!==0" v-for="(item,index) in article" :key="index">
<!-- <UserProjects :project="item" :index="index"></UserProjects>--> <UserArticles :article="item"></UserArticles>
<!-- </div>--> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
</el-card> </el-card>
</div> </div>
</div> </div>
<RightTools></RightTools> <RightTools></RightTools>
<el-dialog
title="修改头像"
:visible.sync="openChangeAvatar"
width="25vw"
append-to-body
:close-on-click-modal="false"
>
<div style="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>
<el-button @click="changeAvatarByUrl" size="small" type="primary">上传<i class="el-icon-upload el-icon--right"></i></el-button>
</div>
<div style="margin-top: 10px;display: flex;flex-direction: row;align-items: center;justify-content: center">
<el-upload
class="upload-demo"
drag
action=""
:http-request="upload"
multiple>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
<div class="el-upload__tip" slot="tip">只能上传jpg/png文件</div>
</el-upload>
<!-- <form action="/upload/UploadHandle" enctype="multipart/form-data" method="post" target="_blank">-->
<!-- <input type="file" name="file1"><br>-->
<!-- <input type="submit" value="上传">-->
<!-- </form>-->
</div>
</el-dialog>
</div> </div>
</template> </template>
@@ -100,10 +137,13 @@ import axios from "axios";
import RightTools from "@/components/Home/RightTools.vue"; import RightTools from "@/components/Home/RightTools.vue";
import UserProjects from "@/components/User/UserProjects.vue"; import UserProjects from "@/components/User/UserProjects.vue";
import UserComments from "@/components/User/UserComments.vue"; import UserComments from "@/components/User/UserComments.vue";
import UserArticles from "@/components/User/UserArticles.vue";
import Vue from "vue";
export default { export default {
name: "UserInfoPage", name: "UserInfoPage",
components: {UserComments, UserProjects, RightTools}, components: {UserArticles, UserComments, UserProjects, RightTools},
data(){ data(){
return{ return{
activeName:'first', activeName:'first',
@@ -116,6 +156,9 @@ export default {
commentList:[], commentList:[],
like:[], like:[],
article:[], article:[],
openChangeAvatar:false,
AvatarUrl:'',
imageUrl:'',
} }
}, },
mounted() { mounted() {
@@ -130,7 +173,13 @@ export default {
} }
} }
}, },
computed: {
headers() {
return {
"Content-Type": "multipart/form-data"
};
},
},
methods: { methods: {
goBack() { goBack() {
window.history.go(-1); window.history.go(-1);
@@ -151,6 +200,7 @@ export default {
that.creatTime=res.data.creatTime; that.creatTime=res.data.creatTime;
that.projectNum=res.data.projectNum; that.projectNum=res.data.projectNum;
that.userId=res.data.userId; that.userId=res.data.userId;
that.imageUrl=res.data.userAvatar;
}); });
}, },
getUserDetail(){ getUserDetail(){
@@ -169,16 +219,125 @@ export default {
that.commentList=JSON.parse(res.data.comment); that.commentList=JSON.parse(res.data.comment);
that.like=JSON.parse(res.data.like) that.like=JSON.parse(res.data.like)
that.article=JSON.parse(res.data.article); that.article=JSON.parse(res.data.article);
console.log(Object.keys(that.article).length); console.log(that.commentList);
}); });
}, },
changeAvatar(){
this.openChangeAvatar=true;
},
changeAvatarByUrl(){
var that=this;
if(this.AvatarUrl!==''){
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/userAvatar',
// URL 中的查询参数
params: {
url: this.AvatarUrl
}
}).then(function (res) {
if(res.data.code===200){
Vue.prototype.$notify({
title: '上传成功',
message: ('i', {style: 'color: teal'}, res.data.msg),
type: 'success',
offset: 50
});
that.$root.URL=that.imageUrl;
}else{
Vue.prototype.$notify.error({
title: '错误',
message: "上传失败",
offset: 50
});
}
});
}else{
Vue.prototype.$notify.error({
title: '错误',
message: "请先填写图片链接",
offset: 50
});
}
},
upload(params){
const formData = new FormData();
formData.append("file", params.file);
axios({
method: 'post',
// 请求的地址
url: '/upload/UploadHandle',
headers:{"Content-Type": "multipart/form-data"},
// URL 中的查询参数
data:formData
}).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{
Vue.prototype.$notify.error({
title: '错误',
message: res.data.msg,
offset: 50
});
}
})
},
changeAvatarByLocal(){
axios({
method: 'post',
// 请求的地址
url: 'http://localhost:8082/helloGithub_war_exploded/retUserAv',
// URL 中的查询参数
responseType: 'blob',
}).then((res)=>{
console.log(res);
})
},
} }
} }
</script> </script>
<style scoped> <style>
::v-deep .el-page-header__left{ .el-page-header__left{
position: relative; position: relative;
left:-20vw; left:-20vw;
} }
.avatar-uploader .el-upload {
border: 1px dashed #d9d9d9;
border-radius: 6px;
cursor: pointer;
position: relative;
overflow: hidden;
}
.avatar-uploader .el-upload:hover {
border-color: #409EFF;
}
.avatar-uploader-icon {
font-size: 28px;
color: #8c939d;
width: 178px;
height: 178px;
line-height: 178px;
text-align: center;
}
.avatar {
width: 178px;
height: 178px;
display: block;
}
</style> </style>

View File

@@ -21,7 +21,6 @@ Vue.use(ElementTiptapPlugin, {
}); });
axios.defaults.withCredentials=true; axios.defaults.withCredentials=true;
import cookie from 'vue-cookie' import cookie from 'vue-cookie'
Vue.prototype.$cookie = cookie; Vue.prototype.$cookie = cookie;
@@ -33,5 +32,5 @@ new Vue({
axios, axios,
store, store,
cookie, cookie,
render: h => h(App) render: h => h(App),
}).$mount('#app') }).$mount('#app')

View File

@@ -11,16 +11,51 @@ module.exports = {
// host: 'localhost', // 本地域名/ip地址 // host: 'localhost', // 本地域名/ip地址
// port: '8080', // 端口号 // port: '8080', // 端口号
proxy: { proxy: {
'/api': { '/github': {
//后端接口的baseurl //后端接口的baseurl
target: 'https://api.github.com/repos', target: 'https://api.github.com/repos',
//是否允许跨域 //是否允许跨域
changeOrigin: true, changeOrigin: true,
// ws: true, //是否代理 websockets
// secure: true,
// 'secure': true,
headers:{
Connection:"kepp-alive"
},
pathRewrite: {
//这里的作用是使用去掉api
'^/github': ''
}
},
'/upload': {
//后端接口的baseurl
target: 'http://localhost:8082/helloGithub_war_exploded',
//是否允许跨域
changeOrigin: true,
headers:{
Connection:"kepp-alive"
},
pathRewrite: {
//这里的作用是使用去掉api
'^/upload': ''
}
},
'/api': {
//后端接口的baseurl
target: 'http://localhost:8082/helloGithub_war_exploded',
//是否允许跨域
changeOrigin: true,
// ws: true, //是否代理 websockets
// secure: true,
// 'secure': true,
headers:{
Connection:"kepp-alive"
},
pathRewrite: { pathRewrite: {
//这里的作用是使用去掉api //这里的作用是使用去掉api
'^/api': '' '^/api': ''
} }
} },
} }
} }
} }