Skip to content

Commit

Permalink
feat!: unity iframe preview
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 23, 2022
1 parent e992780 commit d9ee174
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
23 changes: 16 additions & 7 deletions internal/bootstrap/data/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions internal/conf/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -51,7 +51,7 @@ const (
const (
UNKNOWN = iota
FOLDER
OFFICE
//OFFICE
VIDEO
AUDIO
TEXT
Expand Down
12 changes: 6 additions & 6 deletions internal/db/settinghooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ",")
Expand Down
6 changes: 3 additions & 3 deletions pkg/utils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit d9ee174

Please sign in to comment.