UPDATE: Add showcase card
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 1m45s
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 1m45s
This commit is contained in:
@@ -6,7 +6,7 @@ import { getCharacterInfoApi } from '../api';
|
||||
const DATA_DIR = path.join(process.cwd(), 'data');
|
||||
const characterFileCache: Record<string, Record<string, CharacterDetail>> = {};
|
||||
export let characterMap: Record<string, CharacterDetail> = {};
|
||||
|
||||
export let rankIconMap: Record<string, string[]> = {};
|
||||
function getJsonFilePath(locale: string): string {
|
||||
return path.join(DATA_DIR, `characters.${locale}.json`);
|
||||
}
|
||||
@@ -15,11 +15,20 @@ function loadFromFileIfExists(locale: string): Record<string, CharacterDetail> |
|
||||
if (characterFileCache[locale]) return characterFileCache[locale];
|
||||
|
||||
const filePath = getJsonFilePath(locale);
|
||||
const fileRankIconPath = path.join(DATA_DIR, `rank_icon.json`);
|
||||
if (fs.existsSync(fileRankIconPath)) {
|
||||
const data = JSON.parse(fs.readFileSync(fileRankIconPath, 'utf-8')) as Record<string, string[]>;
|
||||
rankIconMap = data;
|
||||
}
|
||||
if (fs.existsSync(filePath)) {
|
||||
const data = JSON.parse(fs.readFileSync(filePath, 'utf-8')) as Record<string, CharacterDetail>;
|
||||
Object.keys(data).forEach((key) => {
|
||||
data[key].RankIcon = rankIconMap[key] || [];
|
||||
});
|
||||
characterFileCache[locale] = data;
|
||||
return data;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -37,7 +46,10 @@ export async function loadCharacters(charIds: string[], locale: string): Promise
|
||||
await Promise.all(
|
||||
charIds.map(async id => {
|
||||
const info = await getCharacterInfoApi(Number(id), locale);
|
||||
if (info) result[id] = info;
|
||||
if (info){
|
||||
info.RankIcon = rankIconMap[id] || [];
|
||||
result[id] = info;
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { LightConeDetail } from '@/types';
|
||||
const DATA_DIR = path.join(process.cwd(), 'data');
|
||||
const lightconeFileCache: Record<string, Record<string, LightConeDetail>> = {};
|
||||
export let lightconeMap: Record<string, LightConeDetail> = {};
|
||||
export let lightconeBonusMap: Record<string, Record<string, { type: string, value: number }[]>> = {};
|
||||
|
||||
function getJsonFilePath(locale: string): string {
|
||||
return path.join(DATA_DIR, `lightcones.${locale}.json`);
|
||||
@@ -15,9 +16,18 @@ function loadLightconeFromFileIfExists(locale: string): Record<string, LightCone
|
||||
if (lightconeFileCache[locale]) return lightconeFileCache[locale];
|
||||
|
||||
const filePath = getJsonFilePath(locale);
|
||||
const fileBonusPath = path.join(DATA_DIR, `lightcone_bonus.json`);
|
||||
if (fs.existsSync(fileBonusPath)) {
|
||||
const data = JSON.parse(fs.readFileSync(fileBonusPath, 'utf-8')) as Record<string, Record<string, { type: string, value: number }[]>>;
|
||||
lightconeBonusMap = data;
|
||||
}
|
||||
if (fs.existsSync(filePath)) {
|
||||
const data = JSON.parse(fs.readFileSync(filePath, 'utf-8')) as Record<string, LightConeDetail>;
|
||||
Object.keys(data).forEach((key) => {
|
||||
data[key].Bonus = lightconeBonusMap[key] || {};
|
||||
});
|
||||
lightconeFileCache[locale] = data;
|
||||
|
||||
return data;
|
||||
}
|
||||
return null;
|
||||
@@ -37,7 +47,10 @@ export async function loadLightcones(charIds: string[], locale: string): Promise
|
||||
await Promise.all(
|
||||
charIds.map(async id => {
|
||||
const info = await getLightconeInfoApi(Number(id), locale);
|
||||
if (info) result[id] = info;
|
||||
if (info) {
|
||||
info.Bonus = lightconeBonusMap[id] || {};
|
||||
result[id] = info;
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { getRelicInfoApi } from '../api';
|
||||
const DATA_DIR = path.join(process.cwd(), 'data');
|
||||
const relicFileCache: Record<string, Record<string, RelicDetail>> = {};
|
||||
export let relicMap: Record<string, RelicDetail> = {};
|
||||
|
||||
export let relicBonusMap: Record<string, Record<string, { type: string, value: number }[]>> = {};
|
||||
function getJsonFilePath(locale: string): string {
|
||||
return path.join(DATA_DIR, `relics.${locale}.json`);
|
||||
}
|
||||
@@ -15,8 +15,16 @@ function loadRelicFromFileIfExists(locale: string): Record<string, RelicDetail>
|
||||
if (relicFileCache[locale]) return relicFileCache[locale];
|
||||
|
||||
const filePath = getJsonFilePath(locale);
|
||||
const fileBonusPath = path.join(DATA_DIR, `relic_bonus.json`);
|
||||
if (fs.existsSync(fileBonusPath)) {
|
||||
const data = JSON.parse(fs.readFileSync(fileBonusPath, 'utf-8')) as Record<string, Record<string, { type: string, value: number }[]>>;
|
||||
relicBonusMap = data;
|
||||
}
|
||||
if (fs.existsSync(filePath)) {
|
||||
const data = JSON.parse(fs.readFileSync(filePath, 'utf-8')) as Record<string, RelicDetail>;
|
||||
Object.keys(data).forEach((key) => {
|
||||
data[key].Bonus = relicBonusMap[key] || {};
|
||||
});
|
||||
relicFileCache[locale] = data;
|
||||
return data;
|
||||
}
|
||||
@@ -37,7 +45,10 @@ export async function loadRelics(charIds: string[], locale: string): Promise<Rec
|
||||
await Promise.all(
|
||||
charIds.map(async id => {
|
||||
const info = await getRelicInfoApi(Number(id), locale);
|
||||
if (info) result[id] = info;
|
||||
if (info) {
|
||||
info.Bonus = relicBonusMap[id] || {};
|
||||
result[id] = info;
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user