1
0
mirror of https://github.com/zclzone/vue-naive-admin.git synced 2025-12-26 19:20:21 +08:00

fix(slot): 优化部分slot写法,减少手动判断 (#101)

* fix(slot): 优化部分slot写法,减少手动判断

* fix(slot): 优化部分slot写法,减少手动判断
This commit is contained in:
leip247
2024-11-13 11:05:03 +08:00
committed by GitHub
parent 69e6e9a14a
commit 6af6eb3c99
3 changed files with 36 additions and 31 deletions

View File

@@ -11,8 +11,9 @@
<main :class="{ 'flex-1': full }" class="m-12">
<slot />
</main>
<slot v-if="$slots.footer" name="footer" />
<TheFooter v-else-if="showFooter" class="mb-12 mt-auto" />
<slot name="footer">
<TheFooter v-if="showFooter" class="mb-12 mt-auto" />
</slot>
<n-back-top :bottom="20" />
</main>
</template>

View File

@@ -16,16 +16,18 @@
<slot v-if="$slots.header" name="header" />
<template v-else>
<div class="flex items-center">
<slot v-if="$slots['title-prefix']" name="title-prefix" />
<template v-else-if="back">
<div
class="mr-16 flex cursor-pointer items-center text-16 opacity-60 transition-all-300 hover:opacity-40"
@click="router.back()"
>
<i class="i-material-symbols:arrow-left-alt" />
<span class="ml-4">返回</span>
</div>
</template>
<slot name="title-prefix">
<template v-if="back">
<div
class="mr-16 flex cursor-pointer items-center text-16 opacity-60 transition-all-300 hover:opacity-40"
@click="router.back()"
>
<i class="i-material-symbols:arrow-left-alt" />
<span class="ml-4">返回</span>
</div>
</template>
</slot>
<div class="mr-12 h-16 w-4 rounded-l-2 bg-primary" />
<h2 class="font-normal">
{{ title ?? route.meta?.title }}
@@ -39,10 +41,11 @@
<slot />
</AppCard>
<slot v-if="$slots.footer" name="footer" />
<AppCard v-else-if="showFooter" class="flex-shrink-0 py-12">
<TheFooter />
</AppCard>
<slot name="footer">
<AppCard v-if="showFooter" class="flex-shrink-0 py-12">
<TheFooter />
</AppCard>
</slot>
</main>
</template>