mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2025-09-19 20:26:26 +08:00

* feat(config): Add PWA manifest.json endpoint for web app installation * fix: Update comment to English in manifest handler * fix: fix EOL * fix: Remove unused fmt import from manifest handler * feat: use site settings for manifest name and icon * fix(manifest): Move manifest.json route to static handler for proper CDN handling * feat: move manifest.json handler to static package and improve path handling * feat: Add custom static file handler to prevent manifest.json conflicts * fix: Integrate manifest.json handling into static file serving routes * fix: Simplify PWA manifest scope handling and static file serving - Remove CDN-specific logic for PWA manifest scope and start_url - Always use base path for PWA scope regardless of CDN configuration - Replace manual file serving logic with http.FileServer for static assets * fix: Ensure consistent base path handling in site configuration and manifest path construction * fix: Refactor trailing slash handling in site configuration * feat(static): update manifest path handling and add route for manifest.json
35 lines
929 B
Go
35 lines
929 B
Go
package static
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/conf"
|
|
"github.com/OpenListTeam/OpenList/v4/pkg/utils"
|
|
)
|
|
|
|
type SiteConfig struct {
|
|
BasePath string
|
|
Cdn string
|
|
}
|
|
|
|
func getSiteConfig() SiteConfig {
|
|
siteConfig := SiteConfig{
|
|
BasePath: conf.URL.Path,
|
|
Cdn: strings.ReplaceAll(strings.TrimSuffix(conf.Conf.Cdn, "/"), "$version", strings.TrimPrefix(conf.WebVersion, "v")),
|
|
}
|
|
if siteConfig.BasePath != "" {
|
|
siteConfig.BasePath = utils.FixAndCleanPath(siteConfig.BasePath)
|
|
// Keep consistent with frontend: trim trailing slash unless it's root
|
|
if siteConfig.BasePath != "/" && strings.HasSuffix(siteConfig.BasePath, "/") {
|
|
siteConfig.BasePath = strings.TrimSuffix(siteConfig.BasePath, "/")
|
|
}
|
|
}
|
|
if siteConfig.BasePath == "" {
|
|
siteConfig.BasePath = "/"
|
|
}
|
|
if siteConfig.Cdn == "" {
|
|
siteConfig.Cdn = strings.TrimSuffix(siteConfig.BasePath, "/")
|
|
}
|
|
return siteConfig
|
|
}
|