feat(*): 画布助手 - 新增 Live2D 配置导入与模型渲染支持
This commit is contained in:
1 parent
4f9e79f67f
commit
4e0b0a9256
40 files changed
+1668
-59
No files matched your search
@@ -31,7 +31,7 @@ const (
|
||||
)
|
||||
|
||||
const (
|
||||
appearanceSchemaVersion = 8
|
||||
appearanceSchemaVersion = 9
|
||||
appearanceLogoMaxBytes int64 = 5 << 20
|
||||
appearancePosterMaxBytes int64 = 10 << 20
|
||||
appearanceVideoMaxBytes int64 = 256 << 20
|
||||
@@ -48,6 +48,7 @@ const (
|
||||
)
|
||||
|
||||
type AppearanceSetting struct {
|
||||
Canvas CanvasAppearance `json:"canvas"`
|
||||
SchemaVersion int `json:"schemaVersion"`
|
||||
BrandName string `json:"brandName"`
|
||||
BrandSlug string `json:"brandSlug"`
|
||||
@@ -70,6 +71,7 @@ type AppearanceSetting struct {
|
||||
}
|
||||
|
||||
type PublicAppearanceSetting struct {
|
||||
Canvas CanvasAppearance `json:"canvas"`
|
||||
SchemaVersion int `json:"schemaVersion"`
|
||||
BrandName string `json:"brandName"`
|
||||
BrandSlug string `json:"brandSlug"`
|
||||
@@ -109,6 +111,7 @@ type AdminAppearanceSetting struct {
|
||||
|
||||
func defaultAppearanceSetting() AppearanceSetting {
|
||||
return AppearanceSetting{
|
||||
Canvas: defaultCanvasAppearance(),
|
||||
SchemaVersion: appearanceSchemaVersion,
|
||||
BrandName: defaultAppearanceBrandName,
|
||||
BrandSlug: defaultAppearanceBrandSlug,
|
||||
@@ -169,6 +172,11 @@ func (s *Service) UpdateAppearance(actor *model.User, value AppearanceSetting) (
|
||||
return nil, err
|
||||
}
|
||||
value.SchemaVersion = appearanceSchemaVersion
|
||||
canvas, canvasErr := normalizeCanvasAppearance(value.Canvas)
|
||||
if canvasErr != nil {
|
||||
return nil, canvasErr
|
||||
}
|
||||
value.Canvas = canvas
|
||||
value.BrandName = strings.TrimSpace(value.BrandName)
|
||||
value.BrandSlug = strings.ToLower(strings.TrimSpace(value.BrandSlug))
|
||||
value.AuthHeroTitle = normalizeAppearanceCopy(value.AuthHeroTitle)
|
||||
@@ -197,6 +205,13 @@ func (s *Service) UpdateAppearance(actor *model.User, value AppearanceSetting) (
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if value.Canvas.Live2DResourceID != "" {
|
||||
entry, err := s.validateLive2DResource(actor, value.Canvas.Live2DResourceID, before.Canvas.Live2DResourceID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
value.Canvas.Live2DEntry = entry
|
||||
}
|
||||
for _, candidate := range []struct {
|
||||
slot string
|
||||
resourceID string
|
||||
@@ -321,6 +336,7 @@ func (s *Service) appearanceResourceReferences(resourceIDs []string) map[string]
|
||||
{resourceID: value.DarkLogoResourceID, title: "深色模式品牌 Logo"},
|
||||
{resourceID: value.AuthVideoResourceID, title: "登录页品牌视频"},
|
||||
{resourceID: value.AuthVideoPosterResourceID, title: "登录页视频封面"},
|
||||
{resourceID: value.Canvas.Live2DResourceID, title: "画布 Agent Live2D 形象"},
|
||||
}
|
||||
wanted := make(map[string]struct{}, len(resourceIDs))
|
||||
for _, resourceID := range resourceIDs {
|
||||
@@ -615,6 +631,7 @@ func publicAppearanceSetting(setting *model.SystemSetting, value AppearanceSetti
|
||||
revision = strconv.FormatInt(setting.UpdatedAt.UTC().UnixNano(), 36)
|
||||
}
|
||||
result := &PublicAppearanceSetting{
|
||||
Canvas: value.Canvas,
|
||||
SchemaVersion: appearanceSchemaVersion,
|
||||
BrandName: value.BrandName,
|
||||
BrandSlug: value.BrandSlug,
|
||||
|
||||
Reference in new issue
Block a user