From e9e387d602df2792e89bee6cb7df4d0c42c9fe56 Mon Sep 17 00:00:00 2001 From: xueyitt <1455668754@qq.com> Date: Tue, 25 Aug 2026 18:01:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B7=A6=E4=B8=8ALogo=E4=B8=8E?= =?UTF-8?q?=E6=96=87=E6=A1=88=E5=85=81=E8=AE=B8=E9=80=9A=E8=BF=87props?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=EF=BC=9B=20=E9=80=82=E9=85=8D=E5=9C=BA?= =?UTF-8?q?=E6=99=AF=EF=BC=9A=E5=A4=9A=E5=BA=94=E7=94=A8or=E5=A4=9A?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=EF=BC=8C=E4=B8=8D=E5=90=8C=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E4=BB=8E=E5=90=8E=E5=8F=B0=E6=88=96=E8=80=85=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E5=BD=A2=E5=BC=8F=E8=AE=BE=E7=BD=AE=E5=90=84=E8=87=AA=E7=8B=AC?= =?UTF-8?q?=E7=AB=8B=E7=9A=84logo=E4=B8=8E=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: 左上Logo与文案允许通过props传入; 适配场景:多应用or多项目,不同项目从后台或者其他形式设置各自独立的logo与名称 --- packages/effects/layouts/src/basic/layout.vue | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/packages/effects/layouts/src/basic/layout.vue b/packages/effects/layouts/src/basic/layout.vue index 59b45e99c..f8d8dc5eb 100644 --- a/packages/effects/layouts/src/basic/layout.vue +++ b/packages/effects/layouts/src/basic/layout.vue @@ -38,7 +38,10 @@ import { useLayoutScroll } from './use-layout-scroll'; defineOptions({ name: 'BasicLayout' }); -withDefaults(defineProps(), { +const props = withDefaults(defineProps(), { + logoSrc: '', + logoSrcDark: '', + logoText: '', avatar: '', text: '', }); @@ -50,10 +53,27 @@ const emit = defineEmits<{ }>(); interface Props { + /** 自定义 Logo 图片地址,不传则使用偏好设置默认值 */ + logoSrc?: string; + /** 自定义暗色主题 Logo 图片地址 */ + logoSrcDark?: string; + /** 自定义 Logo 文本,不传则使用偏好设置默认值 */ + logoText?: string; + /** 用户头像图片地址 */ avatar?: string; + /** 用户文本(如用户名) */ text?: string; } +/** 最终使用的 Logo 图片地址(自定义优先,否则使用默认) */ +const finalLogoSrc = computed(() => props.logoSrc || preferences.logo.source); +/** 最终使用的暗色 Logo 图片地址 */ +const finalLogoSrcDark = computed( + () => props.logoSrcDark || preferences.logo.sourceDark, +); +/** 最终使用的 Logo 文本(自定义优先,否则使用默认应用名称) */ +const finalLogoText = computed(() => props.logoText || preferences.app.name); + const { isDark, isHeaderNav, @@ -323,9 +343,9 @@ const headerSlots = computed(() => { :fit="preferences.logo.fit" :class="logoClass" :collapsed="logoCollapsed" - :src="preferences.logo.source" - :src-dark="preferences.logo.sourceDark" - :text="preferences.app.name" + :src="finalLogoSrc" + :src-dark="finalLogoSrcDark" + :text="finalLogoText" :show-text="preferences.logo.showText" :logo-mode="preferences.logo.logoMode" :full-logo-height="preferences.logo.fullLogoHeight" @@ -419,8 +439,8 @@ const headerSlots = computed(() => {