Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b3422b1884 | ||
|
|
34b1831a62 | ||
| 5668469665 | |||
|
|
33bdd1418f | ||
|
|
37173601a9 | ||
|
|
080e90a45d | ||
|
|
0bbc1ccab8 | ||
|
|
77f55c78cf | ||
|
|
ef40619a38 | ||
|
|
5b2692a1ff | ||
|
|
583ad038e6 | ||
|
|
d0774c5f20 | ||
|
|
e992ac3274 | ||
|
|
779596bfbb | ||
|
|
d29aa05959 | ||
|
|
298718a468 | ||
|
|
11760e8acd | ||
|
|
6884dc678d | ||
|
|
5004011f46 | ||
|
|
99b147ad6e | ||
|
|
55f9c45c93 | ||
|
|
9f130cb50f | ||
|
|
59dc910bc3 | ||
|
|
b75e9c0590 | ||
|
|
7b7b19feaf | ||
|
|
2d299d347a | ||
|
|
4e08c20a0d | ||
|
|
868741ebe1 | ||
|
|
170b25bc2a | ||
|
|
b5b364a2b0 | ||
|
|
f03a45aa93 | ||
|
|
4504853f88 | ||
|
|
947b9f5476 | ||
|
|
d76485f903 | ||
|
|
9fc4a406a1 | ||
|
|
d3a64c0a77 | ||
|
|
d8ab1d1146 | ||
|
|
03ad8363dc | ||
|
|
a2bd2773ca | ||
|
|
fccb58ad7d |
2
.gitmodules
vendored
2
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
|||||||
[submodule "assets"]
|
[submodule "assets"]
|
||||||
path = assets
|
path = assets
|
||||||
url = http://leonmmcoset.jjxmm.win:2000/MiaoStars/cloudreve-assets.git
|
url = http://leonmmcoset.jjxmm.win:2000/leonmmcoset/leonpan-assets.git
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package constants
|
|||||||
var BackendVersion = "4.7.0"
|
var BackendVersion = "4.7.0"
|
||||||
|
|
||||||
// IsPro 是否为Pro版本
|
// IsPro 是否为Pro版本
|
||||||
var IsPro = "false"
|
var IsPro = "true"
|
||||||
|
|
||||||
var IsProBool = IsPro == "true"
|
var IsProBool = IsPro == "true"
|
||||||
|
|
||||||
|
|||||||
2
assets
2
assets
Submodule assets updated: 921570f229...84cbf588e0
@@ -70,10 +70,18 @@ func (c *settingClient) Gets(ctx context.Context, names []string) (map[string]st
|
|||||||
|
|
||||||
func (c *settingClient) Set(ctx context.Context, settings map[string]string) error {
|
func (c *settingClient) Set(ctx context.Context, settings map[string]string) error {
|
||||||
for k, v := range settings {
|
for k, v := range settings {
|
||||||
if err := c.client.Setting.Update().Where(setting.Name(k)).SetValue(v).Exec(ctx); err != nil {
|
// 尝试更新现有记录
|
||||||
return fmt.Errorf("failed to create setting %q: %w", k, err)
|
affected, err := c.client.Setting.Update().Where(setting.Name(k)).SetValue(v).Save(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("failed to update setting %q: %w", k, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果没有记录被更新,创建新记录
|
||||||
|
if affected == 0 {
|
||||||
|
if err := c.client.Setting.Create().SetName(k).SetValue(v).Exec(ctx); err != nil {
|
||||||
|
return fmt.Errorf("failed to create setting %q: %w", k, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
3
pkg/cache/driver_test.go
vendored
3
pkg/cache/driver_test.go
vendored
@@ -1,8 +1,9 @@
|
|||||||
package cache
|
package cache
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSet(t *testing.T) {
|
func TestSet(t *testing.T) {
|
||||||
|
|||||||
@@ -22,6 +22,10 @@ type (
|
|||||||
SiteBasic(ctx context.Context) *SiteBasic
|
SiteBasic(ctx context.Context) *SiteBasic
|
||||||
// PWA related settings
|
// PWA related settings
|
||||||
PWA(ctx context.Context) *PWASetting
|
PWA(ctx context.Context) *PWASetting
|
||||||
|
// AnnouncementEnabled returns true if announcement is enabled.
|
||||||
|
AnnouncementEnabled(ctx context.Context) bool
|
||||||
|
// Announcement returns the site announcement content.
|
||||||
|
Announcement(ctx context.Context) string
|
||||||
// RegisterEnabled returns true if public sign-up is enabled.
|
// RegisterEnabled returns true if public sign-up is enabled.
|
||||||
RegisterEnabled(ctx context.Context) bool
|
RegisterEnabled(ctx context.Context) bool
|
||||||
// AuthnEnabled returns true if Webauthn is enabled.
|
// AuthnEnabled returns true if Webauthn is enabled.
|
||||||
@@ -776,6 +780,16 @@ func (s *settingProvider) PWA(ctx context.Context) *PWASetting {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AnnouncementEnabled returns true if announcement is enabled.
|
||||||
|
func (s *settingProvider) AnnouncementEnabled(ctx context.Context) bool {
|
||||||
|
return s.getBoolean(ctx, "announcement_enabled", false)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Announcement returns the site announcement content.
|
||||||
|
func (s *settingProvider) Announcement(ctx context.Context) string {
|
||||||
|
return s.getString(ctx, "announcement", "")
|
||||||
|
}
|
||||||
|
|
||||||
func IsTrueValue(val string) bool {
|
func IsTrueValue(val string) bool {
|
||||||
return val == "1" || val == "true"
|
return val == "1" || val == "true"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,6 +90,15 @@ type GetStoragePolicyResponse struct {
|
|||||||
EntitiesSize int `json:"entities_size,omitempty"`
|
EntitiesSize int `json:"entities_size,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StoragePolicySpace 存储策略空间使用情况
|
||||||
|
type StoragePolicySpace struct {
|
||||||
|
ID int64 `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Used int64 `json:"used"`
|
||||||
|
Total int64 `json:"total"`
|
||||||
|
}
|
||||||
|
|
||||||
type ListNodeResponse struct {
|
type ListNodeResponse struct {
|
||||||
Pagination *inventory.PaginationResults `json:"pagination"`
|
Pagination *inventory.PaginationResults `json:"pagination"`
|
||||||
Nodes []*ent.Node `json:"nodes"`
|
Nodes []*ent.Node `json:"nodes"`
|
||||||
@@ -115,9 +124,10 @@ type ListGroupResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type HomepageSummary struct {
|
type HomepageSummary struct {
|
||||||
MetricsSummary *MetricsSummary `json:"metrics_summary"`
|
MetricsSummary *MetricsSummary `json:"metrics_summary"`
|
||||||
SiteURls []string `json:"site_urls"`
|
SiteURls []string `json:"site_urls"`
|
||||||
Version *Version `json:"version"`
|
Version *Version `json:"version"`
|
||||||
|
StoragePolicies []*StoragePolicySpace `json:"storage_policies"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MetricsSummary struct {
|
type MetricsSummary struct {
|
||||||
|
|||||||
@@ -93,6 +93,34 @@ func (s *SummaryService) Summary(c *gin.Context) (*HomepageSummary, error) {
|
|||||||
SiteURls: lo.Map(dep.SettingProvider().AllSiteURLs(c), func(item *url.URL, index int) string {
|
SiteURls: lo.Map(dep.SettingProvider().AllSiteURLs(c), func(item *url.URL, index int) string {
|
||||||
return item.String()
|
return item.String()
|
||||||
}),
|
}),
|
||||||
|
StoragePolicies: make([]*StoragePolicySpace, 0),
|
||||||
|
}
|
||||||
|
|
||||||
|
// 无论是否从缓存加载或生成新统计,都需要获取存储策略空间使用情况
|
||||||
|
policyClient := dep.StoragePolicyClient()
|
||||||
|
policyResult, policyErr := policyClient.ListPolicies(c, &inventory.ListPolicyParameters{
|
||||||
|
PaginationArgs: &inventory.PaginationArgs{PageSize: 1000, Page: 0}, // 获取所有策略
|
||||||
|
})
|
||||||
|
if policyErr == nil {
|
||||||
|
// 收集存储策略空间使用情况
|
||||||
|
res.StoragePolicies = make([]*StoragePolicySpace, 0, len(policyResult.Policies))
|
||||||
|
entityClient := dep.FileClient()
|
||||||
|
|
||||||
|
for _, policy := range policyResult.Policies {
|
||||||
|
// 获取该存储策略的已使用空间
|
||||||
|
_, usedSpace, err := entityClient.CountEntityByStoragePolicyID(c, policy.ID)
|
||||||
|
if err != nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
res.StoragePolicies = append(res.StoragePolicies, &StoragePolicySpace{
|
||||||
|
ID: int64(policy.ID),
|
||||||
|
Name: policy.Name,
|
||||||
|
Type: policy.Type,
|
||||||
|
Used: int64(usedSpace),
|
||||||
|
Total: int64(policy.MaxSize), // 确保类型一致
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if summary, ok := kv.Get(MetricCacheKey); ok {
|
if summary, ok := kv.Get(MetricCacheKey); ok {
|
||||||
|
|||||||
@@ -60,6 +60,10 @@ type SiteConfig struct {
|
|||||||
// App settings
|
// App settings
|
||||||
AppPromotion bool `json:"app_promotion,omitempty"`
|
AppPromotion bool `json:"app_promotion,omitempty"`
|
||||||
|
|
||||||
|
// Announcement settings
|
||||||
|
AnnouncementEnabled bool `json:"announcement_enabled,omitempty"`
|
||||||
|
Announcement string `json:"announcement,omitempty"`
|
||||||
|
|
||||||
//EmailActive bool `json:"emailActive"`
|
//EmailActive bool `json:"emailActive"`
|
||||||
//QQLogin bool `json:"QQLogin"`
|
//QQLogin bool `json:"QQLogin"`
|
||||||
//ScoreEnabled bool `json:"score_enabled"`
|
//ScoreEnabled bool `json:"score_enabled"`
|
||||||
@@ -183,22 +187,24 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
|
|||||||
customNavItems := settings.CustomNavItems(c)
|
customNavItems := settings.CustomNavItems(c)
|
||||||
customHTML := settings.CustomHTML(c)
|
customHTML := settings.CustomHTML(c)
|
||||||
return &SiteConfig{
|
return &SiteConfig{
|
||||||
InstanceID: siteBasic.ID,
|
InstanceID: siteBasic.ID,
|
||||||
SiteName: siteBasic.Name,
|
SiteName: siteBasic.Name,
|
||||||
Themes: themes.Themes,
|
Themes: themes.Themes,
|
||||||
DefaultTheme: themes.DefaultTheme,
|
DefaultTheme: themes.DefaultTheme,
|
||||||
User: &userRes,
|
User: &userRes,
|
||||||
Logo: logo.Normal,
|
Logo: logo.Normal,
|
||||||
LogoLight: logo.Light,
|
LogoLight: logo.Light,
|
||||||
CaptchaType: settings.CaptchaType(c),
|
CaptchaType: settings.CaptchaType(c),
|
||||||
TurnstileSiteID: settings.TurnstileCaptcha(c).Key,
|
TurnstileSiteID: settings.TurnstileCaptcha(c).Key,
|
||||||
ReCaptchaKey: reCaptcha.Key,
|
ReCaptchaKey: reCaptcha.Key,
|
||||||
CapInstanceURL: capCaptcha.InstanceURL,
|
CapInstanceURL: capCaptcha.InstanceURL,
|
||||||
CapSiteKey: capCaptcha.SiteKey,
|
CapSiteKey: capCaptcha.SiteKey,
|
||||||
CapAssetServer: capCaptcha.AssetServer,
|
CapAssetServer: capCaptcha.AssetServer,
|
||||||
AppPromotion: appSetting.Promotion,
|
AppPromotion: appSetting.Promotion,
|
||||||
CustomNavItems: customNavItems,
|
CustomNavItems: customNavItems,
|
||||||
CustomHTML: customHTML,
|
CustomHTML: customHTML,
|
||||||
|
AnnouncementEnabled: settings.AnnouncementEnabled(c),
|
||||||
|
Announcement: settings.Announcement(c),
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user