mirror of
https://github.com/halejohn/Cloudreve.git
synced 2026-01-26 09:34:57 +08:00
Feat: dynamically generate manifest.json
This commit is contained in:
@@ -35,3 +35,14 @@ func AdminChangeSetting(c *gin.Context) {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
// AdminGetSetting 获取站点设置
|
||||
func AdminGetSetting(c *gin.Context) {
|
||||
var service admin.BatchSettingGet
|
||||
if err := c.ShouldBindJSON(&service); err == nil {
|
||||
res := service.Get()
|
||||
c.JSON(200, res)
|
||||
} else {
|
||||
c.JSON(200, ErrorResponse(err))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,3 +85,43 @@ func Captcha(c *gin.Context) {
|
||||
Data: base64stringD,
|
||||
})
|
||||
}
|
||||
|
||||
// Manifest 获取manifest.json
|
||||
func Manifest(c *gin.Context) {
|
||||
options := model.GetSettingByNames(
|
||||
"siteName",
|
||||
"siteTitle",
|
||||
"pwa_small_icon",
|
||||
"pwa_medium_icon",
|
||||
"pwa_large_icon",
|
||||
"pwa_display",
|
||||
"pwa_theme_color",
|
||||
"pwa_background_color",
|
||||
)
|
||||
|
||||
c.JSON(200, map[string]interface{}{
|
||||
"short_name": options["siteName"],
|
||||
"name": options["siteTitle"],
|
||||
"icons": []map[string]string{
|
||||
{
|
||||
"src": options["pwa_small_icon"],
|
||||
"sizes": "64x64 32x32 24x24 16x16",
|
||||
"type": "image/x-icon",
|
||||
},
|
||||
{
|
||||
"src": options["pwa_medium_icon"],
|
||||
"type": "image/png",
|
||||
"sizes": "192x192",
|
||||
},
|
||||
{
|
||||
"src": options["pwa_large_icon"],
|
||||
"type": "image/png",
|
||||
"sizes": "512x512",
|
||||
},
|
||||
},
|
||||
"start_url": ".",
|
||||
"display": options["pwa_display"],
|
||||
"theme_color": options["pwa_theme_color"],
|
||||
"background_color": options["pwa_background_color"],
|
||||
})
|
||||
}
|
||||
|
||||
@@ -72,6 +72,12 @@ func InitCORS(router *gin.Engine) {
|
||||
func InitMasterRouter() *gin.Engine {
|
||||
r := gin.Default()
|
||||
bootstrap.InitCustomRoute(r.Group("/custom"))
|
||||
|
||||
/*
|
||||
静态资源
|
||||
*/
|
||||
r.GET("manifest.json", controllers.Manifest)
|
||||
|
||||
v3 := r.Group("/api/v3")
|
||||
|
||||
/*
|
||||
@@ -289,6 +295,8 @@ func InitMasterRouter() *gin.Engine {
|
||||
admin.GET("news", controllers.AdminNews)
|
||||
// 更改设置
|
||||
admin.PATCH("setting", controllers.AdminChangeSetting)
|
||||
// 获取设置
|
||||
admin.POST("setting", controllers.AdminGetSetting)
|
||||
}
|
||||
|
||||
// 用户
|
||||
|
||||
Reference in New Issue
Block a user