Commit 3ca05cfb authored by zhangshize's avatar zhangshize

feat: add forbidden alias icon

parent f7897383
Pipeline #23402 passed with stages
in 11 minutes and 38 seconds
...@@ -21,28 +21,16 @@ export interface CardData { ...@@ -21,28 +21,16 @@ export interface CardData {
rscale?: number; rscale?: number;
} }
export interface CardText { export type CardStrRange = `str${IntRange<1, 17>}`;
export type CardText = {
id?: number; id?: number;
name?: string; name?: string;
types?: string; types?: string;
desc?: string; desc?: string;
str1?: string; } & {
str2?: string; [str in CardStrRange]?: string;
str3?: string; };
str4?: string;
str5?: string;
str6?: string;
str7?: string;
str8?: string;
str9?: string;
str10?: string;
str11?: string;
str12?: string;
str13?: string;
str14?: string;
str15?: string;
str16?: string;
}
/* /*
* 返回卡片元数据 * 返回卡片元数据
...@@ -80,57 +68,6 @@ window.fetchCard = fetchCard; ...@@ -80,57 +68,6 @@ window.fetchCard = fetchCard;
window.searchCard = searchCards; window.searchCard = searchCards;
export function getCardStr(meta: CardMeta, idx: number): string | undefined { export function getCardStr(meta: CardMeta, idx: number): string | undefined {
switch (idx) { const str = `str${idx + 1}` as CardStrRange;
case 0: { return meta.text[str];
return meta.text.str1;
}
case 1: {
return meta.text.str2;
}
case 2: {
return meta.text.str3;
}
case 3: {
return meta.text.str4;
}
case 4: {
return meta.text.str5;
}
case 5: {
return meta.text.str6;
}
case 6: {
return meta.text.str7;
}
case 7: {
return meta.text.str8;
}
case 8: {
return meta.text.str9;
}
case 9: {
return meta.text.str10;
}
case 10: {
return meta.text.str11;
}
case 11: {
return meta.text.str12;
}
case 12: {
return meta.text.str13;
}
case 13: {
return meta.text.str14;
}
case 14: {
return meta.text.str15;
}
case 15: {
return meta.text.str16;
}
default: {
return undefined;
}
}
} }
import { isNil } from "lodash-es";
import { useConfig } from "@/config"; import { useConfig } from "@/config";
const { lflistUrl } = useConfig(); const { lflistUrl } = useConfig();
...@@ -16,7 +18,8 @@ class Forbidden { ...@@ -16,7 +18,8 @@ class Forbidden {
this.data.set(cardId, limitCount); this.data.set(cardId, limitCount);
} }
public get(id: number): number | undefined { public get(id?: number): number | undefined {
if (isNil(id)) return;
return this.data.get(id); return this.data.get(id);
} }
......
type Enumerate<
N extends number,
Acc extends number[] = [],
> = Acc["length"] extends N
? Acc[number]
: Enumerate<N, [...Acc, Acc["length"]]>;
type IntRange<F extends number, T extends number> = Exclude<
Enumerate<T>,
Enumerate<F>
>;
...@@ -32,7 +32,8 @@ export const DeckCard: React.FC<{ ...@@ -32,7 +32,8 @@ export const DeckCard: React.FC<{
}); });
drag(ref); drag(ref);
const [showText, setShowText] = useState(true); const [showText, setShowText] = useState(true);
const limitCnt = forbidden.get(value.id); const limitCnt = forbidden.get(value.id) ?? forbidden.get(value.data.alias);
return ( return (
<div <div
className={styles.card} className={styles.card}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment