From c17df9c5079673cf9d2f3634f4106f1278cbfbbf Mon Sep 17 00:00:00 2001 From: Aresn Date: Thu, 23 May 2024 11:43:58 +0800 Subject: [PATCH] update --- components/i/Create.vue | 28 +++++++++++++++------------- pages/search/[id].vue | 29 ++++++++++++++++------------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/components/i/Create.vue b/components/i/Create.vue index 8d3ecd0..8de5287 100644 --- a/components/i/Create.vue +++ b/components/i/Create.vue @@ -55,19 +55,21 @@ const handleSearch = async () => { } } -let repoData = await fetchRequest('/v1/chat/repository', { - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } -}) -repoData = repoData.data.map(item => { - return { - label: item.name, - url: item.path, - branch: item.branch - } -}) -$setRepo(repoData) +if (!$repos.length) { + let repoData = await fetchRequest('/v1/chat/repository', { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }) + repoData = repoData.data.map(item => { + return { + label: item.name, + url: item.path, + branch: item.branch + } + }) + $setRepo(repoData) +} defineShortcuts({ meta_enter: { diff --git a/pages/search/[id].vue b/pages/search/[id].vue index 1ec51bf..c185fcf 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -42,19 +42,22 @@ const { fetchRequest } = useFetchRequest() const editIndex = ref(0) const { y } = useWindowScroll({ behavior: 'smooth' }) const { directions } = useScroll(window) -let repoData = await fetchRequest('/v1/chat/repository', { - headers: { - 'Content-Type': 'application/x-www-form-urlencoded' - } -}).catch(()=> {}) -repoData = repoData && repoData.data.map(item => { - return { - label: item.name, - url: item.path, - branch: item.branch - } -}) -$setRepo(repoData) + +if (!$repos.length) { + let repoData = await fetchRequest('/v1/chat/repository', { + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }).catch(()=> {}) + repoData = repoData && repoData.data.map(item => { + return { + label: item.name, + url: item.path, + branch: item.branch + } + }) + $setRepo(repoData) +} // todo mock const repoItem = $repos.find(item => route.query.repo === item.label) || {} const state = reactive({ -- GitLab