fix: 修復主頁滾動, 頂部圖有延遲的 bug closed #1372

fix: 修復當設置搜索文件為xml時,搜索 < 和 > 沒有結果的 bug closed #1369
fix: 修復 CDN 的 custom_format 沒配置,preconnect 報錯的 bug closed #1371
pull/1388/head
Jerry 1 year ago
parent f9a2ad70ce
commit 0d40e75589

@ -4,7 +4,7 @@
'jsdelivr': '//cdn.jsdelivr.net', 'jsdelivr': '//cdn.jsdelivr.net',
'cdnjs': '//cdnjs.cloudflare.com', 'cdnjs': '//cdnjs.cloudflare.com',
'unpkg': '//unpkg.com', 'unpkg': '//unpkg.com',
'custom': custom_format.match(/^((https?:)?(\/\/[^/]+)|([^/]+))(\/|$)/)[1] 'custom': custom_format && custom_format.match(/^((https?:)?(\/\/[^/]+)|([^/]+))(\/|$)/)[1]
} }
- -

@ -15,7 +15,7 @@
.local-search-box .local-search-box
input(placeholder=_p("search.local_search.input_placeholder") type="text").local-search-box--input input(placeholder=_p("search.local_search.input_placeholder") type="text").local-search-box--input
hr hr
#local-search-results.no-result #local-search-results
#local-search-stats-wrap #local-search-stats-wrap
#search-mask #search-mask

@ -1,6 +1,6 @@
{ {
"name": "hexo-theme-butterfly", "name": "hexo-theme-butterfly",
"version": "4.10.0-b2", "version": "4.10.0-b3",
"description": "A Simple and Card UI Design theme for Hexo", "description": "A Simple and Card UI Design theme for Hexo",
"main": "package.json", "main": "package.json",
"scripts": { "scripts": {

@ -134,7 +134,7 @@ if hexo-config('enter_transitions')
#footer #footer
animation: bottom-top 1s animation: bottom-top 1s
#page-header #page-header:not(.full_page)
animation: header-effect 1s animation: header-effect 1s
#site-title, #site-title,

@ -64,10 +64,6 @@
+maxWidth768() +maxWidth768()
max-height: calc(var(--search-height) - 220px) !important max-height: calc(var(--search-height) - 220px) !important
.no-result
& + #local-search-stats-wrap
display: none
.search-keyword .search-keyword
background: transparent background: transparent
color: $search-keyword-highlight color: $search-keyword-highlight

@ -246,10 +246,12 @@ window.addEventListener('load', () => {
const input = document.querySelector('#local-search-input input') const input = document.querySelector('#local-search-input input')
const statsItem = document.getElementById('local-search-stats-wrap') const statsItem = document.getElementById('local-search-stats-wrap')
const $loadingStatus = document.getElementById('loading-status') const $loadingStatus = document.getElementById('loading-status')
const isXml = !path.endsWith('json')
const inputEventFunction = () => { const inputEventFunction = () => {
if (!localSearch.isfetched) return if (!localSearch.isfetched) return
const searchText = input.value.trim().toLowerCase() let searchText = input.value.trim().toLowerCase()
isXml && (searchText = searchText.replace(/</g, '&lt;').replace(/>/g, '&gt;'))
if (searchText !== '') $loadingStatus.innerHTML = '<i class="fas fa-spinner fa-pulse"></i>' if (searchText !== '') $loadingStatus.innerHTML = '<i class="fas fa-spinner fa-pulse"></i>'
const keywords = searchText.split(/[-\s]+/) const keywords = searchText.split(/[-\s]+/)
const container = document.getElementById('local-search-results') const container = document.getElementById('local-search-results')
@ -259,11 +261,14 @@ window.addEventListener('load', () => {
resultItems = localSearch.getResultItems(keywords) resultItems = localSearch.getResultItems(keywords)
} }
if (keywords.length === 1 && keywords[0] === '') { if (keywords.length === 1 && keywords[0] === '') {
container.classList.add('no-result')
container.textContent = '' container.textContent = ''
statsItem.textContent = ''
} else if (resultItems.length === 0) { } else if (resultItems.length === 0) {
container.textContent = '' container.textContent = ''
statsItem.innerHTML = `<div class="search-result-stats">${languages.hits_empty.replace(/\$\{query}/, searchText)}</div>` const statsDiv = document.createElement('div')
statsDiv.className = 'search-result-stats'
statsDiv.textContent = languages.hits_empty.replace(/\$\{query}/, searchText)
statsItem.innerHTML = statsDiv.outerHTML
} else { } else {
resultItems.sort((left, right) => { resultItems.sort((left, right) => {
if (left.includedCount !== right.includedCount) { if (left.includedCount !== right.includedCount) {
@ -276,7 +281,6 @@ window.addEventListener('load', () => {
const stats = languages.hits_stats.replace(/\$\{hits}/, resultItems.length) const stats = languages.hits_stats.replace(/\$\{hits}/, resultItems.length)
container.classList.remove('no-result')
container.innerHTML = `<div class="search-result-list">${resultItems.map(result => result.item).join('')}</div>` container.innerHTML = `<div class="search-result-list">${resultItems.map(result => result.item).join('')}</div>`
statsItem.innerHTML = `<hr><div class="search-result-stats">${stats}</div>` statsItem.innerHTML = `<hr><div class="search-result-stats">${stats}</div>`
window.pjax && window.pjax.refresh(container) window.pjax && window.pjax.refresh(container)

Loading…
Cancel
Save