2022-09-25 17:57:54 +08:00
|
|
|
package static
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2025-07-01 09:54:50 +08:00
|
|
|
"github.com/OpenListTeam/OpenList/v4/internal/conf"
|
|
|
|
"github.com/OpenListTeam/OpenList/v4/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-07-25 17:12:51 +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
|
|
|
|
}
|