mirror of
https://github.com/YunoHost/yunohost-admin.git
synced 2024-09-03 20:06:15 +02:00
feat: add more complex skeleton definitions
This commit is contained in:
parent
59f7b59408
commit
e0816d14e1
3 changed files with 14 additions and 5 deletions
2
app/overrides.d.ts
vendored
2
app/overrides.d.ts
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
import type { Skeleton } from '@/types/commons'
|
||||||
import 'vue-router'
|
import 'vue-router'
|
||||||
|
|
||||||
declare module 'vue-router' {
|
declare module 'vue-router' {
|
||||||
|
@ -6,6 +7,7 @@ declare module 'vue-router' {
|
||||||
routerParams?: string[]
|
routerParams?: string[]
|
||||||
args: { trad?: string; param?: string }
|
args: { trad?: string; param?: string }
|
||||||
breadcrumb?: string[]
|
breadcrumb?: string[]
|
||||||
|
skeleton?: (Skeleton | string)[] | Skeleton | string
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
import { useInfos } from '@/composables/useInfos'
|
import { useInfos } from '@/composables/useInfos'
|
||||||
import { useRequests } from '@/composables/useRequests'
|
import { useRequests } from '@/composables/useRequests'
|
||||||
import { useSettings } from '@/composables/useSettings'
|
import { useSettings } from '@/composables/useSettings'
|
||||||
import type { VueClass } from '@/types/commons'
|
import type { Skeleton, VueClass } from '@/types/commons'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const { routerKey } = useInfos()
|
const { routerKey } = useInfos()
|
||||||
|
@ -25,9 +25,13 @@ const RootView = createReusableTemplate<{
|
||||||
classes: VueClass
|
classes: VueClass
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const skeleton = computed(
|
const skeletons = computed<Skeleton[]>(() => {
|
||||||
() => router.currentRoute.value.meta.skeleton || 'CardInfoSkeleton',
|
const skeleton = router.currentRoute.value.meta.skeleton ?? 'CardInfoSkeleton'
|
||||||
)
|
const skeletons = Array.isArray(skeleton) ? skeleton : [skeleton]
|
||||||
|
return skeletons.map((skeleton) =>
|
||||||
|
typeof skeleton === 'string' ? { is: skeleton } : skeleton,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
const modalComponent = computed(() => {
|
const modalComponent = computed(() => {
|
||||||
if (reconnecting.value) {
|
if (reconnecting.value) {
|
||||||
|
@ -72,7 +76,9 @@ const modalComponent = computed(() => {
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<Component :is="Component" :class="classes" />
|
<Component :is="Component" :class="classes" />
|
||||||
<template #fallback>
|
<template #fallback>
|
||||||
<Component :is="skeleton" />
|
<template v-for="({ is, ...props }, i) in skeletons" :key="i">
|
||||||
|
<Component :is="is" v-bind="props" />
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ export type Cols = Partial<Record<Breakpoint, boolean | ColsNumbers | 'auto'>>
|
||||||
|
|
||||||
// CUSTOM
|
// CUSTOM
|
||||||
|
|
||||||
|
export type Skeleton = { is: string } & Obj
|
||||||
export type CustomRoute = {
|
export type CustomRoute = {
|
||||||
to: RouteLocationNamedRaw
|
to: RouteLocationNamedRaw
|
||||||
text: string
|
text: string
|
||||||
|
|
Loading…
Reference in a new issue