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