feat: 新增配置与提示词偏好页

后端新增 preferences 与 prompt_customizations 表及对应接口,
支持 BYOK 模型渠道密钥落库(仅回显掩码)与按任务类型定制
平台提示词模板;前端新增 /settings 页面及入口。
This commit is contained in:
tongtong committed 2026-09-21 14:29:54 +08:00
1 parent ae6cdf1551
commit b9df2f84ab
27 files changed
+1515 -22

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
package model
import "time"
// PreferenceID 当前没有用户体系,配置与偏好固定为一条全局记录。
const PreferenceID = "default"
// APIKeyConfig 用户自带的模型渠道(BYOK)。
// 密钥只落在本机数据库,对外输出时由 service 脱敏,不回传明文。
type APIKeyConfig struct {
ID string `json:"id"`
Provider string `json:"provider"`
Label string `json:"label"`
BaseURL string `json:"baseUrl"`
APIKey string `json:"apiKey"`
Model string `json:"model"`
Enabled bool `json:"enabled"`
}
// Preference 配置与用户偏好。
// 提示词定制单独存放,见 model.PromptCustomization 与 internal/prompts。
type Preference struct {
ID string `gorm:"primaryKey;size:32" json:"id"`
APIKeys []APIKeyConfig `gorm:"type:text;serializer:json" json:"apiKeys"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
+25
View File
@@ -0,0 +1,25 @@
package model
import "time"
// 提示词定制模式:跟随平台模板 / 在模板后追加要求 / 完全改写。
const (
PromptModeInherit = "inherit"
PromptModeAppend = "append"
PromptModeRewrite = "rewrite"
)
// PromptCustomization 用户对某个任务类型提示词的定制。
// 平台模板本身内置在 internal/prompts,只有定制需要落库;一个任务类型最多一条。
type PromptCustomization struct {
ID string `gorm:"primaryKey;size:64" json:"id"`
Operation string `gorm:"size:64;not null;uniqueIndex" json:"operation"`
Mode string `gorm:"size:16;not null" json:"mode"`
Content string `gorm:"type:text" json:"content"`
// BaseTemplateVersion 定制时依据的平台模板版本,用于判断定制是否已落后于平台更新。
BaseTemplateVersion int `json:"baseTemplateVersion"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}