diff --git a/components/i/Create.vue b/components/i/Create.vue index 8d3ecd02a0ab598c1641492a09a640f5f981ad02..8de5287ce9ffe4dc5dfc7bf859a0aca1bcce0084 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 1ec51bf421fa1ae3c8c30bfe16cee1b0b3ee3204..c185fcf66866be96a2e67f62867a7b3ec4377570 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({