feat(aklive2d): use offical_update to fetch info

This commit is contained in:
Haoyu Xu
2023-11-01 18:06:21 -04:00
parent b05590764f
commit 013783366b
44 changed files with 176 additions and 209 deletions

View File

@@ -3,22 +3,27 @@ import path from 'path'
import { read } from './yaml.js'
import { getOperatorId } from './charword_table.js'
export default function () {
return process(read(path.join(__projectRoot, 'config.yaml')))
export default function (officalInfo) {
return process(read(path.join(__projectRoot, 'config.yaml')), officalInfo)
}
function process(config) {
function process(config, officalInfo) {
for (const [operatorName, operator] of Object.entries(config.operators)) {
const operatorInfo = officalInfo.find(operator.offical_id)
// add title
operator.title = `${config.share.title["en-US"]}${operator.codename["en-US"]} - ${config.share.title["zh-CN"]}${operator.codename["zh-CN"]}`
// add type
operator.type = operator.codename["zh-CN"].includes('·') ? 'skin' : 'operator'
operator.type = operatorInfo.type
// add link
operator.link = operatorName
// id
operator.id = getOperatorId(operator).replace(/^(char_)(\d+)(_.+)$/g, '$2')
operator.color = operatorInfo.color
operator.date = operatorInfo.date
}
return config