Skip to content

Commit d9ee174

Browse files
committed
feat!: unity iframe preview
1 parent e992780 commit d9ee174

4 files changed

Lines changed: 31 additions & 22 deletions

File tree

internal/bootstrap/data/setting.go

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,25 @@ func initialSettings() {
8282
{Key: conf.AudioTypes, Value: "mp3,flac,ogg,m4a,wav,opus", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
8383
{Key: conf.VideoTypes, Value: "mp4,mkv,avi,mov,rmvb,webm,flv", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
8484
{Key: conf.ImageTypes, Value: "jpg,tiff,jpeg,png,gif,bmp,svg,ico,swf,webp", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
85-
{Key: conf.OfficeTypes, Value: "doc,docx,xls,xlsx,ppt,pptx", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
85+
//{Key: conf.OfficeTypes, Value: "doc,docx,xls,xlsx,ppt,pptx", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
8686
{Key: conf.ProxyTypes, Value: "m3u8", Type: conf.TypeText, Group: model.PREVIEW, Flag: model.PRIVATE},
8787
{Key: "external_previews", Value: `{}`, Type: conf.TypeText, Group: model.PREVIEW},
88-
{Key: conf.OfficeViewers, Value: `{
89-
"Microsoft":"https://view.officeapps.live.com/op/view.aspx?src=$url",
90-
"Google":"https://docs.google.com/gview?url=$url&embedded=true",
91-
}`, Type: conf.TypeText, Group: model.PREVIEW},
92-
{Key: conf.PdfViewers, Value: `{
93-
"pdf.js":"https://alist-org.github.io/pdf.js/web/viewer.html?file=$url"
88+
{Key: "iframe_previews", Value: `{
89+
"doc,docx,xls,xlsx,ppt,pptx": {
90+
"Microsoft":"https://view.officeapps.live.com/op/view.aspx?src=$url",
91+
"Google":"https://docs.google.com/gview?url=$url&embedded=true"
92+
},
93+
"pdf": {
94+
"PDF.js":"https://alist-org.github.io/pdf.js/web/viewer.html?file=$url"
95+
}
9496
}`, Type: conf.TypeText, Group: model.PREVIEW},
97+
// {Key: conf.OfficeViewers, Value: `{
98+
// "Microsoft":"https://view.officeapps.live.com/op/view.aspx?src=$url",
99+
// "Google":"https://docs.google.com/gview?url=$url&embedded=true",
100+
//}`, Type: conf.TypeText, Group: model.PREVIEW},
101+
// {Key: conf.PdfViewers, Value: `{
102+
// "pdf.js":"https://alist-org.github.io/pdf.js/web/viewer.html?file=$url"
103+
//}`, Type: conf.TypeText, Group: model.PREVIEW},
95104
{Key: conf.AudioAutoplay, Value: "true", Type: conf.TypeBool, Group: model.PREVIEW},
96105
{Key: conf.VideoAutoplay, Value: "true", Type: conf.TypeBool, Group: model.PREVIEW},
97106
// global settings

internal/conf/const.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ const (
2121
MainColor = "main_color"
2222

2323
// preview
24-
TextTypes = "text_types"
25-
AudioTypes = "audio_types"
26-
VideoTypes = "video_types"
27-
ImageTypes = "image_types"
28-
OfficeTypes = "office_types"
24+
TextTypes = "text_types"
25+
AudioTypes = "audio_types"
26+
VideoTypes = "video_types"
27+
ImageTypes = "image_types"
28+
//OfficeTypes = "office_types"
2929
ProxyTypes = "proxy_types"
3030
OfficeViewers = "office_viewers"
3131
PdfViewers = "pdf_viewers"
@@ -51,7 +51,7 @@ const (
5151
const (
5252
UNKNOWN = iota
5353
FOLDER
54-
OFFICE
54+
//OFFICE
5555
VIDEO
5656
AUDIO
5757
TEXT

internal/db/settinghooks.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ var SettingItemHooks = map[string]SettingItemHook{
3838
return nil
3939
},
4040
},
41-
conf.OfficeTypes: {
42-
Hook: func(item *model.SettingItem) error {
43-
conf.TypesMap[conf.OfficeTypes] = strings.Split(item.Value, ",")
44-
return nil
45-
},
46-
},
41+
//conf.OfficeTypes: {
42+
// Hook: func(item *model.SettingItem) error {
43+
// conf.TypesMap[conf.OfficeTypes] = strings.Split(item.Value, ",")
44+
// return nil
45+
// },
46+
//},
4747
conf.ProxyTypes: {
4848
func(item *model.SettingItem) error {
4949
conf.TypesMap[conf.ProxyTypes] = strings.Split(item.Value, ",")

pkg/utils/file.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ func CreateTempFile(r io.ReadCloser) (*os.File, error) {
5353
// GetFileType get file type
5454
func GetFileType(filename string) int {
5555
ext := Ext(filename)
56-
if SliceContains(conf.TypesMap[conf.OfficeTypes], ext) {
57-
return conf.OFFICE
58-
}
56+
//if SliceContains(conf.TypesMap[conf.OfficeTypes], ext) {
57+
// return conf.OFFICE
58+
//}
5959
if SliceContains(conf.TypesMap[conf.AudioTypes], ext) {
6060
return conf.AUDIO
6161
}

0 commit comments

Comments
 (0)