feat: Refine adult content fuzzy matching logic and enhance UI with direct video links and dedicated loading/empty states.

This commit is contained in:
kuekhaoyang
2025-11-29 23:16:53 +08:00
parent 2d6011abf6
commit 69b60913a4
4 changed files with 66 additions and 78 deletions
+10 -4
View File
@@ -76,17 +76,17 @@ export async function GET() {
return label.replace(/[视频片区专]/g, '');
};
// Helper to check if two labels match fuzzily (>= 2 chars overlap)
// Helper to check if two labels match fuzzily (>= 4 chars overlap)
const isFuzzyMatch = (label1: string, label2: string) => {
const clean1 = cleanLabel(label1);
const clean2 = cleanLabel(label2);
// If either is too short after cleaning, require exact match
if (clean1.length < 2 || clean2.length < 2) {
if (clean1.length < 4 || clean2.length < 4) {
return clean1 === clean2;
}
// Check for 2+ char overlap
// Check for 4+ char overlap
let overlapCount = 0;
const set1 = new Set(clean1.split(''));
for (const char of clean2) {
@@ -94,7 +94,7 @@ export async function GET() {
overlapCount++;
}
}
return overlapCount >= 2;
return overlapCount >= 4;
};
// Process results
@@ -104,6 +104,9 @@ export async function GET() {
categories.forEach((cat: Category) => {
const typeName = cat.type_name.trim();
// Skip empty type names
if (!typeName) return;
const value = `${sourceId}:${cat.type_id}`;
// Try to find a fuzzy match in existing categories
@@ -131,6 +134,9 @@ export async function GET() {
// Convert merged categories to tags
mergedCategories.forEach((cat) => {
// Skip categories with no values (shouldn't happen with current logic but good for safety)
if (cat.values.length === 0) return;
// Create a unique ID based on the label (using base64 to be safe)
const id = Buffer.from(cat.label).toString('base64');