feat!: unity iframe preview

This commit is contained in:
Noah Hsu 2022-08-23 16:50:54 +08:00
parent e9927806d4
commit d9ee174dd3
4 changed files with 31 additions and 22 deletions

View File

@ -82,16 +82,25 @@ func initialSettings() {
{Key: conf.AudioTypes, Value: "mp3,flac,ogg,m4a,wav,opus", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
{Key: conf.VideoTypes, Value: "mp4,mkv,avi,mov,rmvb,webm,flv", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
{Key: conf.ImageTypes, Value: "jpg,tiff,jpeg,png,gif,bmp,svg,ico,swf,webp", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
{Key: conf.OfficeTypes, Value: "doc,docx,xls,xlsx,ppt,pptx", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
//{Key: conf.OfficeTypes, Value: "doc,docx,xls,xlsx,ppt,pptx", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
{Key: conf.ProxyTypes, Value: "m3u8", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
{Key: "external_previews", Value: `{}`, Type: conf.TypeText, Group: model.PREVIEW},
{Key: conf.OfficeViewers, Value: `{
"Microsoft":"https://view.officeapps.live.com/op/view.aspx?src=$url",
"Google":"https://docs.google.com/gview?url=$url&embedded=true",
}`, Type: conf.TypeText, Group: model.PREVIEW},
{Key: conf.PdfViewers, Value: `{
"pdf.js":"https://alist-org.github.io/pdf.js/web/viewer.html?file=$url"
{Key: "iframe_previews", Value: `{
"doc,docx,xls,xlsx,ppt,pptx": {
"Microsoft":"https://view.officeapps.live.com/op/view.aspx?src=$url",
"Google":"https://docs.google.com/gview?url=$url&embedded=true"
},
"pdf": {
"PDF.js":"https://alist-org.github.io/pdf.js/web/viewer.html?file=$url"
}
}`, Type: conf.TypeText, Group: model.PREVIEW},
// {Key: conf.OfficeViewers, Value: `{
// "Microsoft":"https://view.officeapps.live.com/op/view.aspx?src=$url",
// "Google":"https://docs.google.com/gview?url=$url&embedded=true",
//}`, Type: conf.TypeText, Group: model.PREVIEW},
// {Key: conf.PdfViewers, Value: `{
// "pdf.js":"https://alist-org.github.io/pdf.js/web/viewer.html?file=$url"
//}`, Type: conf.TypeText, Group: model.PREVIEW},
{Key: conf.AudioAutoplay, Value: "true", Type: conf.TypeBool, Group: model.PREVIEW},
{Key: conf.VideoAutoplay, Value: "true", Type: conf.TypeBool, Group: model.PREVIEW},
// global settings

View File

@ -21,11 +21,11 @@ const (
MainColor = "main_color"
// preview
TextTypes = "text_types"
AudioTypes = "audio_types"
VideoTypes = "video_types"
ImageTypes = "image_types"
OfficeTypes = "office_types"
TextTypes = "text_types"
AudioTypes = "audio_types"
VideoTypes = "video_types"
ImageTypes = "image_types"
//OfficeTypes = "office_types"
ProxyTypes = "proxy_types"
OfficeViewers = "office_viewers"
PdfViewers = "pdf_viewers"
@ -51,7 +51,7 @@ const (
const (
UNKNOWN = iota
FOLDER
OFFICE
//OFFICE
VIDEO
AUDIO
TEXT

View File

@ -38,12 +38,12 @@ var SettingItemHooks = map[string]SettingItemHook{
return nil
},
},
conf.OfficeTypes: {
Hook: func(item *model.SettingItem) error {
conf.TypesMap[conf.OfficeTypes] = strings.Split(item.Value, ",")
return nil
},
},
//conf.OfficeTypes: {
// Hook: func(item *model.SettingItem) error {
// conf.TypesMap[conf.OfficeTypes] = strings.Split(item.Value, ",")
// return nil
// },
//},
conf.ProxyTypes: {
func(item *model.SettingItem) error {
conf.TypesMap[conf.ProxyTypes] = strings.Split(item.Value, ",")

View File

@ -53,9 +53,9 @@ func CreateTempFile(r io.ReadCloser) (*os.File, error) {
// GetFileType get file type
func GetFileType(filename string) int {
ext := Ext(filename)
if SliceContains(conf.TypesMap[conf.OfficeTypes], ext) {
return conf.OFFICE
}
//if SliceContains(conf.TypesMap[conf.OfficeTypes], ext) {
// return conf.OFFICE
//}
if SliceContains(conf.TypesMap[conf.AudioTypes], ext) {
return conf.AUDIO
}