feat(ent): migrate DB settings in patches
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/cloudreve/Cloudreve/v4/inventory/types"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -169,7 +170,7 @@ type (
|
||||
// FolderPropsCacheTTL returns the cache TTL of folder summary.
|
||||
FolderPropsCacheTTL(ctx context.Context) int
|
||||
// FileViewers returns the file viewers settings.
|
||||
FileViewers(ctx context.Context) []ViewerGroup
|
||||
FileViewers(ctx context.Context) []types.ViewerGroup
|
||||
// ViewerSessionTTL returns the TTL of viewer session.
|
||||
ViewerSessionTTL(ctx context.Context) int
|
||||
// MimeMapping returns the extension to MIME mapping settings.
|
||||
@@ -232,11 +233,11 @@ func (s *settingProvider) Avatar(ctx context.Context) *Avatar {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *settingProvider) FileViewers(ctx context.Context) []ViewerGroup {
|
||||
func (s *settingProvider) FileViewers(ctx context.Context) []types.ViewerGroup {
|
||||
raw := s.getString(ctx, "file_viewers", "[]")
|
||||
var viewers []ViewerGroup
|
||||
var viewers []types.ViewerGroup
|
||||
if err := json.Unmarshal([]byte(raw), &viewers); err != nil {
|
||||
return []ViewerGroup{}
|
||||
return []types.ViewerGroup{}
|
||||
}
|
||||
|
||||
return viewers
|
||||
|
||||
@@ -176,42 +176,6 @@ type MapSetting struct {
|
||||
|
||||
// Viewer related
|
||||
|
||||
type (
|
||||
ViewerAction string
|
||||
ViewerType string
|
||||
)
|
||||
|
||||
const (
|
||||
ViewerActionView = "view"
|
||||
ViewerActionEdit = "edit"
|
||||
|
||||
ViewerTypeBuiltin = "builtin"
|
||||
ViewerTypeWopi = "wopi"
|
||||
)
|
||||
|
||||
type Viewer struct {
|
||||
ID string `json:"id"`
|
||||
Type ViewerType `json:"type"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Exts []string `json:"exts"`
|
||||
Url string `json:"url,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
WopiActions map[string]map[ViewerAction]string `json:"wopi_actions,omitempty"`
|
||||
Props map[string]string `json:"props,omitempty"`
|
||||
MaxSize int64 `json:"max_size,omitempty"`
|
||||
Disabled bool `json:"disabled,omitempty"`
|
||||
Templates []NewFileTemplate `json:"templates,omitempty"`
|
||||
}
|
||||
|
||||
type ViewerGroup struct {
|
||||
Viewers []Viewer `json:"viewers"`
|
||||
}
|
||||
|
||||
type NewFileTemplate struct {
|
||||
Ext string `json:"ext"`
|
||||
DisplayName string `json:"display_name"`
|
||||
}
|
||||
|
||||
type (
|
||||
SearchCategory string
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user