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

View File

@@ -2,11 +2,12 @@
"manifest_version": 1, "manifest_version": 1,
"name": "稻妻合成台", "name": "稻妻合成台",
"version": "1.0", "version": "1.0",
"description": "去稻妻合成台那位莱特不行,他冲刺比其他成男角色远成男角色冲刺右键8下A左走5秒跳跃找交互停顿", "description": "去稻妻合成台 那位莱特不行他冲刺比其他成男角色远成男角色冲刺右键8下A左走5秒跳跃找交互停顿",
"authors": [ "authors": [
{ {
"name": "fengbu", "name": "fengbu"
} }
], ],
"tags": ["稻妻", "合成台"],
"main": "main.js" "main": "main.js"
} }

View File

@@ -5,7 +5,8 @@
"author": "Tool_tingsu", "author": "Tool_tingsu",
"version": "1.0", "version": "1.0",
"description": "", "description": "",
"bgiVersion": "0.42.3" "bgiVersion": "0.42.3",
"tags": [ "胡桃"]
}, },
"positions": [ "positions": [
{ {