UPDATE: New data 4.1.5
All checks were successful
Gitea Auto Deploy / Deploy-Container (push) Successful in 53s

This commit is contained in:
2026-03-17 18:00:02 +07:00
parent 53497d5ece
commit d4a964515e
10 changed files with 74 additions and 56375 deletions

View File

@@ -24,7 +24,7 @@ export async function checkConnectTcpApi(): Promise<boolean> {
export async function getCharacterListApi(): Promise<CharacterBasic[]> {
try {
const res = await axios.get<CharacterBasic[]>("/data/character.json");
const res = await axios.get<CharacterBasic[]>("/api/data/avatar_basic");
return res.data
} catch (error: unknown) {
if (axios.isAxiosError(error)) {
@@ -38,7 +38,7 @@ export async function getCharacterListApi(): Promise<CharacterBasic[]> {
export async function getEnemyListApi(): Promise<MonsterBasic[]> {
try {
const res = await axios.get<MonsterBasic[]>("/data/monster.json");
const res = await axios.get<MonsterBasic[]>("/api/data/monster_basic");
return res.data
} catch (error: unknown) {
if (axios.isAxiosError(error)) {

38
src/lib/cache/cache.ts vendored Normal file
View File

@@ -0,0 +1,38 @@
import { readFileSync, readdirSync } from "fs"
import path from "path"
type CacheItem = {
buf: Uint8Array
type: "json" | "br"
}
const cache = new Map<string, CacheItem>()
const dir = path.join(process.cwd(), "data")
for (const f of readdirSync(dir)) {
const file = path.join(dir, f)
if (f.endsWith(".json.br")) {
const name = f.replace(".json.br", "")
const buf = new Uint8Array(readFileSync(file))
cache.set(name, {
buf,
type: "br"
})
}
if (f.endsWith(".json")) {
const name = f.replace(".json", "")
const buf = new Uint8Array(readFileSync(file))
cache.set(name, {
buf,
type: "json"
})
}
}
export function getDataCache(name: string) {
return cache.get(name)
}

1
src/lib/cache/index.ts vendored Normal file
View File

@@ -0,0 +1 @@
export * from "./cache"