refactor(projects): 代码优化

ISSUES CLOSED: \
This commit is contained in:
Soybean
2022-05-28 20:26:29 +08:00
parent be45d83766
commit 4c2f535a9b
5 changed files with 28 additions and 16 deletions

View File

@ -2,27 +2,27 @@
<div v-if="showTooltip">
<n-tooltip :placement="placement" trigger="hover">
<template #trigger>
<div class="flex-center h-full cursor-pointer dark:hover:bg-[#333]" :class="computedClass">
<div class="flex-center h-full cursor-pointer dark:hover:bg-[#333]" :class="contentClassName">
<slot></slot>
</div>
</template>
{{ tooltipContent }}
</n-tooltip>
</div>
<div v-else class="flex-center cursor-pointer dark:hover:bg-[#333]" :class="computedClass">
<div v-else class="flex-center cursor-pointer dark:hover:bg-[#333]" :class="contentClassName">
<slot></slot>
</div>
</template>
<script lang="ts" setup>
import { computed } from 'vue';
import type { FollowerPlacement } from 'vueuc';
import type { PopoverPlacement } from 'naive-ui';
interface Props {
/** tooltip显示文本 */
tooltipContent?: string;
/** tooltip的位置 */
placement?: FollowerPlacement;
placement?: PopoverPlacement;
/** class类 */
contentClass?: string;
/** 反转模式下 */
@ -37,8 +37,8 @@ const props = withDefaults(defineProps<Props>(), {
const showTooltip = computed(() => Boolean(props.tooltipContent));
const computedClass = computed(() =>
[props.contentClass, props.inverted ? 'hover:bg-primary' : 'hover:bg-[#f6f6f6]'].join(' ')
const contentClassName = computed(
() => `${props.contentClass} ${props.inverted ? 'hover:bg-primary' : 'hover:bg-[#f6f6f6]'}`
);
</script>

View File

@ -17,7 +17,7 @@
<script setup lang="ts">
import { computed } from 'vue';
import type { FollowerPlacement } from 'vueuc';
import type { PopoverPlacement } from 'naive-ui';
import type { EnumThemeLayoutMode } from '@/enum';
interface Props {
@ -34,7 +34,7 @@ const props = defineProps<Props>();
type LayoutConfig = Record<
EnumType.ThemeLayoutMode,
{
placement: FollowerPlacement;
placement: PopoverPlacement;
menuClass: string;
mainClass: string;
}