@@ -216,8 +216,10 @@ export default {
data() {
return {
activeName: 'first',
- activeIndex:'综合',
+ currentTabName:"综合",
+ currentTabIndex:null,
projectLists:[],
+ tabindex:0,
count: 10,
loading: false,
loginDialogVisible: false,
@@ -259,12 +261,16 @@ export default {
name:"综合"
},
{
- icon: ` C++`,
- name:"C++"
+ icon: ` C`,
+ name:"C"
},
{
- icon: ` python`,
- name:"python"
+ icon: ` C#`,
+ name:"C#"
+ },
+ {
+ icon: ` C++`,
+ name:"C++"
},
],
@@ -275,17 +281,17 @@ export default {
this.ProjectLists();
},
created() {
- if (sessionStorage.getItem('current_name') == null){
- this.activeIndex = '综合'
- }else{
- this.activeIndex = sessionStorage.getItem('current_name')
- }
- },
- beforeRouteLeave(to, from, next){
- // 在离开此路由之后清除保存的状态(我的需求是只需要在当前tab页操作刷新保存状态,路由切换之后不需要保存)
- // 根据个人需求决定清除的时间
- sessionStorage.removeItem('currentTab')
- next()
+ // if (sessionStorage.getItem('current_name') == null){
+ // this.activeIndex = '综合'
+ // }else{
+ // this.activeIndex = sessionStorage.getItem('current_name')
+ // }
+ // },
+ // beforeRouteLeave(to, from, next){
+ // // 在离开此路由之后清除保存的状态(我的需求是只需要在当前tab页操作刷新保存状态,路由切换之后不需要保存)
+ // // 根据个人需求决定清除的时间
+ // sessionStorage.removeItem('currentTab')
+ // next()
},
computed: {
noMore() {
@@ -297,10 +303,7 @@ export default {
},
methods: {
- handleClick(tab, event) {
- // location.search:获取路由上的参数
- sessionStorage.setItem('current_name', this.activeIndex)
- },
+
openLogin() {
this.loginDialogVisible = true;
},
@@ -506,19 +509,59 @@ export default {
params: {
num: "0",
}
+ }).then((res)=>{
+ // console.log(res.data);
+ that.projectLists=res.data;
+ });
+ },
+ projectListsByCount(index){
+ var that=this;
+ axios({
+ method: 'post',
+ // 请求的地址
+ url: 'http://localhost:8082/helloGithub_war_exploded/selectMostStar',
+ // URL 中的查询参数
+ params: {
+ num: index,
+ }
+ }).then((res)=>{
+ // console.log(res.data);
+ that.projectLists=res.data;
+ });
+ },
+ tabChange(tab) {
+ if(tab.name=="first"){
+ this.ProjectLists();
+ }
+ else if (tab.name == "second") {
+ this.projectListsByCount(this.tabindex);
+ }
+ },
+
+ typeChangeFun(index){
+ var that=this;
+ axios({
+ method: 'post',
+ // 请求的地址
+ url: 'http://localhost:8082/helloGithub_war_exploded/selectLastByCate',
+ // URL 中的查询参数
+ params: {
+ num: index,
+ }
}).then((res)=>{
console.log(res.data);
that.projectLists=res.data;
});
},
- tabChange(tab, event) {
- console.log(tab, event);
- // eslint-disable-next-line no-empty
- if (tab.name == "second") {
-
+ typeChange(tab){
+ if(this.activeName==="first"){
+ this.typeChangeFun(tab.index);
}
- },
+ if(this.activeName==="second"){
+ this.projectListsByCount(tab.index);
+ }
+ }
}
}