905086
2026-11-09 cbb26873e88a7a13e868448c1cc578ce70b8c6ae
1
2
3
4
5
6
7
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
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
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>游戏目录 · 游趣电玩</title>
<style>
  * { margin: 0; padding: 0; box-sizing: border-box; }
  html, body { height: 100%; }
  body {
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, "Segoe UI", Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #fff;
    color: #000;
    overflow: hidden;
  }
  img { display: block; }
 
  .page {
    height: 100vh;
    padding: 4px;
    display: flex;
    flex-direction: column;
    background: #fff;
  }
 
  /* 顶部搜索 */
  .search {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 9px 11px;
    border-bottom: 1px solid #f3f4f6;
  }
  .search-box {
    flex: 1;
    display: flex;
    align-items: center;
    height: 31px;
    padding: 0 11px;
    background: #f7f8fa;
    border-radius: 2px;
    min-width: 0;
  }
  .search-icon { width: 16px; height: 16px; flex-shrink: 0; margin-right: 8px; }
  .search-icon svg { width: 100%; height: 100%; display: block; }
  #kw {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font-size: 13px;
    color: #323233;
    font-family: inherit;
  }
  #kw::placeholder { color: #969799; }
  .clear-btn {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-left: 6px;
    border: 0;
    padding: 0;
    background: transparent;
    cursor: pointer;
    display: none;
  }
  .clear-btn.show { display: block; }
  .clear-btn svg { width: 100%; height: 100%; display: block; }
 
  /* 游戏列表 */
  .list { flex: 1; overflow-y: auto; }
  .row {
    display: flex;
    padding: 8px;
    border-bottom: 1px solid #f8f8f8;
  }
  .cover {
    width: 124px;
    height: 73px;
    flex-shrink: 0;
    border-radius: 4px;
    background: #f5f5f5;
    overflow: hidden;
  }
  .cover img { width: 100%; height: 100%; object-fit: cover; }
  .meta {
    flex: 1;
    min-width: 0;
    padding-left: 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }
  .name {
    font-size: 16px;
    line-height: 28px;
    font-weight: 400;
    color: #000;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
  }
  .line { display: flex; align-items: center; min-width: 0; }
  .tags { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; }
  .tag {
    display: inline-flex;
    align-items: center;
    height: 15px;
    padding: 0 4px;
    margin-right: 4px;
    background: #ff0000;
    color: #fff;
    font-size: 11px;
    line-height: 15px;
    border-radius: 2px;
    vertical-align: middle;
  }
  .size {
    flex-shrink: 0;
    margin-left: 8px;
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
  }
 
  /* 状态 */
  .footer, .loading, .empty { text-align: center; color: #969799; }
  .footer { font-size: 14px; padding: 14px 0; }
  .loading { padding: 24px 0 14px; }
  .loading .spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ebedf0;
    border-top-color: #c8c9cc;
    border-radius: 50%;
    animation: spin .8s linear infinite;
  }
  @keyframes spin { to { transform: rotate(360deg); } }
  .empty { padding: 90px 0; font-size: 14px; }
  .empty svg { width: 100px; height: 100px; margin: 0 auto 12px; display: block; }
  .empty .desc { line-height: 20px; }
 
  /* 右下角重置气泡 */
  .bubble {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
    border: 0;
    padding: 0;
    border-radius: 50%;
    background: #ff0000;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .18);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 20;
  }
  .bubble.show { display: flex; }
  .bubble svg { width: 20px; height: 20px; display: block; }
</style>
</head>
<body>
 
