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