fe3294ed60
- 新增UserAuth中间件用于验证用户登录状态和权限 - 移除Linux.do登录中的redirectUri和minimumTrustLevel配置项 - 修改Linux.do登录流程以支持动态构建回调URL - 将API v1接口组迁移至需要用户认证的路由 - 在远程AI服务调用中添加用户令牌认证 - 修复被封禁用户的认证检查逻辑 - 更新登录重定向函数以处理请求来源 - 添加RequestOrigin函数解析转发的主机和协议头
84 lines
2.3 KiB
Go
84 lines
2.3 KiB
Go
package model
|
|
|
|
import "encoding/json"
|
|
|
|
type SettingKey string
|
|
|
|
const (
|
|
SettingKeyPublic SettingKey = "public"
|
|
SettingKeyPrivate SettingKey = "private"
|
|
)
|
|
|
|
// ModelChannel 模型渠道配置。
|
|
type ModelChannel struct {
|
|
Protocol string `json:"protocol"`
|
|
Name string `json:"name"`
|
|
BaseURL string `json:"baseUrl"`
|
|
APIKey string `json:"apiKey"`
|
|
Models []string `json:"models"`
|
|
Weight int `json:"weight"`
|
|
Enabled bool `json:"enabled"`
|
|
Remark string `json:"remark"`
|
|
}
|
|
|
|
// PublicModelChannelSetting 公开模型渠道配置。
|
|
type PublicModelChannelSetting struct {
|
|
AvailableModels []string `json:"availableModels"`
|
|
DefaultModel string `json:"defaultModel"`
|
|
DefaultImageModel string `json:"defaultImageModel"`
|
|
DefaultVideoModel string `json:"defaultVideoModel"`
|
|
DefaultTextModel string `json:"defaultTextModel"`
|
|
SystemPrompt string `json:"systemPrompt"`
|
|
AllowCustomChannel *bool `json:"allowCustomChannel"`
|
|
}
|
|
|
|
// PublicSetting 公开配置。
|
|
type PublicSetting struct {
|
|
ModelChannel PublicModelChannelSetting `json:"modelChannel"`
|
|
Auth PublicAuthSetting `json:"auth"`
|
|
}
|
|
|
|
type PublicAuthSetting struct {
|
|
LinuxDo PublicLinuxDoAuthSetting `json:"linuxDo"`
|
|
}
|
|
|
|
type PublicLinuxDoAuthSetting struct {
|
|
Enabled bool `json:"enabled"`
|
|
}
|
|
|
|
// PrivateSetting 私有配置。
|
|
type PrivateSetting struct {
|
|
Channels []ModelChannel `json:"channels"`
|
|
PromptSync PromptSyncSetting `json:"promptSync"`
|
|
Auth PrivateAuthSetting `json:"auth"`
|
|
}
|
|
|
|
// PromptSyncSetting 提示词定时同步配置。
|
|
type PromptSyncSetting struct {
|
|
Enabled *bool `json:"enabled"`
|
|
Cron string `json:"cron"`
|
|
}
|
|
|
|
type PrivateAuthSetting struct {
|
|
LinuxDo PrivateLinuxDoAuthSetting `json:"linuxDo"`
|
|
}
|
|
|
|
type PrivateLinuxDoAuthSetting struct {
|
|
ClientID string `json:"clientId"`
|
|
ClientSecret string `json:"clientSecret"`
|
|
}
|
|
|
|
// Setting 系统配置。
|
|
type Setting struct {
|
|
Key SettingKey `json:"key" gorm:"primaryKey"`
|
|
Value json.RawMessage `json:"value" gorm:"serializer:json"`
|
|
CreatedAt string `json:"createdAt"`
|
|
UpdatedAt string `json:"updatedAt"`
|
|
}
|
|
|
|
// Settings 系统公开和私有配置。
|
|
type Settings struct {
|
|
Public PublicSetting `json:"public"`
|
|
Private PrivateSetting `json:"private"`
|
|
}
|