@@ -24,6 +24,7 @@ import (
2424 "fmt"
2525 "net/mail"
2626 "net/url"
27+ "path/filepath"
2728 "strings"
2829
2930 "github.com/apache/answer/internal/base/constant"
@@ -305,16 +306,54 @@ type GetSMTPConfigResp struct {
305306
306307// GetManifestJsonResp get manifest json response
307308type GetManifestJsonResp struct {
308- ManifestVersion int `json:"manifest_version"`
309- Version string `json:"version"`
310- Revision string `json:"revision"`
311- ShortName string `json:"short_name"`
312- Name string `json:"name"`
313- Icons map [string ]string `json:"icons"`
314- StartUrl string `json:"start_url"`
315- Display string `json:"display"`
316- ThemeColor string `json:"theme_color"`
317- BackgroundColor string `json:"background_color"`
309+ ManifestVersion int `json:"manifest_version"`
310+ Version string `json:"version"`
311+ Revision string `json:"revision"`
312+ ShortName string `json:"short_name"`
313+ Name string `json:"name"`
314+ Icons []ManifestJsonIcon `json:"icons"`
315+ StartUrl string `json:"start_url"`
316+ Display string `json:"display"`
317+ ThemeColor string `json:"theme_color"`
318+ BackgroundColor string `json:"background_color"`
319+ }
320+
321+ type ManifestJsonIcon struct {
322+ Src string `json:"src"`
323+ Sizes string `json:"sizes"`
324+ Type string `json:"type"`
325+ }
326+
327+ func CreateManifestJsonIcons (icon string ) []ManifestJsonIcon {
328+ ext := filepath .Ext (icon )
329+ if ext == "" {
330+ ext = "png"
331+ } else {
332+ ext = strings .ToLower (ext [1 :])
333+ }
334+ iconType := fmt .Sprintf ("image/%s" , ext )
335+ return []ManifestJsonIcon {
336+ {
337+ Src : icon ,
338+ Sizes : "16x16" ,
339+ Type : iconType ,
340+ },
341+ {
342+ Src : icon ,
343+ Sizes : "32x32" ,
344+ Type : iconType ,
345+ },
346+ {
347+ Src : icon ,
348+ Sizes : "48x48" ,
349+ Type : iconType ,
350+ },
351+ {
352+ Src : icon ,
353+ Sizes : "128x128" ,
354+ Type : iconType ,
355+ },
356+ }
318357}
319358
320359const (
0 commit comments