mirror of
https://github.com/cloudreve/cloudreve.git
synced 2026-04-18 12:09:40 +00:00
feat(dashboard): set global default file apps (close cloudreve/cloudreve#2304)
This commit is contained in:
2
assets
2
assets
Submodule assets updated: 194c0c3f22...4672a94eef
@@ -684,6 +684,7 @@ var DefaultSettings = map[string]string{
|
||||
"fts_tika_exts": "pdf,doc,docx,xls,xlsx,ppt,pptx,odt,ods,odp,rtf,txt,md,html,htm,epub,csv",
|
||||
"fts_tika_max_file_size": "26214400",
|
||||
"fts_chunk_size": "2000",
|
||||
"viewer_default_apps": "{}",
|
||||
}
|
||||
|
||||
var RedactedSettings = map[string]struct{}{
|
||||
|
||||
@@ -330,6 +330,8 @@ type (
|
||||
Viewers []Viewer `json:"viewers"`
|
||||
}
|
||||
|
||||
DefaultViewerMapping map[string]string
|
||||
|
||||
NewFileTemplate struct {
|
||||
Ext string `json:"ext"`
|
||||
DisplayName string `json:"display_name"`
|
||||
|
||||
@@ -234,6 +234,8 @@ type (
|
||||
FTSTikaExtractor(ctx context.Context) *FTSTikaExtractorSetting
|
||||
// FTSChunkSize returns the maximum chunk size in bytes for full-text search indexing.
|
||||
FTSChunkSize(ctx context.Context) int
|
||||
// DefaultViewerMapping returns the default viewer mapping.
|
||||
DefaultViewerMapping(ctx context.Context) types.DefaultViewerMapping
|
||||
}
|
||||
UseFirstSiteUrlCtxKey = struct{}
|
||||
)
|
||||
@@ -325,6 +327,15 @@ func (s *settingProvider) Avatar(ctx context.Context) *Avatar {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *settingProvider) DefaultViewerMapping(ctx context.Context) types.DefaultViewerMapping {
|
||||
raw := s.getString(ctx, "viewer_default_apps", "{}")
|
||||
var mapping types.DefaultViewerMapping
|
||||
if err := json.Unmarshal([]byte(raw), &mapping); err != nil {
|
||||
return types.DefaultViewerMapping{}
|
||||
}
|
||||
return mapping
|
||||
}
|
||||
|
||||
func (s *settingProvider) FileViewers(ctx context.Context) []types.ViewerGroup {
|
||||
raw := s.getString(ctx, "file_viewers", "[]")
|
||||
var viewers []types.ViewerGroup
|
||||
|
||||
@@ -43,18 +43,19 @@ type SiteConfig struct {
|
||||
PrivacyPolicyUrl string `json:"privacy_policy_url,omitempty"`
|
||||
|
||||
// Explorer section
|
||||
Icons string `json:"icons,omitempty"`
|
||||
EmojiPreset string `json:"emoji_preset,omitempty"`
|
||||
MapProvider setting.MapProvider `json:"map_provider,omitempty"`
|
||||
GoogleMapTileType setting.MapGoogleTileType `json:"google_map_tile_type,omitempty"`
|
||||
MapboxAK string `json:"mapbox_ak,omitempty"`
|
||||
FileViewers []types.ViewerGroup `json:"file_viewers,omitempty"`
|
||||
MaxBatchSize int `json:"max_batch_size,omitempty"`
|
||||
ThumbnailWidth int `json:"thumbnail_width,omitempty"`
|
||||
ThumbnailHeight int `json:"thumbnail_height,omitempty"`
|
||||
CustomProps []types.CustomProps `json:"custom_props,omitempty"`
|
||||
ShowEncryptionStatus bool `json:"show_encryption_status,omitempty"`
|
||||
FullTextSearch bool `json:"full_text_search,omitempty"`
|
||||
Icons string `json:"icons,omitempty"`
|
||||
EmojiPreset string `json:"emoji_preset,omitempty"`
|
||||
MapProvider setting.MapProvider `json:"map_provider,omitempty"`
|
||||
GoogleMapTileType setting.MapGoogleTileType `json:"google_map_tile_type,omitempty"`
|
||||
MapboxAK string `json:"mapbox_ak,omitempty"`
|
||||
FileViewers []types.ViewerGroup `json:"file_viewers,omitempty"`
|
||||
DefaultViewerMapping types.DefaultViewerMapping `json:"default_viewer_mapping,omitempty"`
|
||||
MaxBatchSize int `json:"max_batch_size,omitempty"`
|
||||
ThumbnailWidth int `json:"thumbnail_width,omitempty"`
|
||||
ThumbnailHeight int `json:"thumbnail_height,omitempty"`
|
||||
CustomProps []types.CustomProps `json:"custom_props,omitempty"`
|
||||
ShowEncryptionStatus bool `json:"show_encryption_status,omitempty"`
|
||||
FullTextSearch bool `json:"full_text_search,omitempty"`
|
||||
|
||||
// Thumbnail section
|
||||
ThumbExts []string `json:"thumb_exts,omitempty"`
|
||||
@@ -113,6 +114,7 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
|
||||
return &SiteConfig{
|
||||
MaxBatchSize: maxBatchSize,
|
||||
FileViewers: fileViewers,
|
||||
DefaultViewerMapping: settings.DefaultViewerMapping(c),
|
||||
Icons: explorerSettings.Icons,
|
||||
MapProvider: mapSettings.Provider,
|
||||
GoogleMapTileType: mapSettings.GoogleTileType,
|
||||
|
||||
Reference in New Issue
Block a user