115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
1
2
3
4
5
|
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
3bb1af6b
tangwang
tenant1和tenant2 m...
|
6
|
<title>Product Search - for Shoplazza</title>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
7
|
<link rel="stylesheet" href="/static/css/style.css">
|
a2fd1661
tangwang
前端支持sugg,对接到另外单独的...
|
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
<style>
.suggestions-list {
position: absolute;
top: 100%;
left: 0;
right: 0;
background: white;
border: 1px solid #ddd;
border-radius: 4px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
max-height: 300px;
overflow-y: auto;
z-index: 1000;
margin-top: 2px;
}
.suggestion-item {
padding: 10px 15px;
cursor: pointer;
border-bottom: 1px solid #f0f0f0;
transition: background-color 0.2s;
}
.suggestion-item:hover,
.suggestion-item.highlighted {
background-color: #f5f5f5;
}
.suggestion-item:last-child {
border-bottom: none;
}
.suggestion-text {
font-size: 14px;
color: #333;
}
.suggestion-meta {
font-size: 12px;
color: #999;
margin-top: 2px;
}
</style>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
46
47
|
</head>
<body>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
48
49
50
51
52
53
54
55
56
57
|
<div class="page-container">
<!-- Header -->
<header class="top-header">
<div class="header-left">
<span class="logo">Product</span>
<span class="product-count" id="productCount">0 products found</span>
</div>
<div class="header-right">
<button class="fold-btn" onclick="toggleFilters()">Fold</button>
</div>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
58
59
|
</header>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
60
61
|
<!-- Search Bar -->
<div class="search-bar">
|
4d824a77
tangwang
所有租户共用一套统一配置.tena...
|
62
|
<div class="tenant-input-wrapper">
|
3bb1af6b
tangwang
tenant1和tenant2 m...
|
63
|
<label for="tenantInput">tenant ID:</label>
|
6d524cb4
tangwang
docs优化
|
64
|
<input type="text" id="tenantInput" placeholder="请输入租户ID" value="162">
|
4d824a77
tangwang
所有租户共用一套统一配置.tena...
|
65
|
</div>
|
c4263d93
tangwang
支持 sku_filter_dim...
|
66
67
68
69
|
<div class="tenant-input-wrapper">
<label for="skuFilterDimension">sku_filter_dimension:</label>
<input type="text" id="skuFilterDimension" placeholder="SKU筛选维度" value="color">
</div>
|
a2fd1661
tangwang
前端支持sugg,对接到另外单独的...
|
70
71
72
73
74
|
<div class="search-input-wrapper" style="position: relative;">
<input type="text" id="searchInput" placeholder="输入搜索关键词... (支持中文、英文、俄文)"
onkeypress="handleKeyPress(event)" oninput="handleSearchInput(event)">
<div id="suggestionsList" class="suggestions-list" style="display: none;"></div>
</div>
|
3bb1af6b
tangwang
tenant1和tenant2 m...
|
75
|
<button onclick="performSearch()" class="search-btn">Search</button>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
76
77
78
79
|
</div>
<!-- Filter Section -->
<div class="filter-section" id="filterSection">
|
a10a89a3
tangwang
构造测试数据用于测试分类 和 三种...
|
80
|
<!-- Category Filter (一级分类) -->
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
81
|
<div class="filter-row">
|
a10a89a3
tangwang
构造测试数据用于测试分类 和 三种...
|
82
83
|
<div class="filter-label">Category:</div>
<div class="filter-tags" id="category1Tags"></div>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
84
85
|
</div>
|
a10a89a3
tangwang
构造测试数据用于测试分类 和 三种...
|
86
|
<!-- Color Filter -->
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
87
|
<div class="filter-row">
|
a10a89a3
tangwang
构造测试数据用于测试分类 和 三种...
|
88
89
|
<div class="filter-label">Color:</div>
<div class="filter-tags" id="colorTags"></div>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
90
91
|
</div>
|
a10a89a3
tangwang
构造测试数据用于测试分类 和 三种...
|
92
|
<!-- Size Filter -->
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
93
|
<div class="filter-row">
|
a10a89a3
tangwang
构造测试数据用于测试分类 和 三种...
|
94
95
96
97
98
99
100
101
|
<div class="filter-label">Size:</div>
<div class="filter-tags" id="sizeTags"></div>
</div>
<!-- Material Filter -->
<div class="filter-row">
<div class="filter-label">Material:</div>
<div class="filter-tags" id="materialTags"></div>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
102
103
|
</div>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
104
105
106
107
|
<!-- Dropdown Filters -->
<div class="filter-row">
<div class="filter-label">Others:</div>
<div class="filter-dropdowns">
|
edd38328
tangwang
测试过滤、聚合、排序
|
108
|
<select id="priceFilter" onchange="handlePriceFilter(this.value)">
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
109
110
111
112
113
114
|
<option value="">Price</option>
<option value="0-50">0-50</option>
<option value="50-100">50-100</option>
<option value="100-200">100-200</option>
<option value="200+">200+</option>
</select>
|
edd38328
tangwang
测试过滤、聚合、排序
|
115
116
117
118
119
120
121
122
|
<select id="timeFilter" onchange="handleTimeFilter(this.value)">
<option value="">Listing Time</option>
<option value="today">Today</option>
<option value="week">This Week</option>
<option value="month">This Month</option>
<option value="3months">Last 3 Months</option>
<option value="6months">Last 6 Months</option>
</select>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
123
124
|
<button class="clear-filters-btn" onclick="clearAllFilters()" style="display: none;" id="clearFiltersBtn">Clear Filters</button>
</div>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
125
126
127
|
</div>
</div>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
128
129
|
<!-- Sort Section -->
<div class="sort-section">
|
edd38328
tangwang
测试过滤、聚合、排序
|
130
131
|
<button class="sort-btn active" data-sort="" onclick="setSortByDefault()">By default</button>
<button class="sort-btn" data-sort="create_time">
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
132
133
|
By New Products
<span class="sort-arrows">
|
edd38328
tangwang
测试过滤、聚合、排序
|
134
135
|
<span class="arrow-up" data-field="create_time" data-order="desc" onclick="sortByField('create_time', 'desc')">▲</span>
<span class="arrow-down" data-field="create_time" data-order="asc" onclick="sortByField('create_time', 'asc')">▼</span>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
136
137
|
</span>
</button>
|
13320ac6
tangwang
分面接口修改:
|
138
|
<button class="sort-btn" data-sort="price">
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
139
140
|
By Price
<span class="sort-arrows">
|
13320ac6
tangwang
分面接口修改:
|
141
142
143
144
145
146
147
148
149
|
<span class="arrow-up" data-field="price" data-order="asc" onclick="sortByField('price', 'asc')">▲</span>
<span class="arrow-down" data-field="price" data-order="desc" onclick="sortByField('price', 'desc')">▼</span>
</span>
</button>
<button class="sort-btn" data-sort="sales">
By Sales
<span class="sort-arrows">
<span class="arrow-up" data-field="sales" data-order="desc" onclick="sortByField('sales', 'desc')">▲</span>
<span class="arrow-down" data-field="sales" data-order="asc" onclick="sortByField('sales', 'asc')">▼</span>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
150
151
|
</span>
</button>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
152
153
154
|
<div class="sort-right">
<select id="resultSize" onchange="performSearch()">
|
9f96d6f3
tangwang
短query不用语义搜索
|
155
156
|
<option value="20">20 per page</option>
<option value="50" selected>50 per page</option>
|
e7ad2b4a
tangwang
测试页面分页配置
|
157
158
|
<option value="100">100 per page</option>
<option value="200">200 per page</option>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
159
160
161
162
163
|
</select>
</div>
</div>
<!-- Loading -->
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
164
165
|
<div id="loading" class="loading" style="display: none;">
<div class="spinner"></div>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
166
|
<p>Loading...</p>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
167
168
|
</div>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
169
170
|
<!-- Product Grid -->
<div class="product-grid" id="productGrid"></div>
|
c86c8237
tangwang
支持聚合。过滤项补充了逻辑,但是有问题
|
171
|
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
172
173
|
<!-- Pagination -->
<div class="pagination" id="pagination" style="display: none;"></div>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
174
|
|
1f071951
tangwang
补充调试信息,记录包括各个阶段的 ...
|
175
|
<!-- Debug Info -->
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
176
|
<details class="debug-info">
|
1f071951
tangwang
补充调试信息,记录包括各个阶段的 ...
|
177
178
|
<summary>调试信息</summary>
<div id="debugInfo"></div>
|
a7a8c6cb
tangwang
测试过滤、聚合、排序
|
179
|
</details>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
180
181
182
|
</div>
<footer>
|
362d43b6
tangwang
店匠体系数据的搜索
|
183
|
<p>SearchEngine © 2025 | API: <span id="apiUrl">Loading...</span></p>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
184
185
|
</footer>
|
a2fd1661
tangwang
前端支持sugg,对接到另外单独的...
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
|
<script src="/static/js/app.js?v=3.2"></script>
<script>
// 自动补全功能
const SUGGEST_API = 'http://120.76.41.98:5003/suggest';
let debounceTimer = null;
let currentSuggestions = [];
let selectedIndex = -1;
let abortController = null;
// 防抖函数
function debounce(func, wait) {
return function(...args) {
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => func.apply(this, args), wait);
};
}
// 获取建议
async function fetchSuggestions(query) {
if (!query || query.trim().length === 0) {
hideSuggestions();
return;
}
// 取消之前的请求
if (abortController) {
abortController.abort();
}
abortController = new AbortController();
try {
const url = new URL(SUGGEST_API);
url.searchParams.set('query', query);
url.searchParams.set('lang', 'zh');
url.searchParams.set('limit', '40');
const response = await fetch(url.toString(), {
signal: abortController.signal,
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
'Referer': window.location.origin + '/'
}
});
if (!response.ok) {
throw new Error('请求失败');
}
const data = await response.json();
if (data.status === 'success' && data.suggestions) {
currentSuggestions = data.suggestions;
showSuggestions(data.suggestions);
} else {
hideSuggestions();
}
} catch (error) {
if (error.name !== 'AbortError') {
console.error('获取建议失败:', error);
hideSuggestions();
}
}
}
// 显示建议列表
function showSuggestions(suggestions) {
const list = document.getElementById('suggestionsList');
if (!suggestions || suggestions.length === 0) {
hideSuggestions();
return;
}
list.innerHTML = '';
suggestions.forEach((item, index) => {
const div = document.createElement('div');
div.className = 'suggestion-item';
div.dataset.index = index;
div.innerHTML = `
<div class="suggestion-text">${escapeHtml(item.canon)}</div>
<div class="suggestion-meta">${item.entry_type} | 频次: ${item.canon_freq}</div>
`;
div.onclick = () => selectSuggestion(item.canon);
div.onmouseenter = () => {
selectedIndex = index;
updateHighlight();
};
list.appendChild(div);
});
list.style.display = 'block';
selectedIndex = -1;
}
// 隐藏建议列表
function hideSuggestions() {
const list = document.getElementById('suggestionsList');
list.style.display = 'none';
currentSuggestions = [];
selectedIndex = -1;
}
// 选择建议
function selectSuggestion(text) {
const input = document.getElementById('searchInput');
input.value = text;
hideSuggestions();
performSearch();
}
// 更新高亮
function updateHighlight() {
const items = document.querySelectorAll('.suggestion-item');
items.forEach((item, index) => {
if (index === selectedIndex) {
item.classList.add('highlighted');
} else {
item.classList.remove('highlighted');
}
});
}
// HTML转义
function escapeHtml(text) {
const div = document.createElement('div');
div.textContent = text;
return div.innerHTML;
}
// 处理输入事件
const debouncedFetch = debounce(fetchSuggestions, 300);
function handleSearchInput(event) {
const query = event.target.value;
debouncedFetch(query);
}
// 键盘导航
document.addEventListener('keydown', (e) => {
const list = document.getElementById('suggestionsList');
if (list.style.display === 'none' || currentSuggestions.length === 0) {
return;
}
if (e.key === 'ArrowDown') {
e.preventDefault();
selectedIndex = (selectedIndex + 1) % currentSuggestions.length;
updateHighlight();
} else if (e.key === 'ArrowUp') {
e.preventDefault();
selectedIndex = selectedIndex <= 0 ? currentSuggestions.length - 1 : selectedIndex - 1;
updateHighlight();
} else if (e.key === 'Enter' && selectedIndex >= 0) {
e.preventDefault();
selectSuggestion(currentSuggestions[selectedIndex].canon);
} else if (e.key === 'Escape') {
hideSuggestions();
}
});
// 点击外部关闭建议列表
document.addEventListener('click', (e) => {
const list = document.getElementById('suggestionsList');
const input = document.getElementById('searchInput');
if (!list.contains(e.target) && e.target !== input) {
hideSuggestions();
}
});
</script>
|
115047ee
tangwang
为一个租户灌入测试数据;实例的启动...
|
352
353
|
</body>
</html>
|