<div class="page">
  <div class="search">
    <div class="search-box">
      <span class="search-icon">
        <svg viewBox="0 0 1024 1024" fill="#969799"><path d="M459.094 786.667c-180.107 0-326.667-146.56-326.667-326.667S278.987 133.333 459.094 133.333 785.761 279.893 785.761 460s-146.56 326.667-326.667 326.667z m0-57.6c148.587 0 269.067-120.48 269.067-269.067S607.681 190.933 459.094 190.933 190.027 311.413 190.027 460s120.48 269.067 269.067 269.067z"></path><path d="M665.579 601.259a28.8 28.8 0 0 1 40.704 40.704l-71.723 71.723a28.8 28.8 0 1 1-40.704-40.704l71.723-71.723z"></path><path d="M662.486 662.486a28.8 28.8 0 0 1 40.704 0l133.76 133.76a28.8 28.8 0 0 1-40.704 40.704L662.486 703.19a28.8 28.8 0 0 1 0-40.704z"></path></svg>
      </span>
      <input id="kw" type="text" placeholder="请输入搜索关键词" autocomplete="off">
      <button class="clear-btn" id="clearBtn" type="button" aria-label="清空">
        <svg viewBox="0 0 1024 1024" fill="#c8c9cc"><path d="M512 85.333c235.648 0 426.667 191.019 426.667 426.667S747.648 938.667 512 938.667 85.333 747.648 85.333 512 276.352 85.333 512 85.333z m149.333 240.213a35.925 35.925 0 0 0-50.773 0L512 424.107 413.397 325.504a35.925 35.925 0 0 0-50.773 50.773L461.227 512 362.624 610.603a35.925 35.925 0 0 0 50.773 50.773L512 562.773l98.603 98.603a35.925 35.925 0 0 0 50.773-50.773L562.773 512l98.603-98.603a35.925 35.925 0 0 0 0-50.773z"></path></svg>
      </button>
    </div>
  </div>
 
  <div class="list" id="list">
    <div class="loading"><span class="spinner"></span></div>
  </div>
</div>
 
<button class="bubble" id="bubble" type="button" aria-label="重置搜索">
  <svg viewBox="0 0 1024 1024" fill="#fff"><path d="M512 85.333c235.648 0 426.667 191.019 426.667 426.667S747.648 938.667 512 938.667 85.333 747.648 85.333 512 276.352 85.333 512 85.333z m149.333 240.213a35.925 35.925 0 0 0-50.773 0L512 424.107 413.397 325.504a35.925 35.925 0 0 0-50.773 50.773L461.227 512 362.624 610.603a35.925 35.925 0 0 0 50.773 50.773L512 562.773l98.603 98.603a35.925 35.925 0 0 0 50.773-50.773L562.773 512l98.603-98.603a35.925 35.925 0 0 0 0-50.773z"></path></svg>
</button>
 
<template id="emptyTpl">
  <div class="empty">
    <svg viewBox="0 0 1024 1024">
      <ellipse cx="512" cy="700" rx="260" ry="34" fill="#f2f3f5"></ellipse>
      <rect x="292" y="238" width="440" height="374" rx="28" fill="#f7f8fa" stroke="#e5e7eb"></rect>
      <circle cx="470" cy="404" r="76" fill="#fff" stroke="#dcdfe6"></circle>
      <path d="M530 464l72 72" stroke="#dcdfe6" stroke-width="18" stroke-linecap="round"></path>
    </svg>
    <div class="desc"></div>
  </div>
</template>
 
<script>
const PAGE_SIZE = 20;
const listEl = document.getElementById('list');
const kwEl = document.getElementById('kw');
const clearBtn = document.getElementById('clearBtn');
const bubble = document.getElementById('bubble');
const emptyTpl = document.getElementById('emptyTpl');
 
let allGames = [];
let shownCount = 0;
let loading = false;
let keyword = '';
 
function esc(s) {
  return String(s == null ? '' : s).replace(/[&<>"']/g, m =>
    ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[m]));
}
 
// 与对标页一致:数值 + 空格 + 单位
function formatSize(v) {
  if (!v) return '';
  const t = String(v).trim();
  const m = t.match(/^([0-9]+(?:\.[0-9]+)?)\s*(TB|GB|MB|KB|B)$/i);
  if (m) return m[1] + ' ' + m[2].toUpperCase();
  return /[a-zA-Z]/.test(t) ? t : t + ' GB';
}
 
