Skip to content

Commit 7b89de2

Browse files
authored
Merge pull request #5352 from jumpserver/pr@osm@perf_logo_title
remove font famliy
2 parents e2eeee0 + a81aa6a commit 7b89de2

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

‎src/layout/components/NavHeader/index.vue‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
<ul class="navbar-left">
4343
<li class="left-item">
4444
<div class="nav-logo">
45-
<Logo v-if="showLogo" :collapse="false" />
45+
<!-- TODO 根据 INTERFACE store 的开关动态设置 -->
46+
<Logo v-if="showLogo" :collapse="true" />
4647
</div>
4748
</li>
4849
<li v-if="orgsShow" class="left-item" style="margin-left: 20px">

‎src/layout/components/NavLeft/Logo.vue‎

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<template>
2-
<!-- TODO title 拼接形式 -->
32
<div :class="{ collapse: collapse }" class="sidebar-logo-container">
43
<transition name="sidebarLogoFade">
54
<a v-if="collapse" key="collapse" class="sidebar-logo-link" @click="handleClick">
65
<img :src="logoSrc" alt="logo" class="sidebar-logo" />
6+
<span :style="logoTitleStyle" class="sidebar-title">{{ logoTitle }}</span>
77
</a>
88
<a v-else key="expand" class="sidebar-logo-link" @click="handleClick">
99
<img :src="logoTextSrc" alt="logo" class="sidebar-logo-text" />
@@ -37,6 +37,28 @@ export default {
3737
},
3838
logoTitle() {
3939
return this.publicSettings['INTERFACE']['login_title']
40+
},
41+
logoTitleStyle() {
42+
const minFontSize = 10
43+
const maxFontSize = 16
44+
const titleLength = (this.logoTitle || '').trim().length || 1
45+
const sidebarWidth = 200
46+
const marginLeft = 10
47+
const horizontalPadding = 10
48+
const logoWidth = 32
49+
const gap = 8
50+
const letterSpacing = 1.5
51+
const availableWidth = sidebarWidth - marginLeft - horizontalPadding - logoWidth - gap
52+
const availableTextWidth = Math.max(
53+
minFontSize,
54+
availableWidth - Math.max(0, titleLength - 1) * letterSpacing
55+
)
56+
const fontSize = Math.max(minFontSize, Math.floor(availableTextWidth / titleLength))
57+
58+
return {
59+
fontSize: `${Math.min(maxFontSize, fontSize)}px`,
60+
maxWidth: `${availableWidth}px`
61+
}
4062
}
4163
},
4264
created() {},
@@ -79,6 +101,7 @@ export default {
79101
overflow: hidden;
80102
81103
& .sidebar-logo-link {
104+
box-sizing: border-box;
82105
display: flex;
83106
gap: 8px;
84107
align-items: center;
@@ -100,19 +123,17 @@ export default {
100123
101124
& .sidebar-title {
102125
display: inline-block;
126+
flex: 1;
127+
min-width: 0;
103128
color: #fff;
104129
font-weight: 600;
105-
margin-top: 5px;
106130
line-height: $headerHeight;
107-
font-size: 20px;
108-
font-family:
109-
Avenir,
110-
Helvetica Neue,
111-
Arial,
112-
Helvetica,
113-
sans-serif;
131+
font-size: 16px;
132+
text-align: left;
114133
vertical-align: middle;
115134
letter-spacing: 1.5px;
135+
white-space: nowrap;
136+
overflow: hidden;
116137
}
117138
}
118139

0 commit comments

Comments
 (0)