@@ -7,6 +7,7 @@ import { createPortal } from 'react-dom'
7
7
import { Rnd , RndResizeCallback } from 'react-rnd'
8
8
import { useWindowSize } from 'react-use'
9
9
10
+ import { Level } from '../../../models/operation'
10
11
import { sendMessage , useMessage } from '../../../utils/messenger'
11
12
import { useLazyStorage } from '../../../utils/useLazyStorage'
12
13
import { useFloatingMap } from './FloatingMapContext'
@@ -25,14 +26,15 @@ interface FloatingMapConfig {
25
26
y : number
26
27
width : number
27
28
height : number
29
+ level ?: Level
28
30
}
29
31
30
32
const UID = 'floating-map'
31
33
const STORAGE_KEY = `copilot-${ UID } `
32
34
33
35
const HEADER_CLASS = 'floating-map-header'
34
36
35
- const HEADER_HEIGHT = 16
37
+ const HEADER_HEIGHT = 36
36
38
const ASPECT_RATIO = 16 / 9
37
39
const MIN_HEIGHT = 150 + HEADER_HEIGHT
38
40
const MIN_WIDTH = 150 * ASPECT_RATIO
@@ -54,6 +56,7 @@ export function FloatingMap() {
54
56
y : window . innerHeight - DEFAULT_HEIGHT ,
55
57
width : DEFAULT_WIDTH ,
56
58
height : DEFAULT_HEIGHT ,
59
+ level : undefined ,
57
60
} ,
58
61
// merge two values in case the saved value is missing some properties
59
62
( savedValue , defaultValue ) => ( { ...defaultValue , ...savedValue } ) ,
@@ -77,6 +80,7 @@ export function FloatingMap() {
77
80
useEffect ( ( ) => {
78
81
// when level changes, the iframe should reload
79
82
setMapStatus ( MapStatus . Loading )
83
+ setConfig ( ( cfg ) => ( { ...cfg , level } ) )
80
84
} , [ level ] )
81
85
82
86
const setMapState = useCallback ( ( ) => {
@@ -204,9 +208,8 @@ export function FloatingMap() {
204
208
</ Rnd >
205
209
) : (
206
210
< Card
207
- className = "absolute !p-0 overflow-hidden pointer-events-auto"
211
+ className = "absolute !p-0 overflow-hidden pointer-events-auto left-4 bottom-4 "
208
212
elevation = { 2 }
209
- style = { { left : 0 , bottom : 0 } }
210
213
>
211
214
< FloatingMapHeader config = { config } setConfig = { setConfig } />
212
215
</ Card >
@@ -238,13 +241,14 @@ function FloatingMapHeader({
238
241
>
239
242
< Button
240
243
minimal
241
- small = { ! config . show }
242
- className = "min-h-0 !py-0 "
244
+ style = { { height : HEADER_HEIGHT } }
245
+ className = "px-4 "
243
246
title = { config . show ? '隐藏地图' : '显示地图' }
244
247
icon = { config . show ? 'caret-down' : 'caret-up' }
245
248
onClick = { ( ) => setConfig ( { ...config , show : ! config . show } ) }
246
249
>
247
- { ! config . show && '地图' }
250
+ 地图
251
+ { config . show && ` ${ config . level ?. name } ` }
248
252
</ Button >
249
253
</ div >
250
254
)
0 commit comments