87 lines
2.9 KiB
HTML
87 lines
2.9 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block content %}
|
|
<div class="page-header">
|
|
<div>
|
|
<h1>全局搜索</h1>
|
|
<p class="muted">按名称或备注搜索箱子、物品和子物品,快速定位它们所在的位置。</p>
|
|
</div>
|
|
</div>
|
|
|
|
<section class="card">
|
|
<form method="get" action="/search" class="search-form">
|
|
<input
|
|
type="search"
|
|
name="q"
|
|
value="{{ query }}"
|
|
placeholder="例如:锅、电源线、冬衣、文件袋"
|
|
>
|
|
<button type="submit" class="button button-primary">搜索</button>
|
|
</form>
|
|
</section>
|
|
|
|
{% if query and ai_available %}
|
|
<section class="card" style="margin-top: 8px;">
|
|
{% if ai_activated %}
|
|
<span class="muted">AI 搜索已启用</span>
|
|
{% else %}
|
|
<a href="/search?q={{ query | urlencode }}&ai=1" class="button button-secondary" style="display:inline-block; text-decoration:none;">
|
|
AI 智能搜索
|
|
</a>
|
|
{% endif %}
|
|
</section>
|
|
{% endif %}
|
|
|
|
{% if searched %}
|
|
{% if ai_error %}
|
|
<section class="card" style="margin-top: 8px; border-color: #b42318;">
|
|
<p style="margin:0; color: #b42318;"><strong>{{ ai_error }}</strong></p>
|
|
</section>
|
|
{% endif %}
|
|
|
|
{% if ai_activated and expanded_terms %}
|
|
<section class="card" style="margin-top: 8px; border-color: #0b57d0;">
|
|
<p style="margin:0; color: #0b57d0;"><strong>AI 帮你扩展了:</strong>{{ expanded_terms | join('、') }}</p>
|
|
</section>
|
|
{% endif %}
|
|
|
|
{% if results %}
|
|
<section class="stack">
|
|
<p class="muted">共找到 {{ results|length }} 条结果。</p>
|
|
{% for result in results %}
|
|
<article class="card search-result">
|
|
{% if result.image_url %}
|
|
<img src="{{ result.image_url }}" alt="{{ result.name }}" class="thumb-image">
|
|
{% endif %}
|
|
<div class="result-body">
|
|
<p class="meta">类型:{{ result.type }}</p>
|
|
<h2>{{ result.name }}</h2>
|
|
<p><strong>定位:</strong>{{ result.path }}</p>
|
|
{% if result.type == "Item" and result.is_container %}
|
|
<p><strong>容器:</strong>是</p>
|
|
{% endif %}
|
|
{% if result.note %}
|
|
<p><strong>备注:</strong>{{ result.note }}</p>
|
|
{% endif %}
|
|
<div class="actions">
|
|
<a href="{{ result.detail_url }}">{{ result.detail_label }}</a>
|
|
{% if result.secondary_url %}
|
|
<a href="{{ result.secondary_url }}">{{ result.secondary_label }}</a>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
</article>
|
|
{% endfor %}
|
|
</section>
|
|
{% else %}
|
|
<section class="card">
|
|
<p>没有找到匹配结果。</p>
|
|
</section>
|
|
{% endif %}
|
|
{% else %}
|
|
<section class="card">
|
|
<p>输入关键词后,可以跨 Box、Item、SubItem 进行搜索。</p>
|
|
</section>
|
|
{% endif %}
|
|
{% endblock %}
|