11<script setup lang="ts">
22import type { ToolbarType } from ' ./types' ;
33
4+ import { computed } from ' vue' ;
5+
46import { preferences , usePreferences } from ' @vben/preferences' ;
57
68import { Copyright } from ' ../basic/copyright' ;
@@ -11,6 +13,7 @@ import Toolbar from './toolbar.vue';
1113interface Props {
1214 appName? : string ;
1315 logo? : string ;
16+ logoDark? : string ;
1417 pageTitle? : string ;
1518 pageDescription? : string ;
1619 sloganImage? : string ;
@@ -20,10 +23,11 @@ interface Props {
2023 clickLogo? : () => void ;
2124}
2225
23- withDefaults (defineProps <Props >(), {
26+ const props = withDefaults (defineProps <Props >(), {
2427 appName: ' ' ,
2528 copyright: true ,
2629 logo: ' ' ,
30+ logoDark: ' ' ,
2731 pageDescription: ' ' ,
2832 pageTitle: ' ' ,
2933 sloganImage: ' ' ,
@@ -34,6 +38,18 @@ withDefaults(defineProps<Props>(), {
3438
3539const { authPanelCenter, authPanelLeft, authPanelRight, isDark } =
3640 usePreferences ();
41+
42+ /**
43+ * @zh_CN 根据主题选择合适的 logo 图标
44+ */
45+ const logoSrc = computed (() => {
46+ // 如果是暗色主题且提供了 logoDark,则使用暗色主题的 logo
47+ if (isDark .value && props .logoDark ) {
48+ return props .logoDark ;
49+ }
50+ // 否则使用默认的 logo
51+ return props .logo ;
52+ });
3753 </script >
3854
3955<template >
@@ -65,14 +81,21 @@ const { authPanelCenter, authPanelLeft, authPanelRight, isDark } =
6581 <slot name =" logo" >
6682 <!-- 头部 Logo 和应用名称 -->
6783 <div
68- v-if =" logo || appName"
84+ v-if =" logoSrc || appName"
6985 class =" absolute left-0 top-0 z-10 flex flex-1"
7086 @click =" clickLogo"
7187 >
7288 <div
7389 class =" text-foreground lg:text-foreground ml-4 mt-4 flex flex-1 items-center sm:left-6 sm:top-6"
7490 >
75- <img v-if =" logo" :alt =" appName" :src =" logo" class =" mr-2" width =" 42" />
91+ <img
92+ v-if =" logoSrc"
93+ :key =" logoSrc"
94+ :alt =" appName"
95+ :src =" logoSrc"
96+ class =" mr-2"
97+ width =" 42"
98+ />
7699 <p v-if =" appName" class =" m-0 text-xl font-medium" >
77100 {{ appName }}
78101 </p >
0 commit comments