From c3ed17164dfaac9d55ab77d97c51b55d3730f7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=8B=E4=BA=91?= Date: Mon, 28 Apr 2025 22:55:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=85=88=E4=BD=BF=E7=94=A8=E5=86=85?= =?UTF-8?q?=E7=BD=AE=E7=89=88=E6=9C=AC=E5=8F=B7=E8=80=8C=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/build.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/build/build.js b/build/build.js index ec8a14ac..05b363af 100644 --- a/build/build.js +++ b/build/build.js @@ -41,14 +41,17 @@ function extractInfoFromCombatFile(filePath) { const content = fs.readFileSync(filePath, 'utf8'); const authorMatch = content.match(/\/\/\s*作者\s*:(.*)/); const descriptionMatch = content.match(/\/\/\s*描述\s*:(.*)/); + const versionMatch = content.match(/\/\/\s*版本\s*:(.*)/); const characterMatches = content.match(/^(?!\/\/).*?(\S+)(?=\s|$)/gm); const tags = [...new Set(characterMatches || [])] .map(char => char.trim()) .filter(char => char.length > 0 && !char.match(/^[,.]$/)); // 过滤掉单个逗号或句号 - const gitTimestamp = getGitTimestamp(filePath); - const version = gitTimestamp ? formatTime(gitTimestamp) : calculateSHA1(filePath).substring(0, 7); + // 优先使用文件中的版本号,其次使用提交时间,最后使用 SHA + const version = versionMatch ? versionMatch[1].trim() : + (getGitTimestamp(filePath) ? formatTime(getGitTimestamp(filePath)) : + calculateSHA1(filePath).substring(0, 7)); return { author: authorMatch ? authorMatch[1].trim() : '', @@ -97,9 +100,10 @@ function extractInfoFromPathingFile(filePath, parentFolders) { const contentObj = JSON.parse(content); - // 优先使用 Git 提交时间作为版本号 - const gitTimestamp = getGitTimestamp(filePath); - const version = gitTimestamp ? formatTime(gitTimestamp) : (contentObj.info?.version || calculateSHA1(filePath).substring(0, 7)); + // 优先使用文件中的版本号,其次使用提交时间,最后使用 SHA + const version = contentObj.info?.version || + (getGitTimestamp(filePath) ? formatTime(getGitTimestamp(filePath)) : + calculateSHA1(filePath).substring(0, 7)); let tags = parentFolders.slice(2) .filter(tag => !tag.includes('@')) @@ -127,6 +131,7 @@ function extractInfoFromTCGFile(filePath, parentFolder) { const content = fs.readFileSync(filePath, 'utf8'); const authorMatch = content.match(/\/\/\s*作者:(.*)/); const descriptionMatch = content.match(/\/\/\s*描述:(.*)/); + const versionMatch = content.match(/\/\/\s*版本:(.*)/); const characterMatches = content.match(/角色\d+\s?=([^|\r\n{]+)/g); let tags = characterMatches @@ -141,8 +146,10 @@ function extractInfoFromTCGFile(filePath, parentFolder) { tags = ['酒馆挑战', ...tags]; } - const gitTimestamp = getGitTimestamp(filePath); - const version = gitTimestamp ? formatTime(gitTimestamp) : calculateSHA1(filePath).substring(0, 7); + // 优先使用文件中的版本号,其次使用提交时间,最后使用 SHA + const version = versionMatch ? versionMatch[1].trim() : + (getGitTimestamp(filePath) ? formatTime(getGitTimestamp(filePath)) : + calculateSHA1(filePath).substring(0, 7)); return { author: authorMatch ? authorMatch[1].trim() : '',