Skip to content

Commit

Permalink
fix: improve UI layout of pages tab
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Oct 11, 2023
1 parent c930126 commit 66e59ae
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 26 deletions.
1 change: 1 addition & 0 deletions packages/devtools-ui-kit/src/components/NTextInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const props = withDefaults(
type: 'text',
},
)
const emit = defineEmits<{ (...args: any): void }>()
const input = useVModel(props, 'modelValue', emit, { passive: true })
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/components/RoutesTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function getMiddlewarePath(name: any) {
v-text="'active'"
/>
<NBadge
v-if="matchedPending.find(m => m.name === item.name)"
v-else-if="matchedPending.find(m => m.name === item.name)"
n="teal"
title="next"
v-text="'next'"
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools/client/composables/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function useClient() {
return useState<NuxtDevtoolsHostClient>('devtools-client')
}

export function useClientRoute() {
export function useClientRoute(): ComputedRef<ReturnType<typeof useRoute>> {
const client = useClient()
return computed(() => client.value?.nuxt.vueApp.config.globalProperties?.$route)
}
Expand Down
9 changes: 9 additions & 0 deletions packages/devtools/client/pages/__blank.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script setup lang="ts">
definePageMeta({
layout: 'none',
})
</script>

<template>
<div h-screen w-screen bg-black />
</template>
44 changes: 20 additions & 24 deletions packages/devtools/client/pages/modules/pages.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<script setup lang="ts">
import { nextTick } from 'vue'
definePageMeta({
icon: 'carbon-tree-view-alt',
title: 'Pages',
Expand All @@ -20,21 +18,15 @@ const layouts = useLayouts()
const routes = useMergedRouteList()
const middleware = computed(() => {
return serverApp.value?.middleware || []
})
const middleware = computed(() => serverApp.value?.middleware || [])
const routeInput = ref('')
until(route).toBeTruthy().then((v) => {
routeInput.value = v.path
})
onMounted(() => {
if (route.value)
routeInput.value = route.value.path
until(router).toBeTruthy().then((v) => {
v.afterEach(() => {
nextTick(() => {
routeInput.value = route.value.path
})
router.value?.afterEach((to) => {
routeInput.value = to.fullPath
})
})
Expand All @@ -44,13 +36,12 @@ async function navigate() {
}
const routeInputMatched = computed(() => {
if (routeInput.value === route.value.path)
return []
return router.value.resolve(routeInput.value || '/').matched
})
function navigateToRoute(path: string) {
router.value.push(path)
routeInput.value = path
}
</script>

Expand Down Expand Up @@ -85,18 +76,23 @@ function navigateToRoute(path: string) {
</div>
</div>
<NSectionBlock
v-if="routeInputMatched.length"
icon="carbon-tree-view"
text="Matched Routes"
:padding="false"
>
<RoutesTable
:pages="routeInputMatched"
:layouts="layouts || []"
:matched="[]"
:matched-pending="routeInputMatched"
@navigate="navigateToRoute"
/>
<div min-h-14>
<RoutesTable
v-if="routeInputMatched.length"
:pages="routeInputMatched"
:layouts="layouts || []"
:matched="route.matched"
:matched-pending="routeInputMatched"
@navigate="navigateToRoute"
/>
<div v-else class="py-4 text-center">
<span op50>No routes matched</span>
</div>
</div>
</NSectionBlock>
<NSectionBlock
icon="carbon-tree-view-alt"
Expand Down

0 comments on commit 66e59ae

Please sign in to comment.