From 220241d8a88456ad5eccd321c51b9c76ff656079 Mon Sep 17 00:00:00 2001 From: zhendi Date: Tue, 17 Dec 2024 14:48:35 +0800 Subject: [PATCH] move tag selection from props to URL query params --- frontend/src/components/shared/RepoCards.vue | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/shared/RepoCards.vue b/frontend/src/components/shared/RepoCards.vue index 099e5f8ee..5b679fdf5 100644 --- a/frontend/src/components/shared/RepoCards.vue +++ b/frontend/src/components/shared/RepoCards.vue @@ -9,8 +9,8 @@ :frameworkTags="frameworkTags" :languageTags="languageTags" :licenseTags="licenseTags" - :selectedTag="props.selectedTag" - :selectedTagType="props.selectedTagType" + :selectedTag="selectedTag" + :selectedTagType="selectedTagType" @resetTags="resetTags" :type="repoType" /> @@ -134,11 +134,21 @@ import UpdateUsername from '../popup/UpdateUsername.vue' const props = defineProps({ - selectedTag: String, - selectedTagType: String, repoType: String }) + const getQueryParams = () => { + const { searchParams } = new URL(window.location.href) + return { + tag: searchParams.get('tag') ?? '', + tagType: searchParams.get('tag_type') ?? '' + } + } + + const { tag, tagType } = getQueryParams() + const selectedTag = ref(tag) + const selectedTagType = ref(tagType) + const tagFields = { model: [ 'computer_vision',