File size: 2,671 Bytes
8ede856 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | <template>
<div class="logo-container">
<div class="logo-content">
<div class="logo-image">
<img width="110" src="@/assets/images/astrbot_logo_mini.webp" alt="AstrBot Logo">
</div>
<div class="logo-text">
<h2
:style="{color: useCustomizerStore().uiTheme === 'PurpleTheme' ? '#5e35b1' : '#d7c5fa'}"
v-html="formatTitle(title || t('core.header.logoTitle'))"
></h2>
<!-- 父子组件传递css变量可能会出错,暂时使用十六进制颜色值 -->
<h4 :style="{color: useCustomizerStore().uiTheme === 'PurpleTheme' ? '#000000aa' : '#ffffffcc'}"
class="hint-text">{{ subtitle || t('core.header.accountDialog.title') }}</h4>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { useCustomizerStore } from "@/stores/customizer";
import { useI18n } from '@/i18n/composables';
const { t } = useI18n();
const props = withDefaults(defineProps<{
title?: string;
subtitle?: string;
}>(), {
title: '', // 默认为空,组件会使用翻译值
subtitle: ''
})
// 智能格式化标题,在小屏幕上允许在合适位置换行
const formatTitle = (title: string) => {
// 如果标题包含 "AstrBot" 和其他文字,在它们之间添加换行机会
if (title.includes('AstrBot ') || title.includes('AstrBot')) {
// 处理 "AstrBot 仪表盘" 或 "AstrBot Dashboard" 等格式
return title.replace(/(AstrBot)\s+(.+)/, '$1<wbr> $2');
}
return title;
}
</script>
<style scoped>
.logo-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%;
margin-bottom: 10px;
}
.logo-content {
display: flex;
align-items: center;
gap: 20px;
padding: 10px;
max-width: 100%;
overflow: visible;
}
.logo-image {
display: flex;
justify-content: center;
align-items: center;
}
.logo-image img {
transition: transform 0.3s ease;
}
.logo-text {
display: flex;
flex-direction: column;
align-items: flex-start;
min-width: 0;
flex: 1;
}
.logo-text h2 {
margin: 0;
font-size: 1.8rem;
font-weight: 600;
letter-spacing: 0.5px;
white-space: nowrap;
min-width: fit-content;
}
/* 在小屏幕上允许在指定位置换行 */
@media (max-width: 420px) {
.logo-text h2 {
line-height: 1.3;
}
}
.logo-text h4 {
margin: 4px 0 0 0;
font-size: 1rem;
font-weight: 400;
letter-spacing: 0.3px;
white-space: nowrap;
}
/* 响应式处理 */
@media (max-width: 520px) {
.logo-content {
gap: 15px;
}
.logo-text h2 {
font-size: 1.6rem;
}
.logo-text h4 {
font-size: 0.9rem;
}
.logo-image img {
width: 90px;
}
}
</style>
|