Skip to content
This repository was archived by the owner on Nov 14, 2025. It is now read-only.

Commit 317c6a7

Browse files
committed
fix: 修复米游社日历数据异常,导致日历页白屏的问题
1 parent ec063ef commit 317c6a7

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gs-helper",
33
"productName": "GenshinHelper",
44
"private": true,
5-
"version": "1.2.3",
5+
"version": "1.2.4",
66
"description": "PC 端小工具,支持原神签到、祈愿分析、查看便签状态和游戏详细数据等。基于 Electron 和 React。",
77
"main": ".webpack/main",
88
"prettier": "@vikiboss/prettier-config",

src/render/pages/calendar/DailyMaterial/index.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ function getUniqueArray(arr: any[], key: string) {
4545
return results
4646
}
4747

48+
const MATERIAL_TYPE = '2'
49+
const WEAPON_TYPE = '1'
50+
4851
function getMaterialList(list: CalenderEvent[]) {
49-
const matirialKink = '2'
50-
const kind2 = list.filter((event) => event.kind === matirialKink)
52+
const kind2 = list.filter((event) => event.kind === MATERIAL_TYPE)
5153

5254
const materials: CalenderEvent[] = []
5355

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

76+
function sort(p: CalenderEvent, n: CalenderEvent) {
77+
return JSON.parse(p.sort || '{"0": 999}')[0] - JSON.parse(n.sort || '{"0": 999}')[0]
78+
}
79+
7480
// 角色
75-
const roles = cals.filter((e) => e.break_type === '2')
76-
roles.sort((p, n) => JSON.parse(p.sort)[0] - JSON.parse(n.sort)[0])
81+
const roles = cals.filter((e) => e.break_type === MATERIAL_TYPE)
82+
roles.sort(sort)
7783

7884
// 武器
79-
const weapons = cals.filter((e) => e.break_type === '1')
80-
weapons.sort((p, n) => JSON.parse(p.sort)[0] - JSON.parse(n.sort)[0])
85+
const weapons = cals.filter((e) => e.break_type === WEAPON_TYPE)
86+
weapons.sort(sort)
8187

8288
// 材料
8389
const materials = getMaterialList(cals)
84-
materials.sort((p, n) => JSON.parse(n.sort)[0] - JSON.parse(p.sort)[0])
90+
materials.sort(sort)
8591

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

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

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

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

0 commit comments

Comments
 (0)