Enhance API documentation and improve marker functionality
- Updated API documentation for clarity and consistency, including detailed descriptions of authentication and user account endpoints. - Added a new cave marker image to enhance visual representation in the frontend. - Implemented normalization for cave marker images during upload to ensure consistent storage format. - Expanded test coverage for client services, including new tests for marker uploads and image normalization.
This commit is contained in:
@@ -85,10 +85,16 @@ export function createMarker(
|
||||
if (!marker.hidden) {
|
||||
const resolve = iconOptions?.resolveIconUrl ?? ((path: string) => path)
|
||||
const fallback = iconOptions?.fallbackIconUrl
|
||||
const iconUrl =
|
||||
marker.name === 'Cave' && marker.image === 'gfx/terobjs/mm/custom'
|
||||
? resolve('gfx/terobjs/mm/cave.png')
|
||||
: marker.image === 'gfx/terobjs/mm/custom'
|
||||
? resolve('gfx/terobjs/mm/custom.png')
|
||||
: resolve(`${marker.image}.png`)
|
||||
let icon: L.Icon
|
||||
if (marker.image === 'gfx/terobjs/mm/custom') {
|
||||
if (marker.image === 'gfx/terobjs/mm/custom' && marker.name !== 'Cave') {
|
||||
icon = new ImageIcon({
|
||||
iconUrl: resolve('gfx/terobjs/mm/custom.png'),
|
||||
iconUrl,
|
||||
iconSize: [21, 23],
|
||||
iconAnchor: [11, 21],
|
||||
popupAnchor: [1, 3],
|
||||
@@ -97,7 +103,7 @@ export function createMarker(
|
||||
})
|
||||
} else {
|
||||
icon = new ImageIcon({
|
||||
iconUrl: resolve(`${marker.image}.png`),
|
||||
iconUrl,
|
||||
iconSize: [32, 32],
|
||||
fallbackIconUrl: fallback,
|
||||
})
|
||||
|
||||
BIN
frontend-nuxt/public/gfx/terobjs/mm/cave.png
Normal file
BIN
frontend-nuxt/public/gfx/terobjs/mm/cave.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.4 KiB |
@@ -481,6 +481,9 @@ func (s *ClientService) UploadMarkers(ctx context.Context, data []byte) error {
|
||||
if img == "" {
|
||||
img = "gfx/terobjs/mm/custom"
|
||||
}
|
||||
if mraw.Name == "Cave" {
|
||||
img = "gfx/terobjs/mm/cave"
|
||||
}
|
||||
id, err := idB.NextSequence()
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -91,3 +91,31 @@ func TestClientProcessGridUpdate_EmptyGrids(t *testing.T) {
|
||||
t.Fatal("expected non-nil result")
|
||||
}
|
||||
}
|
||||
|
||||
func TestUploadMarkers_NormalizesCaveImage(t *testing.T) {
|
||||
client, st := newTestClientService(t)
|
||||
ctx := context.Background()
|
||||
body := []byte(`[{"Name":"Cave","GridID":"g1","X":10,"Y":20,"Image":"gfx/terobjs/mm/custom"}]`)
|
||||
if err := client.UploadMarkers(ctx, body); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var stored app.Marker
|
||||
if err := st.View(ctx, func(tx *bbolt.Tx) error {
|
||||
grid := st.GetMarkersGridBucket(tx)
|
||||
if grid == nil {
|
||||
t.Fatal("markers grid bucket not found")
|
||||
return nil
|
||||
}
|
||||
v := grid.Get([]byte("g1_10_20"))
|
||||
if v == nil {
|
||||
t.Fatal("marker g1_10_20 not found")
|
||||
return nil
|
||||
}
|
||||
return json.Unmarshal(v, &stored)
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if stored.Image != "gfx/terobjs/mm/cave" {
|
||||
t.Fatalf("expected stored marker Image gfx/terobjs/mm/cave, got %q", stored.Image)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user