Skip to content

Commit f67f805

Browse files
LightLight
authored andcommitted
feat: 添加支持在未设定 Logo 时选取标题首字作为导航图片内容展示
1 parent 3954ca7 commit f67f805

4 files changed

Lines changed: 26 additions & 7 deletions

File tree

src/css/nav.css

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,24 @@ body.night .search-engine ul::before {
339339
transition: all 0.3s ease;
340340
}
341341

342-
.xe-comment-entry img {
342+
.xe-comment-entry img,
343+
.xe-comment-entry .no-img {
343344
float: left;
344345
display: block;
345346
margin-right: 10px;
346-
border-radius: 50px;
347+
}
348+
349+
.xe-comment-entry .no-img {
350+
width: 54px;
351+
height: 54px;
352+
font-size: 2em;
353+
background: #e8e1e1;
354+
text-align: center;
355+
line-height: 54px;
356+
}
357+
358+
body.night .xe-comment-entry .no-img {
359+
background: #282b2d;
347360
}
348361

349362
.xe-comment p {

src/footer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function show_date_time() {
6565
});
6666
</script>
6767
<?php endif; ?>
68-
<script src="<?php echo THEME_URL ?>/js/index.min.js"></script>
68+
<script src="<?php echo THEME_URL ?>/js/index.js"></script>
6969
<script src="<?php echo THEME_URL ?>/js/zui.js"></script>
7070
<script src="<?php echo THEME_URL ?>/js/bootstrap.min.js"></script>
7171
<script src="<?php echo THEME_URL ?>/js/TweenMax.min.js"></script>

src/index.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,12 @@ class="fa fa-heart xiaotubiao"
9090
data-original-title="<?php echo $posts->fields->url; ?>">
9191
<div class="xe-comment-entry">
9292
<span class="xe-user-img">
93-
<img src="<?php echo $posts->fields->logo; ?>" class="img-circle" width="54"
94-
alt="<?php $posts->title(); ?>">
93+
<?php if (strlen($posts->fields->logo) > 0) : ?>
94+
<img src="<?php echo $posts->fields->logo; ?>" class="img-circle" width="54"
95+
alt="<?php $posts->title(); ?>">
96+
<?php else : ?>
97+
<span class="img-circle no-img"><?php echo strlen($posts->title) > 0 ? mb_substr($posts->title, 0, 1) : '' ?></span>
98+
<?php endif; ?>
9599
</span>
96100
<div class="xe-comment">
97101
<span href="javascript:void(0);" class="xe-user-name overflowClip_1">
@@ -116,7 +120,8 @@ class="fa fa-heart xiaotubiao"
116120
<ul>
117121
<li class="fk_service_box fk_service_sidebar visible-xs"
118122
onclick="document.getElementById('01').click();" style="display: block;">
119-
<a id="01" href="#" rel="toggle-sidebar" class="fk_service_box fk_service_sidebar" title="切换侧栏" data-toggle="mobile-menu">1</a>
123+
<a id="01" href="#" rel="toggle-sidebar" class="fk_service_box fk_service_sidebar" title="切换侧栏"
124+
data-toggle="mobile-menu">1</a>
120125
</li>
121126
<li class="fk_service_box fk_service_upward"
122127
onclick="document.getElementById('02').click();" style="display: block;">
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3103,11 +3103,12 @@ function search() {
31033103
const curNavList = [];
31043104
const navList = document.querySelectorAll('.main-content .label-info');
31053105
navList.forEach(item => {
3106+
const userImg = item.querySelector('.xe-user-img img');
31063107
curNavList.push({
31073108
url: item.dataset.originalTitle || '',
31083109
title: item.querySelector('strong').textContent.trim() || '',
31093110
des: item.querySelector('p').textContent.trim() || '',
3110-
src: item.querySelector('.xe-user-img img').src || '',
3111+
src: (userImg && userImg.src) || '',
31113112
});
31123113
});
31133114

0 commit comments

Comments
 (0)