diff --git a/apps/directory/src/routes/path/Home.jsx b/apps/directory/src/routes/path/Home.jsx
index c51d2d8..f4f8dfb 100644
--- a/apps/directory/src/routes/path/Home.jsx
+++ b/apps/directory/src/routes/path/Home.jsx
@@ -21,7 +21,7 @@ const voiceOnAtom = atomWithStorage('voiceOn', false)
let lastVoiceState = 'ended'
export default function Home() {
- // eslint-disable-next-line no-unused-vars
+ // eslint-disable-next-line
const _trackEvt = useInsight()
const { setTitle, setTabs, currentTab, setHeaderIcon, setFastNavigation } =
useHeader()
@@ -190,15 +190,14 @@ export default function Home() {
- {officialUpdate.dates
- .reduce((acc, cur) => {
- const op = officialUpdate.info[cur]
- return [...acc, ...op]
- }, [])
- .slice(
- 0,
- officialUpdate.length -
- operators.length
+ {officialUpdate.info
+ .filter(
+ (e) =>
+ !operators.find(
+ (o) =>
+ o.official_id ===
+ e.id.toString()
+ )
)
.map((entry, index) => {
return (
@@ -251,12 +250,21 @@ export default function Home() {
classes.title
}
>
- {
- entry
- .codename[
- language
- ]
- }
+ {language ===
+ 'zh-CN'
+ ? entry.type ===
+ 'skin'
+ ? `${
+ entry
+ .skinName[
+ 'zh-CN'
+ ]
+ } · ${entry.operatorName}`
+ : entry.operatorName
+ : entry
+ .skinName[
+ 'en-US'
+ ]}
{
if (!data) throw new Error('No data found')
const rows = (data as OfficialArray)[0][3].initialData
- const dict: OfficialInfo = {
+ const dict: OfficialInfoV2 = {
length: rows.length,
dates: [],
- info: {},
+ info: [],
}
let current_displayTime = rows[0].displayTime
- let current_block = []
for (const row of rows) {
const displayTime = row.displayTime
if (displayTime !== current_displayTime) {
- dict.info[current_displayTime] = current_block
dict.dates.push(current_displayTime)
current_displayTime = row.displayTime
- current_block = []
}
- current_block.push(get_row(row))
+ dict.info.push(get_row(row, current_displayTime))
}
- dict.info[current_displayTime] = current_block
dict.dates.push(current_displayTime)
file.writeSync(JSON.stringify(dict, null, 4), OFFICIAL_INFO_JSON)
}
-const get_row = (row: OfficialOperatorInfo): OfficialInfoOperatorConfig => {
+const get_row = (
+ row: OfficialOperatorInfo,
+ date: string
+): OfficialInfoOperatorConfigV2 => {
const type = row.type
- let codename_zhCN, item_type: 'operator' | 'skin'
+ let item_type: 'operator' | 'skin'
switch (type) {
case 0:
- codename_zhCN = row.charName
item_type = 'operator'
break
case 1:
- codename_zhCN = row.suitName + ' · ' + row.charName
item_type = 'skin'
break
default:
throw 'unknown type'
}
return {
- codename: {
- 'zh-CN': codename_zhCN,
+ operatorName: row.charName,
+ skinName: {
+ 'zh-CN': row.suitName,
'en-US': row.codename,
},
type: item_type,
link: `https://ak.hypergryph.com/archive/dynamicCompile/${row.cid}.html`,
- id: row.cid,
+ id: Number(row.cid),
+ date,
}
}
const generateMapping = () => {
const mapping: OfficialInfoMapping = {}
- const content = file.readSync(OFFICIAL_INFO_JSON)
+ const content = file.readSync(OFFICIAL_INFO_JSON) as string
if (!content) throw new Error('Failed to read official info JSON')
- const data: OfficialInfo = JSON.parse(content)
+ const data: OfficialInfoV2 = JSON.parse(content)
if (!data) throw new Error('Failed to parse official info JSON')
- Object.keys(data.info).forEach((date) => {
- data.info[date].forEach((operator) => {
- mapping[operator.id] = {
- date,
- ...operator,
- }
- })
+ data.info.forEach((e) => {
+ mapping[e.id] = e
})
return mapping
}
diff --git a/packages/official-info/types.ts b/packages/official-info/types.ts
index 000c394..0429f5f 100644
--- a/packages/official-info/types.ts
+++ b/packages/official-info/types.ts
@@ -21,30 +21,8 @@ type UnrelatedDataArray = ['$', string, null, unknown]
export type OfficialArray = [OfficialDataArray, UnrelatedDataArray]
-export type OfficialInfo = {
- length: number
- dates: string[]
- info: {
- [date: string]: OfficialInfoOperatorConfig[]
- }
-}
-
-export interface OfficialInfoOperatorConfig {
- codename: {
- 'zh-CN': string
- 'en-US': string
- }
- type: 'operator' | 'skin'
- link: string
- id: string
-}
-
-export interface OperatorConfig extends OfficialInfoOperatorConfig {
- date: string
-}
-
export type OfficialInfoMapping = {
- [id: string]: OperatorConfig
+ [id: string]: OfficialInfoOperatorConfigV2
}
export type OfficialInfoV2 = {
diff --git a/packages/operator/index.ts b/packages/operator/index.ts
index faa37b9..e775b2d 100644
--- a/packages/operator/index.ts
+++ b/packages/operator/index.ts
@@ -145,8 +145,8 @@ const generateMapping = () => {
const type = operatorInfo.type
const name =
type === 'skin'
- ? operatorInfo.codename['zh-CN'].split(' · ')[0]
- : operatorInfo.codename['en-US']
+ ? operatorInfo.skinName['zh-CN']
+ : operatorInfo.skinName['en-US']
const skinEntry = findSkinEntry(skinTable, name, type)
operator.filename = skinEntry.dynIllustId.replace(/_2$/, '')
operator.fallback_name =
diff --git a/packages/operator/libs/initer.ts b/packages/operator/libs/initer.ts
index 4568e7b..9898dc0 100644
--- a/packages/operator/libs/initer.ts
+++ b/packages/operator/libs/initer.ts
@@ -31,8 +31,8 @@ export const init = (name: string, id: string) => {
try {
const entryName =
currentOpertor.type === 'skin'
- ? currentOpertor.codename['zh-CN'].split(' · ')[0]
- : currentOpertor.codename['en-US']
+ ? currentOpertor.skinName['zh-CN']
+ : currentOpertor.skinName['en-US']
const skinEntry = findSkinEntry(
skinTable,
entryName,
@@ -41,7 +41,16 @@ export const init = (name: string, id: string) => {
template.codename = findCodename(skinEntry, currentOpertor)
} catch (e: unknown) {
console.log(e as string)
- template.codename = currentOpertor.codename
+ template.codename =
+ currentOpertor.type === 'skin'
+ ? {
+ 'zh-CN': `${currentOpertor.skinName['zh-CN']} · ${currentOpertor.operatorName}`,
+ 'en-US': `${currentOpertor.skinName['en-US']} / ${currentOpertor.operatorName}`,
+ }
+ : {
+ 'zh-CN': `${currentOpertor.operatorName}`,
+ 'en-US': `${currentOpertor.skinName['en-US']}`,
+ }
}
file.writeSync(
diff --git a/packages/operator/libs/utils.ts b/packages/operator/libs/utils.ts
index 1863a10..9351af9 100644
--- a/packages/operator/libs/utils.ts
+++ b/packages/operator/libs/utils.ts
@@ -10,7 +10,7 @@ import {
SkinTableJsonCharSkinEntry,
Codename,
} from '../types.ts'
-import type { OfficialInfoOperatorConfig } from '@aklive2d/official-info/types'
+import type { OfficialInfoOperatorConfigV2 } from '@aklive2d/official-info/types'
export const getExtractedFolder = (name: string) => {
return path.join(OPERATOR_SOURCE_FOLDER, name, config.dir_name.extracted)
@@ -111,7 +111,7 @@ export const findSkinEntry = (
*/
export const findCodename = (
skinEntry: SkinTableJsonCharSkinEntry,
- officialInfo: OfficialInfoOperatorConfig
+ officialInfo: OfficialInfoOperatorConfigV2
) => {
const UPPER_CASE_EXCEPTION_WORDS = [
'the',
@@ -144,7 +144,7 @@ export const findCodename = (
modelNameNormalized = modelNameNormalizedArray.join(' ')
}
if (skinEntry.displaySkin.skinName) {
- let engSkinName = officialInfo.codename['en-US']
+ let engSkinName = officialInfo.skinName['en-US']
const engkinNameArray = engSkinName.split(' ')
engkinNameArray.forEach((word, index) => {
if (/^[a-zA-Z]+$/.test(word)) {
@@ -158,10 +158,11 @@ export const findCodename = (
}
})
engSkinName = engkinNameArray.join(' ')
- codename['zh-CN'] = officialInfo.codename['zh-CN'].replace(/ +$/, '')
+ codename['zh-CN'] =
+ `${officialInfo.skinName['zh-CN']} · ${officialInfo.operatorName}`
codename['en-US'] = `${engSkinName} / ${modelNameNormalized}`
} else {
- codename['zh-CN'] = officialInfo.codename['zh-CN'].replace(/ +$/, '')
+ codename['zh-CN'] = officialInfo.operatorName
codename['en-US'] = modelNameNormalized
}
return codename