mirror of https://github.com/Xhofe/alist
🚧 plist generate
parent
b3a6e33ce1
commit
944e68a979
|
@ -1,10 +1,60 @@
|
|||
package controllers
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/server/common"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
"github.com/gin-gonic/gin"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Favicon(c *gin.Context) {
|
||||
c.Redirect(302, conf.GetStr("favicon"))
|
||||
}
|
||||
|
||||
func Plist(c *gin.Context) {
|
||||
data := c.Param("data")
|
||||
bytes, err := base64.StdEncoding.DecodeString(data)
|
||||
if err != nil {
|
||||
common.ErrorResp(c, err, 500)
|
||||
return
|
||||
}
|
||||
u := string(bytes)
|
||||
name := utils.Base(u)
|
||||
name = strings.TrimRight(name, ".ipa")
|
||||
plist := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>items</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>assets</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>kind</key>
|
||||
<string>software-package</string>
|
||||
<key>url</key>
|
||||
<string>%s</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>metadata</key>
|
||||
<dict>
|
||||
<key>bundle-identifier</key>
|
||||
<string>ci.nn.alist-doc</string>
|
||||
<key>bundle-version</key>
|
||||
<string>1</string>
|
||||
<key>kind</key>
|
||||
<string>software</string>
|
||||
<key>title</key>
|
||||
<string>%s</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>`, u, name)
|
||||
c.Status(200)
|
||||
c.Header("Content-Type", "application/xml;charset=utf-8")
|
||||
_, _ = c.Writer.WriteString(plist)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ func InitApiRouter(r *gin.Engine) {
|
|||
r.GET("/d/*path", middlewares.DownCheck, controllers.Down)
|
||||
r.GET("/p/*path", middlewares.DownCheck, controllers.Proxy)
|
||||
r.GET("/favicon.ico", controllers.Favicon)
|
||||
r.GET("/i/:data/ipa.plist", controllers.Plist)
|
||||
|
||||
api := r.Group("/api")
|
||||
public := api.Group("/public")
|
||||
|
|
Loading…
Reference in New Issue