Skip to content

Commit 5c239d5

Browse files
authored
Merge pull request #814 from zanllp/feat/enable-tiktok-view
add toggle to switch between classic and TikTok-style viewers. Enable all past experimental features by default
2 parents fe986cc + 1a4ac9b commit 5c239d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+867
-290
lines changed

javascript/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Promise.resolve().then(async () => {
1313
<link rel="icon" href="/favicon.ico" />
1414
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1515
<title>Infinite Image Browsing</title>
16-
<script type="module" crossorigin src="/infinite_image_browsing/fe-static/assets/index-66b6399d.js"></script>
17-
<link rel="stylesheet" href="/infinite_image_browsing/fe-static/assets/index-15ce0f1b.css">
16+
<script type="module" crossorigin src="/infinite_image_browsing/fe-static/assets/index-411a6464.js"></script>
17+
<link rel="stylesheet" href="/infinite_image_browsing/fe-static/assets/index-8b98f7af.css">
1818
</head>
1919
2020
<body>

scripts/iib/db/datamodel.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,26 @@ def get_random_images(cls, conn: Connection, size: int) -> List["Image"]:
280280

281281
step = max(1, total_count // size)
282282

283-
start_indices = [random.randint(i * step, min((i + 1) * step - 1, total_count - 1)) for i in range(size)]
284-
placeholders = ",".join("?" * len(start_indices))
285-
cur.execute(f"SELECT * FROM image WHERE id IN ({placeholders})", start_indices)
286-
rows = cur.fetchall()
287-
curr_images = [cls.from_row(row) for row in rows if os.path.exists(row[1])]
288-
images.extend(curr_images)
289-
images = unique_by(images, lambda x: x.path)
283+
start_indices = []
284+
for i in range(size):
285+
min_val = i * step
286+
max_val = min((i + 1) * step - 1, total_count - 1)
287+
# 确保 max_val 不小于 min_val
288+
if max_val < min_val:
289+
max_val = min_val
290+
# 确保索引在有效范围内 (1 到 total_count)
291+
min_val = max(1, min(min_val, total_count))
292+
max_val = max(1, min(max_val, total_count))
293+
if min_val <= max_val:
294+
start_indices.append(random.randint(min_val, max_val))
295+
296+
if start_indices:
297+
placeholders = ",".join("?" * len(start_indices))
298+
cur.execute(f"SELECT * FROM image WHERE id IN ({placeholders})", start_indices)
299+
rows = cur.fetchall()
300+
curr_images = [cls.from_row(row) for row in rows if os.path.exists(row[1])]
301+
images.extend(curr_images)
302+
images = unique_by(images, lambda x: x.path)
290303
return images
291304

292305

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)