Feat: set default view method in file manager
This commit is contained in:
parent
e2f6dab70c
commit
a0c320b964
4 changed files with 35 additions and 23 deletions
|
@ -164,6 +164,8 @@ Neue',Helvetica,Arial,sans-serif; box-sizing: border-box; font-size: 14px; verti
|
|||
{Name: "temp_path", Value: "temp", Type: "path"},
|
||||
{Name: "score_enabled", Value: "1", Type: "score"},
|
||||
{Name: "share_score_rate", Value: "80", Type: "score"},
|
||||
{Name: "home_view_method", Value: "icon", Type: "view"},
|
||||
{Name: "share_view_method", Value: "list", Type: "view"},
|
||||
}
|
||||
|
||||
for _, value := range defaultSettings {
|
||||
|
|
|
@ -4,17 +4,19 @@ import model "github.com/HFO4/cloudreve/models"
|
|||
|
||||
// SiteConfig 站点全局设置序列
|
||||
type SiteConfig struct {
|
||||
SiteName string `json:"title"`
|
||||
LoginCaptcha bool `json:"loginCaptcha"`
|
||||
RegCaptcha bool `json:"regCaptcha"`
|
||||
ForgetCaptcha bool `json:"forgetCaptcha"`
|
||||
EmailActive bool `json:"emailActive"`
|
||||
QQLogin bool `json:"QQLogin"`
|
||||
Themes string `json:"themes"`
|
||||
DefaultTheme string `json:"defaultTheme"`
|
||||
ScoreEnabled bool `json:"score_enabled"`
|
||||
ShareScoreRate string `json:"share_score_rate"`
|
||||
User User `json:"user"`
|
||||
SiteName string `json:"title"`
|
||||
LoginCaptcha bool `json:"loginCaptcha"`
|
||||
RegCaptcha bool `json:"regCaptcha"`
|
||||
ForgetCaptcha bool `json:"forgetCaptcha"`
|
||||
EmailActive bool `json:"emailActive"`
|
||||
QQLogin bool `json:"QQLogin"`
|
||||
Themes string `json:"themes"`
|
||||
DefaultTheme string `json:"defaultTheme"`
|
||||
ScoreEnabled bool `json:"score_enabled"`
|
||||
ShareScoreRate string `json:"share_score_rate"`
|
||||
HomepageViewMethod string `json:"home_view_method"`
|
||||
ShareViewMethod string `json:"share_view_method"`
|
||||
User User `json:"user"`
|
||||
}
|
||||
|
||||
func checkSettingValue(setting map[string]string, key string) string {
|
||||
|
@ -32,16 +34,18 @@ func BuildSiteConfig(settings map[string]string, user *model.User) Response {
|
|||
}
|
||||
return Response{
|
||||
Data: SiteConfig{
|
||||
SiteName: checkSettingValue(settings, "siteName"),
|
||||
LoginCaptcha: model.IsTrueVal(checkSettingValue(settings, "login_captcha")),
|
||||
RegCaptcha: model.IsTrueVal(checkSettingValue(settings, "reg_captcha")),
|
||||
ForgetCaptcha: model.IsTrueVal(checkSettingValue(settings, "forget_captcha")),
|
||||
EmailActive: model.IsTrueVal(checkSettingValue(settings, "email_active")),
|
||||
QQLogin: model.IsTrueVal(checkSettingValue(settings, "qq_login")),
|
||||
Themes: checkSettingValue(settings, "themes"),
|
||||
DefaultTheme: checkSettingValue(settings, "defaultTheme"),
|
||||
ScoreEnabled: model.IsTrueVal(checkSettingValue(settings, "score_enabled")),
|
||||
ShareScoreRate: checkSettingValue(settings, "share_score_rate"),
|
||||
User: userRes,
|
||||
SiteName: checkSettingValue(settings, "siteName"),
|
||||
LoginCaptcha: model.IsTrueVal(checkSettingValue(settings, "login_captcha")),
|
||||
RegCaptcha: model.IsTrueVal(checkSettingValue(settings, "reg_captcha")),
|
||||
ForgetCaptcha: model.IsTrueVal(checkSettingValue(settings, "forget_captcha")),
|
||||
EmailActive: model.IsTrueVal(checkSettingValue(settings, "email_active")),
|
||||
QQLogin: model.IsTrueVal(checkSettingValue(settings, "qq_login")),
|
||||
Themes: checkSettingValue(settings, "themes"),
|
||||
DefaultTheme: checkSettingValue(settings, "defaultTheme"),
|
||||
ScoreEnabled: model.IsTrueVal(checkSettingValue(settings, "score_enabled")),
|
||||
ShareScoreRate: checkSettingValue(settings, "share_score_rate"),
|
||||
HomepageViewMethod: checkSettingValue(settings, "home_view_method"),
|
||||
ShareViewMethod: checkSettingValue(settings, "share_view_method"),
|
||||
User: userRes,
|
||||
}}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,11 @@ func BuildShareResponse(share *model.Share, unlocked bool) Share {
|
|||
}
|
||||
|
||||
if share.IsDir {
|
||||
|
||||
source := share.GetSourceFolder()
|
||||
resp.Source = &shareSource{
|
||||
Name: source.Name,
|
||||
Size: 0,
|
||||
}
|
||||
} else {
|
||||
source := share.GetSourceFile()
|
||||
resp.Source = &shareSource{
|
||||
|
|
|
@ -23,6 +23,8 @@ func SiteConfig(c *gin.Context) {
|
|||
"defaultTheme",
|
||||
"score_enabled",
|
||||
"share_score_rate",
|
||||
"home_view_method",
|
||||
"share_view_method",
|
||||
})
|
||||
|
||||
// 如果已登录,则同时返回用户信息
|
||||
|
|
Loading…
Add table
Reference in a new issue