Skip to content

Commit

Permalink
fix: 修复米游社日历数据异常,导致日历页白屏的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
vikiboss committed Feb 14, 2023
1 parent ec063ef commit 317c6a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "gs-helper",
"productName": "GenshinHelper",
"private": true,
"version": "1.2.3",
"version": "1.2.4",
"description": "PC 端小工具,支持原神签到、祈愿分析、查看便签状态和游戏详细数据等。基于 Electron 和 React。",
"main": ".webpack/main",
"prettier": "@vikiboss/prettier-config",
Expand Down
22 changes: 14 additions & 8 deletions src/render/pages/calendar/DailyMaterial/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@ function getUniqueArray(arr: any[], key: string) {
return results
}

const MATERIAL_TYPE = '2'
const WEAPON_TYPE = '1'

function getMaterialList(list: CalenderEvent[]) {
const matirialKink = '2'
const kind2 = list.filter((event) => event.kind === matirialKink)
const kind2 = list.filter((event) => event.kind === MATERIAL_TYPE)

const materials: CalenderEvent[] = []

Expand All @@ -71,17 +73,21 @@ export default function DailyMaterial({ cals, notice }: DailyProp) {
const [type, setType] = useState<Type>('roles')
const [week, setWeek] = useState<number>(todayWeek)

function sort(p: CalenderEvent, n: CalenderEvent) {
return JSON.parse(p.sort || '{"0": 999}')[0] - JSON.parse(n.sort || '{"0": 999}')[0]
}

// 角色
const roles = cals.filter((e) => e.break_type === '2')
roles.sort((p, n) => JSON.parse(p.sort)[0] - JSON.parse(n.sort)[0])
const roles = cals.filter((e) => e.break_type === MATERIAL_TYPE)
roles.sort(sort)

// 武器
const weapons = cals.filter((e) => e.break_type === '1')
weapons.sort((p, n) => JSON.parse(p.sort)[0] - JSON.parse(n.sort)[0])
const weapons = cals.filter((e) => e.break_type === WEAPON_TYPE)
weapons.sort(sort)

// 材料
const materials = getMaterialList(cals)
materials.sort((p, n) => JSON.parse(n.sort)[0] - JSON.parse(p.sort)[0])
materials.sort(sort)

const EventMap: Record<string, CalenderEvent[]> = { roles, weapons, materials }

Expand All @@ -96,7 +102,7 @@ export default function DailyMaterial({ cals, notice }: DailyProp) {
? `「${e.title}」 突破需要`
: ''

const contents = ` ${e.contentInfos[0].title.slice(0, 4)} 系列`
const contents = ` ${e.contentInfos[0]?.title.slice(0, 4)} 系列`

message += type !== 'materials' ? contents : e.title
message += `,可在 「${e.contentSource[0]?.title || '忘却之峡'}」 获取`
Expand Down

0 comments on commit 317c6a7

Please sign in to comment.