From 7d3c36babc82eac47fbe5cc010a2c15a69326539 Mon Sep 17 00:00:00 2001 From: Qing Date: Sat, 1 Jul 2023 13:02:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8A=9F=E8=83=BD=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Home/Home.vue | 103 +++++++++++++++++++++++++---------- 1 file changed, 73 insertions(+), 30 deletions(-) diff --git a/src/components/Home/Home.vue b/src/components/Home/Home.vue index 3b3766a..1094914 100644 --- a/src/components/Home/Home.vue +++ b/src/components/Home/Home.vue @@ -9,9 +9,9 @@ 热门标签
- - - + + + @@ -44,7 +44,7 @@

加载中...

没有更多了

- +
@@ -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); + } + } } }