2024-07-10 21:26:10 +08:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<th:block
|
2024-07-30 05:32:35 +08:00
|
|
|
th:insert="~{common/layout :: layout (title = ${theme.config.page_config.search.search_title} + ' - ' + ${site.title}, canonical = @{/search}, content = ~{::content}, isPost = true)}"
|
|
|
|
th:with="isJournals = true, enableShare = false, baseEnableComment = false"
|
|
|
|
xmlns:th="https://www.thymeleaf.org">
|
|
|
|
<th:block th:fragment="content">
|
|
|
|
<div class="card card-content search">
|
|
|
|
<div class="card-tab">
|
|
|
|
<div>[[${#strings.replace(title, ' - ' + site.title, '')}]]</div>
|
|
|
|
</div>
|
|
|
|
<div class="search-box">
|
|
|
|
<script th:inline="javascript">
|
|
|
|
$(function () {
|
|
|
|
var searchForm = document.getElementById('halo-search-form')
|
|
|
|
searchForm.addEventListener('submit', function (event) {
|
|
|
|
var searchInput = document.getElementById('halo-search-form-text-input')
|
|
|
|
var query = searchInput.value.trim()
|
|
|
|
if (!query || query.startsWith('*')) {
|
|
|
|
event.preventDefault()
|
|
|
|
Qmsg.warning(!query ? '请输入内容' : '不能输入星号(*)作为内容开头')
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if (DreamConfig.pjax_state) {
|
|
|
|
event.preventDefault()
|
|
|
|
searchForm.setAttribute('data-pjax', '')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
document.addEventListener('keydown', function (event) {
|
|
|
|
if (event.key === 'Enter') {
|
|
|
|
if (!searchForm.contains(document.activeElement)) {
|
|
|
|
event.preventDefault() // 阻止默认行为
|
|
|
|
searchForm.dispatchEvent(new Event('submit')) // 触发submit事件
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
</script>
|
|
|
|
<form id="halo-search-form" class="search-form-inner" method="get" action="/search" role="search">
|
|
|
|
<input type="hidden" name="limit" th:value="${theme.config.page_config.search.search_limit}">
|
|
|
|
<input
|
|
|
|
id="halo-search-form-text-input"
|
|
|
|
class="text-input"
|
|
|
|
type="search"
|
|
|
|
name="keyword"
|
|
|
|
th:title="${theme.config.page_config.search.search_placeholder}"
|
|
|
|
th:placeholder="${theme.config.page_config.search.search_placeholder}"
|
|
|
|
th:value="${searchResult.keyword}"
|
|
|
|
/>
|
|
|
|
<button class="search-form-btn" th:title="${theme.config.page_config.search.search_btn_title}"
|
|
|
|
type="submit">
|
|
|
|
<i class="ri-search-line"></i>
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
</div>
|
2024-07-10 21:26:10 +08:00
|
|
|
</div>
|
2024-07-30 05:32:35 +08:00
|
|
|
<div th:if="${searchResult.hits.size() > 0}" class="widget card search" th:each="hit : ${searchResult.hits}">
|
|
|
|
<div class="card-content main">
|
|
|
|
<a th:href="${hit.permalink}" th:target="${theme.config.page_config.search.search_target}">
|
|
|
|
<h2 class="title">[(${hit.title})]</h2>
|
|
|
|
</a>
|
|
|
|
<!-- <div class="main-content not-toc description" th:utext="${hit.description}">-->
|
|
|
|
<!-- </div>-->
|
|
|
|
<hr/>
|
|
|
|
<div class="meta">
|
|
|
|
<div></div>
|
|
|
|
<em th:text="'最后更新于 ' + ${#dates.format(hit.updateTimestamp,'yyyy年MM月dd日 HH:mm:ss')}"></em>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div th:unless="${searchResult.hits.size() > 0}" class="widget card search">
|
|
|
|
<div class="result-empty">
|
|
|
|
<div class="result-empty-tips" th:utext="${theme.config.page_config.search.search_empty_tips}"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</th:block>
|
2024-07-10 21:26:10 +08:00
|
|
|
</th:block>
|