diff options
Diffstat (limited to 'packages/client/src/views/Repository.vue')
-rw-r--r-- | packages/client/src/views/Repository.vue | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/packages/client/src/views/Repository.vue b/packages/client/src/views/Repository.vue index 24000d4..7b31545 100644 --- a/packages/client/src/views/Repository.vue +++ b/packages/client/src/views/Repository.vue @@ -24,18 +24,29 @@ export default { const description = ref(""); const has_readme = ref(null); - const fetchProjects = async(repository) => { - console.log(repository); - const repository_data = await (await fetch(`${window.location.protocol}//${window.location.host}/api/v1/repos/${repository}`)).json(); - name.value = repository_data.data.name; - description.value = repository_data.data.description; - has_readme.value = repository_data.data.has_readme; + const fetchProjects = async(router, path) => { + const repository = router.currentRoute._rawValue.params.repo; + + const repository_data = await fetch(`${window.location.protocol}//${window.location.host}/api/v1/repos/${repository}`) + .catch(() => { + if(path.split("/").length === 2) { + router.replace(`/${repository}/log`); + }; + return null; + }); + + if(repository_data) { + const data = (await repository_data.json()).data; + name.value = data.name; + description.value = data.description; + has_readme.value = data.has_readme; + } }; return { name, description, has_readme, fetchProjects }; }, created() { - this.fetchProjects(this.$router.currentRoute._rawValue.params.repo); + this.fetchProjects(this.$router, this.$route.path); } }; </script> |