From fa701a845a2255bc745b6bf702b6971b66734ff0 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 17 Feb 2022 20:23:06 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=8E=9F=E7=A5=9E=E6=8A=BD=E5=8D=A1?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E5=8D=A1=E6=B1=A0=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E7=AD=96=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/GenshinPanel/index.tsx | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/web/plugins/com.msgbyte.genshin/src/GenshinPanel/index.tsx b/web/plugins/com.msgbyte.genshin/src/GenshinPanel/index.tsx index 97c7153c..4e54016b 100644 --- a/web/plugins/com.msgbyte.genshin/src/GenshinPanel/index.tsx +++ b/web/plugins/com.msgbyte.genshin/src/GenshinPanel/index.tsx @@ -1,14 +1,27 @@ import React from 'react'; import { Translate } from '../translate'; -import { util } from 'genshin-gacha-kit'; +import { OfficialGachaIndex, OfficialGachaType, util } from 'genshin-gacha-kit'; import { useAsync } from '@capital/common'; import { PillTabs, PillTabPane } from '@capital/component'; -import './index.less'; import { GachaPool } from './GachaPool'; +import _groupBy from 'lodash/groupBy'; +import './index.less'; const GenshinPanel: React.FC = React.memo(() => { - const { value: gachaList } = useAsync(() => { - return util.getGachaIndex(); + const { value: gachaList } = useAsync(async () => { + const gacha = await util.getGachaIndex(); + const dict = _groupBy(gacha, 'gacha_type') as unknown as Record< + keyof OfficialGachaType, + OfficialGachaIndex[] + >; + + // 顺序: 角色 -> 武器 -> 常驻 -> 新手 + return [ + ...(dict['301'] ?? []), + ...(dict['302'] ?? []), + ...(dict['200'] ?? []), + ...(dict['100'] ?? []), + ]; }, []); return (