画图台(并发出图):
- 不再锁定 UI:点「生成」开独立任务,可连续多次并发
- 结果网格一行5个、最多10张,进行中/成功/失败状态回显,刷新保留进行中
- 生图张数 1/2/3/4,各自独立计费出卡
- 点图=参考图(单张替换/多张替换末位);首尾帧模型点视频=抓末帧设为首帧,否则放大
- /logs 新增 statuses=pending,success 服务端过滤(status IN 专用 SQL)
品牌定制(设置→网站):
- 自定义 Logo 图片 + 子标题(公开页头部 + 管理侧栏)
- 邮件验证码标题改用站点名:{title} 邮箱验证码
提示词复制:
- 去掉复制按钮,点提示词文字即复制(预览/后台日志/图片管理/画图记录),统一弹「指令已复制」
- 新增 utils/clipboard.js:execCommand 回退,非安全上下文(http/IP)也能复制
用户管理:列表加「备注」列,新建/编辑可填改备注(默认空)
provider 修复:
- grok 401 正确判死封号(markTokenFailure 漏了 grok 池)
- grok 视频支持 15s
- custom 上游报错去敏感(抹掉上游 URL/IP,改英文短描述)
- custom 去掉额度耗尽锁定:429/欠费当临时错误,账号保持 active
UI/其它:
- 展示位弹窗浅色主题适配(tab 选中高亮、输入框边框)— 主题变量 + 中心补丁
- 自定义模型:时长可填任意秒数 + 15s 预设
- 首页设置/卡密弹窗去固定高度与滚动条
- 顶部菜单「记录」→「图片」
- 下线 Flow provider(代码移除)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
78 lines
2.3 KiB
Go
78 lines
2.3 KiB
Go
package repo
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"backend/internal/model"
|
|
"gorm.io/datatypes"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type ModelRepository struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewModelRepository(db *gorm.DB) *ModelRepository {
|
|
return &ModelRepository{db: db}
|
|
}
|
|
|
|
// IncrementGenerationCount bumps a model's persistent success counter by 1.
|
|
// Best-effort: a missing model id is a no-op (0 rows affected, no error).
|
|
func (r *ModelRepository) IncrementGenerationCount(ctx context.Context, modelID string) error {
|
|
return r.db.WithContext(ctx).Model(&model.ModelConfig{}).
|
|
Where("id = ?", modelID).
|
|
UpdateColumn("generation_count", gorm.Expr("generation_count + 1")).Error
|
|
}
|
|
|
|
func (r *ModelRepository) List(ctx context.Context) ([]model.ModelConfig, error) {
|
|
var items []model.ModelConfig
|
|
// Higher weight floats to the top of the dropdown / admin list; ties fall
|
|
// back to newest-first so order stays stable for equal-weight models.
|
|
if err := r.db.WithContext(ctx).Order("weight desc, created_at desc").Find(&items).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
func (r *ModelRepository) Get(ctx context.Context, modelID string) (*model.ModelConfig, error) {
|
|
var item model.ModelConfig
|
|
if err := r.db.WithContext(ctx).First(&item, "id = ?", modelID).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &item, nil
|
|
}
|
|
|
|
func JSONStrings(v datatypes.JSON) []string {
|
|
if len(v) == 0 {
|
|
return []string{}
|
|
}
|
|
var out []string
|
|
if err := json.Unmarshal([]byte(v), &out); err == nil {
|
|
return out
|
|
}
|
|
return []string{}
|
|
}
|
|
|
|
func (r *ModelRepository) Create(ctx context.Context, item *model.ModelConfig) error {
|
|
return r.db.WithContext(ctx).Create(item).Error
|
|
}
|
|
|
|
func (r *ModelRepository) Update(ctx context.Context, modelID string, patch map[string]any) (*model.ModelConfig, error) {
|
|
patch["updated_at"] = time.Now()
|
|
if err := r.db.WithContext(ctx).Model(&model.ModelConfig{}).Where("id = ?", modelID).Updates(patch).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
var item model.ModelConfig
|
|
if err := r.db.WithContext(ctx).First(&item, "id = ?", modelID).Error; err != nil {
|
|
return nil, err
|
|
}
|
|
return &item, nil
|
|
}
|
|
|
|
func (r *ModelRepository) Delete(ctx context.Context, modelID string) (int64, error) {
|
|
res := r.db.WithContext(ctx).Delete(&model.ModelConfig{}, "id = ?", modelID)
|
|
return res.RowsAffected, res.Error
|
|
}
|