function tagList(g) {
  const out = [];
  const push = v => {
    String(v || '').split(/[,,、/\s]+/).map(s => s.trim()).forEach(s => {
      if (s && !out.includes(s)) out.push(s);
    });
  };
  push(g.category_name);
  push(g.tags);
  return out;
}
 
function rowHtml(g) {
  const tags = tagList(g).map(t => `<span class="tag">${esc(t)}</span>`).join('');
  return `<div class="row">
    <div class="cover">${g.cover ? `<img src="${esc(g.cover)}" alt="${esc(g.title)}" loading="lazy" onerror="this.remove()">` : ''}</div>
    <div class="meta">
      <div class="name">${esc(g.title)}</div>
      <div class="line">
        <div class="tags">${tags}</div>
        <div class="size">${esc(formatSize(g.size))}</div>
      </div>
    </div>
  </div>`;
}
 
function showLoading() {
  listEl.innerHTML = '<div class="loading"><span class="spinner"></span></div>';
}
 
function showEmpty(msg) {
  const node = emptyTpl.content.cloneNode(true);
  node.querySelector('.desc').textContent = msg || '暂无数据';
  listEl.innerHTML = '';
  listEl.appendChild(node);
}
 
function appendPage() {
  const next = allGames.slice(shownCount, shownCount + PAGE_SIZE);
  if (!next.length) return;
  const frag = document.createDocumentFragment();
  const wrap = document.createElement('div');
  wrap.innerHTML = next.map(rowHtml).join('');
  while (wrap.firstChild) frag.appendChild(wrap.firstChild);
  const oldFooter = listEl.querySelector('.footer');
  if (oldFooter) oldFooter.remove();
  listEl.appendChild(frag);
  shownCount += next.length;
  if (shownCount >= allGames.length && allGames.length) {
    const footer = document.createElement('div');
    footer.className = 'footer';
    footer.textContent = '没有更多了~';
    listEl.appendChild(footer);
  }
}
 
async function loadGames(kw) {
  if (loading) return;
  loading = true;
  showLoading();
  try {
    const p = new URLSearchParams({ platform: 'all', category: '0', keyword: kw || '', sort: 'updated' });
    const res = await fetch('/api/games?' + p.toString()).then(r => r.json());
    if (res.code !== 0) throw new Error(res.msg || '加载失败');
    allGames = res.data || [];
    shownCount = 0;
    listEl.innerHTML = '';
    if (!allGames.length) showEmpty('暂无数据');
    else appendPage();
  } catch (e) {
    showEmpty(e.message || '加载失败');
  } finally {
    loading = false;
  }
}
 
// 回车 / 点击放大镜触发搜索;清空与右下气泡可重置
function doSearch() {
  keyword = kwEl.value.trim();
  bubble.classList.toggle('show', !!keyword);
  loadGames(keyword);
}
 
function resetSearch() {
  kwEl.value = '';
  keyword = '';
  clearBtn.classList.remove('show');
  bubble.classList.remove('show');
  loadGames('');
}
 
kwEl.addEventListener('input', () => {
  clearBtn.classList.toggle('show', !!kwEl.value);
});
kwEl.addEventListener('keydown', e => {
  if (e.key === 'Enter') doSearch();
});
document.querySelector('.search-icon').addEventListener('click', doSearch);
clearBtn.addEventListener('click', resetSearch);
bubble.addEventListener('click', resetSearch);
 
listEl.addEventListener('scroll', () => {
  if (loading) return;
  const rest = listEl.scrollHeight - listEl.scrollTop - listEl.clientHeight;
  if (rest < 100 && shownCount < allGames.length) appendPage();
});
 
loadGames('');
</script>
</body>
</html>