feat: ?debug=true
This commit is contained in:
+27
-4
@@ -80,7 +80,11 @@ export function card(app: App) {
|
||||
)
|
||||
.get(
|
||||
"/genshin/:uid/:char",
|
||||
async ({ params: { uid, char: charId }, store: { start } }) => {
|
||||
async ({
|
||||
params: { uid, char: charId },
|
||||
store: { start },
|
||||
query: { debug },
|
||||
}) => {
|
||||
try {
|
||||
// const data = mockData;
|
||||
const [[avatarStore, weaponStore, relicStore, locs], data] =
|
||||
@@ -90,7 +94,7 @@ export function card(app: App) {
|
||||
console.log(`\n${Date.now() - start}ms - Stores loaded`),
|
||||
),
|
||||
),
|
||||
feature("API")
|
||||
feature("API") || uid !== "775956514"
|
||||
? deduper.acquire(`enka-${uid}`, () =>
|
||||
fetchEnka(uid, false).finally(() =>
|
||||
console.log(
|
||||
@@ -127,13 +131,16 @@ export function card(app: App) {
|
||||
36,
|
||||
);
|
||||
if (feature("API")) {
|
||||
const cached = cache.get<ImageResponse>(cacheKey);
|
||||
if (cached) return cached.clone();
|
||||
if (!debug) {
|
||||
const cached = cache.get<ImageResponse>(cacheKey);
|
||||
if (cached) return cached.clone();
|
||||
}
|
||||
}
|
||||
|
||||
const resources = await Promise.all([
|
||||
assets
|
||||
.load(
|
||||
// when reached level 40, then ascend, promoteLevel is 2
|
||||
weapon.data.promoteLevel >= 2
|
||||
? weapon.store.AwakenIcon
|
||||
: weapon.store.Icon,
|
||||
@@ -187,6 +194,16 @@ export function card(app: App) {
|
||||
|
||||
const statRows = buildDisplayRows(char, locs);
|
||||
|
||||
if (debug)
|
||||
return JSON.stringify({
|
||||
char,
|
||||
weapon,
|
||||
assets: resources.map((e) => e.src),
|
||||
charLvl,
|
||||
charLvlMax,
|
||||
statRows,
|
||||
});
|
||||
|
||||
const res = new ImageResponse(
|
||||
<div tw="relative text-[32.25px] text-white rounded-xl overflow-hidden">
|
||||
<div tw="aspect-[1218/508] h-full">
|
||||
@@ -498,6 +515,12 @@ export function card(app: App) {
|
||||
uid: t.String(),
|
||||
char: t.Number(),
|
||||
}),
|
||||
query: t.Object(
|
||||
{
|
||||
debug: t.Optional(t.String()),
|
||||
},
|
||||
{ additionalProperties: true },
|
||||
),
|
||||
detail: {
|
||||
tags: ["Card"],
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user