Skip to content

Commit 8a77dfc

Browse files
committed
refactor(App): add Tab type-guard
1 parent c42ad06 commit 8a77dfc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ const tabs = computed(() => {
3737
return entries;
3838
});
3939
40+
const isFeedTab = (payload: unknown): payload is Tab => tabs.value.some(({ value }) => value === payload);
4041
const selectedTab = computed<Tab>({
41-
get: () => route.name?.toString() as Tab ?? tabs.value[0].value,
42+
get: () => isFeedTab(route.name) ? route.name : tabs.value[0].value,
4243
set: (name) => { router.push({ name }); }
4344
});
4445
</script>

0 commit comments

Comments
 (0)