From e7a00c5b69b2a370e42abd5c51386c4b4853b208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=8E=AB=E5=94=90=E5=B0=BC?= <1431128779@qq.com> Date: Tue, 25 Jun 2024 19:15:42 +0800 Subject: [PATCH] =?UTF-8?q?update:=20=E8=B0=83=E6=95=B4=E5=8F=8B=E6=83=85?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E9=A1=B5=E9=9D=A2=EF=BC=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=88=86=E7=BB=84=E3=80=81=E6=98=BE=E7=A4=BA=E5=BC=B9=E7=AA=97?= =?UTF-8?q?=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/v2/all.api.js | 8 ++- pagesA/friend-links/friend-links.vue | 103 ++++++++------------------- 2 files changed, 37 insertions(+), 74 deletions(-) diff --git a/api/v2/all.api.js b/api/v2/all.api.js index ce0be1f..1d14609 100644 --- a/api/v2/all.api.js +++ b/api/v2/all.api.js @@ -139,6 +139,12 @@ export default { }) }, + /** + * 获取友链分组 + */ + getFriendLinkGroupList: (params) => { + return HttpHandler.Get(`/apis/core.halo.run/v1alpha1/linkgroups`, params) + }, /** * 获取友链 @@ -191,4 +197,4 @@ export default { submitLink(form) { return HttpHandler.Post(`/apis/linksSubmit.muyin.site/v1alpha1/submit`, form, null) } -} \ No newline at end of file +} diff --git a/pagesA/friend-links/friend-links.vue b/pagesA/friend-links/friend-links.vue index 4a6d699..8378958 100644 --- a/pagesA/friend-links/friend-links.vue +++ b/pagesA/friend-links/friend-links.vue @@ -19,7 +19,7 @@ + :class="{ 'border-b-1': index !== dataList.length - 1 }" @click="fnOnLinkEvent(link)"> - + {{ link.spec.displayName }} @@ -63,61 +63,6 @@ - - - - - {{ team.title }} - - - - - - - - {{ link.spec.displayName }} - - - - ID:{{ link.metadata.name }} - - - {{ link.spec.groupName || '暂未分组' }} - - - - 博客简介:{{ link.spec.description || '这个博主很懒,没写简介~' }} - - - - - - - - {{ link.spec.displayName }} - - {{ link.spec.description }} - - - - {{ link.spec.url }} - - - - - - - - - - {{ detail.data.name }} + {{ detail.data.spec.displayName }} - - ID:{{ detail.data.id }} - - {{ detail.data.team || '暂未分组' }} + {{ detail.data.spec.groupName }} - {{ detail.data.url }} + {{ detail.data.spec.url }} - 博客简介:{{ detail.data.description || '这个博主很懒,没写简介~' }} + 博客简介:{{ detail.data.spec.description || '这个博主很懒,没写简介~' }} - @@ -199,6 +141,7 @@ export default { hasNext: false, isLoadMore: false, loadMoreText: '', + linkGroupList: [], dataList: [], cacheDataList: [], colors: [ @@ -212,7 +155,7 @@ export default { }; }, computed: { - haloPluginConfigs(){ + haloPluginConfigs() { return this.$tm.vx.getters().getConfigs.pluginConfig; }, calcSiteThumbnail(val) { @@ -226,8 +169,8 @@ export default { } }, onLoad() { - this.fnSetPageTitle('朋友圈'); - this.fnGetData(); + this.fnSetPageTitle('友情链接'); + this.fnGetLinkGroupData(); }, onPullDownRefresh() { this.isLoadMore = false; @@ -249,16 +192,29 @@ export default { } }, methods: { - fnRandomColor() { - const _r = GetRandomNumberByRange(0, this.colors.length - 1); - return this.colors[_r]; + fnGetLinkGroupData() { + this.$httpApi.v2 + .getFriendLinkGroupList({ + page: 1, + size: 0 + }) + .then(res => { + this.linkGroupList = res.items; + this.fnGetData() + }) + .catch(err => { + console.error(err); + }); + }, + findLinkGroupDisplayNameByGroupMetadataName(groupName) { + if (this.linkGroupList.length === 0) return groupName || "未分组" + return this.linkGroupList.find(item => item.metadata.name === groupName)?.spec?.displayName || groupName || "未分组" }, fnGetData() { if (!this.isLoadMore) { this.loading = 'loading'; } this.loadMoreText = ''; - this.$httpApi.v2 .getFriendLinkList(this.queryParams) .then(res => { @@ -267,6 +223,7 @@ export default { this.hasNext = res.hasNext; const list = res.items.map(item => { item.spec.logo = this.$utils.checkAvatarUrl(item.spec.logo) + item.spec.groupName = this.findLinkGroupDisplayNameByGroupMetadataName(item.spec?.groupName) return item; }) this.dataList = this.dataList.concat(list);