Compare commits

40 Commits
0.0.1 ... main

Author SHA1 Message Date
Leonmmcoset
b3422b1884 Merge branch 'main' of http://leonmmcoset.jjxmm.win:2000/LeonMMcoset/leonpan 2025-11-04 18:40:35 +08:00
Leonmmcoset
34b1831a62 assets 2025-11-04 18:40:34 +08:00
5668469665 change leonpan-assets‘s address 2025-10-30 12:29:31 +00:00
Leonmmcoset
33bdd1418f assets 2025-10-26 21:31:29 +08:00
Leonmmcoset
37173601a9 assets 2025-10-26 21:04:21 +08:00
Leonmmcoset
080e90a45d assets 2025-10-26 20:50:14 +08:00
Leonmmcoset
0bbc1ccab8 assets 2025-10-26 20:24:57 +08:00
Leonmmcoset
77f55c78cf assets 2025-10-25 18:05:29 +08:00
Leonmmcoset
ef40619a38 assets 2025-10-25 17:42:51 +08:00
Leonmmcoset
5b2692a1ff assers 2025-10-25 09:59:39 +08:00
Leonmmcoset
583ad038e6 assets 2025-10-24 23:35:19 +08:00
Leonmmcoset
d0774c5f20 assets 2025-10-24 23:14:30 +08:00
Leonmmcoset
e992ac3274 assets 2025-10-24 22:54:58 +08:00
Leonmmcoset
779596bfbb assets 2025-10-24 22:32:14 +08:00
Leonmmcoset
d29aa05959 awa 2025-10-24 22:18:41 +08:00
Leonmmcoset
298718a468 assets 2025-10-24 22:05:13 +08:00
Leonmmcoset
11760e8acd test ispro 2025-10-24 22:04:41 +08:00
Leonmmcoset
6884dc678d assets 2025-10-24 21:42:23 +08:00
Leonmmcoset
5004011f46 assets 2025-10-24 21:01:57 +08:00
Leonmmcoset
99b147ad6e fix 2025-10-24 20:32:52 +08:00
Leonmmcoset
55f9c45c93 fix 2025-10-24 20:22:11 +08:00
Leonmmcoset
9f130cb50f backend update 2025-10-24 20:11:17 +08:00
Leonmmcoset
59dc910bc3 assets 2025-10-23 21:07:59 +08:00
Leonmmcoset
b75e9c0590 assets 2025-10-23 20:56:11 +08:00
Leonmmcoset
7b7b19feaf assets 2025-10-23 20:36:04 +08:00
Leonmmcoset
2d299d347a assets 2025-10-23 20:26:01 +08:00
Leonmmcoset
4e08c20a0d assets 2025-10-23 20:18:25 +08:00
Leonmmcoset
868741ebe1 fix 2025-10-23 20:02:41 +08:00
Leonmmcoset
170b25bc2a assets 2025-10-22 22:20:12 +08:00
Leonmmcoset
b5b364a2b0 assets 2025-10-22 22:04:36 +08:00
Leonmmcoset
f03a45aa93 assets 2025-10-22 21:49:17 +08:00
Leonmmcoset
4504853f88 assets 2025-10-22 21:38:13 +08:00
Leonmmcoset
947b9f5476 assets 2025-10-22 21:27:00 +08:00
Leonmmcoset
d76485f903 fix error 2025-10-22 21:19:55 +08:00
Leonmmcoset
9fc4a406a1 assets 2025-10-22 21:13:37 +08:00
Leonmmcoset
d3a64c0a77 add anc 2025-10-22 21:10:46 +08:00
Leonmmcoset
d8ab1d1146 assets 2025-10-21 21:36:48 +08:00
Leonmmcoset
03ad8363dc assets 2025-10-21 21:27:47 +08:00
Leonmmcoset
a2bd2773ca assets 2025-10-21 21:16:10 +08:00
Leonmmcoset
fccb58ad7d assets 2025-10-21 20:54:01 +08:00
9 changed files with 93 additions and 26 deletions

2
.gitmodules vendored
View File

@@ -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

View File

@@ -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

Submodule assets updated: 921570f229...84cbf588e0

View File

@@ -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

View File

@@ -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) {

View File

@@ -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"
} }

View File

@@ -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"`
@@ -118,6 +127,7 @@ 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 {

View File

@@ -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 {

View File

@@ -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"`
@@ -199,6 +203,8 @@ func (s *GetSettingService) GetSiteConfig(c *gin.Context) (*SiteConfig, error) {
AppPromotion: appSetting.Promotion, AppPromotion: appSetting.Promotion,
CustomNavItems: customNavItems, CustomNavItems: customNavItems,
CustomHTML: customHTML, CustomHTML: customHTML,
AnnouncementEnabled: settings.AnnouncementEnabled(c),
Announcement: settings.Announcement(c),
}, nil }, nil
} }