diff --git a/assets b/assets index 18bb1b0..6b2a820 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 18bb1b01b24c25ce070a2027fe362985d4866932 +Subproject commit 6b2a820a0c194c5dfb8069a4f4fcede5dd8d7b12 diff --git a/models/migration.go b/models/migration.go index be794d8..d29844f 100644 --- a/models/migration.go +++ b/models/migration.go @@ -189,6 +189,7 @@ Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; verti {Name: "pwa_display", Value: "standalone", Type: "pwa"}, {Name: "pwa_theme_color", Value: "#000000", Type: "pwa"}, {Name: "pwa_background_color", Value: "#ffffff", Type: "pwa"}, + {Name: "office_preview_service", Value: "https://view.officeapps.live.com/op/view.aspx?src={$src}", Type: "preview"}, } for _, value := range defaultSettings { diff --git a/service/explorer/file.go b/service/explorer/file.go index 8b56871..92961cb 100644 --- a/service/explorer/file.go +++ b/service/explorer/file.go @@ -2,8 +2,10 @@ package explorer import ( "context" + "encoding/base64" "encoding/json" "fmt" + "github.com/cloudreve/Cloudreve/v3/pkg/util" "io/ioutil" "net/http" "net/url" @@ -222,15 +224,15 @@ func (service *FileIDService) CreateDocPreviewSession(ctx context.Context, c *gi } // 生成最终的预览器地址 - // TODO 从配置文件中读取 - viewerBase, _ := url.Parse("https://view.officeapps.live.com/op/view.aspx") - params := viewerBase.Query() - params.Set("src", downloadURL) - viewerBase.RawQuery = params.Encode() - + srcB64 := base64.StdEncoding.EncodeToString([]byte(downloadURL)) + srcEncoded := url.QueryEscape(downloadURL) + srcB64Encoded := url.QueryEscape(srcB64) return serializer.Response{ Code: 0, - Data: viewerBase.String(), + Data: util.Replace(map[string]string{ + "{$src}": srcEncoded, + "{$srcB64}": srcB64Encoded, + }, model.GetSettingByName("office_preview_service")), } }