update
This commit is contained in:
@@ -271,6 +271,51 @@ function updateAlbumInfo() {
|
||||
document.title = `${currentAlbum.title} - 图片展示服务`;
|
||||
}
|
||||
|
||||
// 标签分类映射(与后端 tag_extractor.rs 保持一致)
|
||||
const TAG_CATEGORIES = {
|
||||
style: ['日系', '韩系', '森系', '复古', '甜美', '性感', '清新', '冷艳',
|
||||
'优雅', '知性', '可爱', '俏皮', '温柔', '妩媚', '野性', '清纯',
|
||||
'时尚', '潮流', '街头', '学院', '文艺', '古典', '民族', '异域',
|
||||
'japanese', 'korean', 'retro', 'vintage', 'cute', 'sexy',
|
||||
'elegant', 'fresh', 'sweet', 'wild', 'pure', 'fashion'],
|
||||
outfit: ['比基尼', '泳装', '泳衣', '旗袍', '制服', '丝袜', '内衣', '文胸',
|
||||
'包臀裙', '紧身裙', '超短裙', '连衣裙', '半身裙', '短裙', '长裙',
|
||||
'牛仔裤', '热裤', '短裤', '休闲裤', '西装裤',
|
||||
'T恤', '衬衫', '毛衣', '针织衫', '外套', '风衣', '大衣', '西装',
|
||||
'吊带', '抹胸', '露背', '透视', '蕾丝', '镂空', '开叉',
|
||||
'高跟鞋', '运动鞋', '凉鞋', '拖鞋', '靴子',
|
||||
'bikini', 'swimsuit', 'stockings', 'lingerie', 'dress',
|
||||
'skirt', 'jeans', 'shirt', 'sweater', 'coat', 'heels'],
|
||||
scene: ['室内', '户外', '街拍', '浴室', '浴缸', '床上', '床照', '沙发',
|
||||
'厨房', '阳台', '窗边', '楼梯', '走廊', '电梯', '车内', '驾驶座',
|
||||
'海边', '沙滩', '泳池', '温泉', '森林', '草地', '花园', '公园',
|
||||
'街道', '巷弄', '建筑', '天台', '屋顶', '咖啡馆', '餐厅', '酒店',
|
||||
'indoor', 'outdoor', 'street', 'beach', 'pool', 'bathroom',
|
||||
'bedroom', 'kitchen', 'balcony', 'car', 'cafe', 'hotel'],
|
||||
body: ['美腿', '美胸', '翘臀', '玉足', '美背', '香肩', '蛮腰', '细腰',
|
||||
'长腿', '酥胸', '丰臀', '白皙', '肌肤', '纹身',
|
||||
'legs', 'breasts', 'ass', 'feet', 'back', 'shoulders', 'waist',
|
||||
'skin', 'tattoo'],
|
||||
mood: ['清纯', '诱惑', '唯美', '清新', '冷艳', '妩媚', '娇羞', '俏皮',
|
||||
'温柔', '野性', '冷傲', '热情', '慵懒', '迷离', '甜美', '知性',
|
||||
'pure', 'seductive', 'beautiful', 'fresh', 'cool', 'charming',
|
||||
'shy', 'cute', 'gentle', 'wild', 'lazy', 'sweet'],
|
||||
topic: ['写真', '私房', '街拍', '旅拍', '婚纱照', '艺术照', '生活照',
|
||||
'自拍', '跟拍', '约拍', '商拍',
|
||||
'photoshoot', 'portrait', 'selfie', 'travel', 'wedding'],
|
||||
};
|
||||
|
||||
// 获取标签的分类
|
||||
function getTagCategory(tag) {
|
||||
const tagLower = tag.toLowerCase();
|
||||
for (const [category, tags] of Object.entries(TAG_CATEGORIES)) {
|
||||
if (tags.some(t => t.toLowerCase() === tagLower)) {
|
||||
return category;
|
||||
}
|
||||
}
|
||||
return 'default';
|
||||
}
|
||||
|
||||
// 更新相册元数据(人名 + 标签)点击可搜索
|
||||
function updateAlbumMeta() {
|
||||
const metaContainer = document.getElementById('album-meta-tags');
|
||||
@@ -283,36 +328,46 @@ function updateAlbumMeta() {
|
||||
chips.push({
|
||||
text: currentAlbum.person_name_cleaned,
|
||||
type: 'person',
|
||||
category: 'person',
|
||||
query: currentAlbum.person_name_cleaned
|
||||
});
|
||||
}
|
||||
|
||||
// 添加标签
|
||||
// 添加标签(支持多种格式)
|
||||
if (currentAlbum.tags) {
|
||||
let tagList = [];
|
||||
try {
|
||||
const tags = JSON.parse(currentAlbum.tags);
|
||||
if (Array.isArray(tags)) {
|
||||
tags.forEach(tag => {
|
||||
chips.push({
|
||||
text: tag,
|
||||
type: 'tag',
|
||||
query: tag
|
||||
});
|
||||
// 格式1: JSON数组 [["标签名", "分类"], ...]
|
||||
const parsed = JSON.parse(currentAlbum.tags);
|
||||
if (Array.isArray(parsed)) {
|
||||
parsed.forEach(item => {
|
||||
if (Array.isArray(item)) {
|
||||
tagList.push({ text: item[0], category: item[1] || 'default' });
|
||||
} else if (typeof item === 'string') {
|
||||
tagList.push({ text: item, category: getTagCategory(item) });
|
||||
} else if (item.tag || item.name) {
|
||||
const t = item.tag || item.name;
|
||||
const c = item.category || item.type || getTagCategory(t);
|
||||
tagList.push({ text: t, category: c });
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
// 非JSON格式,当作逗号分隔
|
||||
// 格式2: 逗号分隔字符串
|
||||
currentAlbum.tags.split(',').forEach(tag => {
|
||||
const t = tag.trim();
|
||||
if (t) {
|
||||
chips.push({
|
||||
text: t,
|
||||
type: 'tag',
|
||||
query: t
|
||||
});
|
||||
}
|
||||
if (t) tagList.push({ text: t, category: getTagCategory(t) });
|
||||
});
|
||||
}
|
||||
|
||||
tagList.forEach(t => {
|
||||
chips.push({
|
||||
text: t.text,
|
||||
type: 'tag',
|
||||
category: t.category,
|
||||
query: t.text
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
if (chips.length === 0) {
|
||||
@@ -323,7 +378,9 @@ function updateAlbumMeta() {
|
||||
metaContainer.style.display = 'flex';
|
||||
metaContainer.innerHTML = chips.map(chip => {
|
||||
const icon = chip.type === 'person' ? 'fa-user' : 'fa-tag';
|
||||
return `<span class="meta-chip meta-chip-${chip.type}" data-meta-type="${chip.type}" data-meta-query="${encodeURIComponent(chip.query)}">
|
||||
// 生成 CSS 类名:人物用 person,标签用 tag-{category}
|
||||
const cssClass = chip.type === 'person' ? 'meta-chip-person' : `meta-chip-tag-${chip.category || 'default'}`;
|
||||
return `<span class="meta-chip ${cssClass}" data-meta-type="${chip.type}" data-meta-query="${encodeURIComponent(chip.query)}">
|
||||
<i class="fas ${icon}"></i> ${chip.text}
|
||||
</span>`;
|
||||
}).join('');
|
||||
|
||||
Reference in New Issue
Block a user