feat(*): 插件中心与模型协议 - 完善声明式协议运行时并增加功能开放控制
This commit is contained in:
1 parent
7cc6021f6e
commit
919037e5d9
106 files changed
+8816
-499
No files matched your search
@@ -14,19 +14,23 @@ import (
|
||||
const featureAvailabilitySettingKey = "feature_availability"
|
||||
|
||||
const (
|
||||
FeatureShortDrama = "shortDrama"
|
||||
FeatureTaskCenter = "taskCenter"
|
||||
FeatureCredits = "credits"
|
||||
FeatureCustomChannels = "customChannels"
|
||||
FeatureFrontendModels = "frontendModels"
|
||||
FeatureShortDrama = "shortDrama"
|
||||
FeatureTaskCenter = "taskCenter"
|
||||
FeatureCredits = "credits"
|
||||
FeatureCustomChannels = "customChannels"
|
||||
FeatureFrontendModels = "frontendModels"
|
||||
FeaturePluginCenter = "pluginCenter"
|
||||
FeatureSystemPlugins = "systemPluginsVisibleToUsers"
|
||||
)
|
||||
|
||||
type FeatureAvailability struct {
|
||||
ShortDramaEnabled bool `json:"shortDramaEnabled"`
|
||||
TaskCenterEnabled bool `json:"taskCenterEnabled"`
|
||||
CreditsEnabled bool `json:"creditsEnabled"`
|
||||
CustomChannelsEnabled bool `json:"customChannelsEnabled"`
|
||||
FrontendModelsEnabled bool `json:"frontendModelsEnabled"`
|
||||
ShortDramaEnabled bool `json:"shortDramaEnabled"`
|
||||
TaskCenterEnabled bool `json:"taskCenterEnabled"`
|
||||
CreditsEnabled bool `json:"creditsEnabled"`
|
||||
CustomChannelsEnabled bool `json:"customChannelsEnabled"`
|
||||
FrontendModelsEnabled bool `json:"frontendModelsEnabled"`
|
||||
PluginCenterEnabled bool `json:"pluginCenterEnabled"`
|
||||
SystemPluginsVisibleToUsers bool `json:"systemPluginsVisibleToUsers"`
|
||||
}
|
||||
|
||||
type PublicFeatureAvailability struct {
|
||||
@@ -39,7 +43,15 @@ type PublicFeatureAvailability struct {
|
||||
|
||||
func defaultFeatureAvailability() FeatureAvailability {
|
||||
// 缺少配置代表尚未由运维接管;前台模型需要明确配置后才开放。
|
||||
return FeatureAvailability{ShortDramaEnabled: true, TaskCenterEnabled: true, CreditsEnabled: true, CustomChannelsEnabled: true, FrontendModelsEnabled: false}
|
||||
return FeatureAvailability{
|
||||
ShortDramaEnabled: true,
|
||||
TaskCenterEnabled: true,
|
||||
CreditsEnabled: true,
|
||||
CustomChannelsEnabled: true,
|
||||
FrontendModelsEnabled: false,
|
||||
PluginCenterEnabled: true,
|
||||
SystemPluginsVisibleToUsers: true,
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Service) FeatureAvailability() (*PublicFeatureAvailability, error) {
|
||||
@@ -98,6 +110,10 @@ func (s *Service) FeatureEnabled(feature string) (bool, error) {
|
||||
return value.CustomChannelsEnabled, nil
|
||||
case FeatureFrontendModels:
|
||||
return value.FrontendModelsEnabled, nil
|
||||
case FeaturePluginCenter:
|
||||
return value.PluginCenterEnabled, nil
|
||||
case FeatureSystemPlugins:
|
||||
return value.SystemPluginsVisibleToUsers, nil
|
||||
default:
|
||||
return false, errors.New("未知功能开放配置")
|
||||
}
|
||||
@@ -122,6 +138,10 @@ func (s *Service) RequireFeature(feature string) error {
|
||||
return Forbidden("自定义渠道暂未开放")
|
||||
case FeatureFrontendModels:
|
||||
return Forbidden("前台模型目录暂未开放")
|
||||
case FeaturePluginCenter:
|
||||
return Forbidden("插件中心暂未开放")
|
||||
case FeatureSystemPlugins:
|
||||
return Forbidden("系统插件暂未向普通用户展示")
|
||||
default:
|
||||
return Forbidden("该功能暂未开放")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user