2022-09-25 17:57:54 +08:00
|
|
|
package static
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2025-06-12 22:02:46 +08:00
|
|
|
"github.com/OpenListTeam/OpenList/internal/conf"
|
|
|
|
"github.com/OpenListTeam/OpenList/pkg/utils"
|
2022-09-25 17:57:54 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type SiteConfig struct {
|
|
|
|
BasePath string
|
|
|
|
Cdn string
|
|
|
|
}
|
|
|
|
|
|
|
|
func getSiteConfig() SiteConfig {
|
|
|
|
siteConfig := SiteConfig{
|
2023-02-18 19:03:07 +08:00
|
|
|
BasePath: conf.URL.Path,
|
2025-06-24 07:12:18 +08:00
|
|
|
Cdn: strings.ReplaceAll(strings.TrimSuffix(conf.Conf.Cdn, "/"), "$version", strings.TrimPrefix(conf.WebVersion, "v"),),
|
2022-09-25 17:57:54 +08:00
|
|
|
}
|
|
|
|
if siteConfig.BasePath != "" {
|
2022-12-17 19:49:05 +08:00
|
|
|
siteConfig.BasePath = utils.FixAndCleanPath(siteConfig.BasePath)
|
2022-09-25 17:57:54 +08:00
|
|
|
}
|
|
|
|
if siteConfig.Cdn == "" {
|
2023-02-18 19:03:07 +08:00
|
|
|
siteConfig.Cdn = strings.TrimSuffix(siteConfig.BasePath, "/")
|
2022-09-25 17:57:54 +08:00
|
|
|
}
|
|
|
|
return siteConfig
|
|
|
|
}
|