Skip to content

Commit 997bd89

Browse files
committed
feat: placeholder for missing or empty level names
1 parent 7608e7a commit 997bd89

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/components/editor/floatingMap/FloatingMap.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Button, Card, NonIdealState, Spinner } from '@blueprintjs/core'
22

33
import clsx from 'clsx'
4-
import { clamp } from 'lodash-es'
4+
import { clamp, isNil } from 'lodash-es'
55
import { useCallback, useEffect, useState } from 'react'
66
import { createPortal } from 'react-dom'
77
import { Rnd, RndResizeCallback } from 'react-rnd'
@@ -229,6 +229,14 @@ function FloatingMapHeader({
229229
config: FloatingMapConfig
230230
setConfig: (config: FloatingMapConfig) => void
231231
}) {
232+
let levelName = config.level?.name
233+
234+
if (isNil(levelName)) {
235+
levelName = '未选择关卡'
236+
} else if (!levelName.trim()) {
237+
levelName = '未命名关卡'
238+
}
239+
232240
return (
233241
<div
234242
className={clsx(
@@ -248,7 +256,7 @@ function FloatingMapHeader({
248256
onClick={() => setConfig({ ...config, show: !config.show })}
249257
>
250258
地图
251-
{config.show && ` ${config.level?.name}`}
259+
{config.show && ` - ${levelName}`}
252260
</Button>
253261
</div>
254262
)

0 commit comments

Comments
 (0)