feat: 支持自定义标签

This commit is contained in:
秋云
2025-05-06 03:28:48 +08:00
parent d7cb58f002
commit 2d8f2d3ea6
3 changed files with 15 additions and 4 deletions

View File

@@ -73,7 +73,7 @@ function extractInfoFromJSFolder(folderPath) {
version: manifest.version || '',
description: convertNewlines(combinedDescription),
author: manifest.authors && manifest.authors.length > 0 ? manifest.authors[0].name : '',
tags: []
tags: manifest.tags || []
};
} catch (error) {
console.error(`解析 ${manifestPath} 时出错:`, error);
@@ -105,10 +105,16 @@ function extractInfoFromPathingFile(filePath, parentFolders) {
(getGitTimestamp(filePath) ? formatTime(getGitTimestamp(filePath)) :
calculateSHA1(filePath).substring(0, 7));
// 从父文件夹获取默认标签
let tags = parentFolders.slice(2)
.filter(tag => !tag.includes('@'))
.filter((tag, index, self) => self.indexOf(tag) === index);
// 如果存在自定义标签,与默认标签合并
if (contentObj.info && contentObj.info.tags && Array.isArray(contentObj.info.tags)) {
tags = [...tags, ...contentObj.info.tags];
}
if (contentObj.positions && Array.isArray(contentObj.positions)) {
const actions = contentObj.positions.map(pos => pos.action);
if (actions.includes('nahida_collect')) tags.push('纳西妲');
@@ -119,6 +125,9 @@ function extractInfoFromPathingFile(filePath, parentFolders) {
if (actions.includes('fight')) tags.push('战斗');
}
// 确保标签数组中没有重复项
tags = [...new Set(tags)];
return {
author: contentObj.info.author || '',
description: convertNewlines(contentObj.info.description || ''),