feat: 画图台并发重构 + 品牌定制 + 用户备注 + provider/UI 多项修复
画图台(并发出图):
- 不再锁定 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>
This commit is contained in:
@@ -41,19 +41,12 @@ func (s *AdminReadService) Users(ctx context.Context) ([]model.User, map[string]
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
counts, err := s.events.UserSuccessCounts(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
for i := range users {
|
||||
meta := users[i].Notes
|
||||
_ = meta
|
||||
}
|
||||
stats, err := s.users.Stats(ctx)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
stats["generation_counts"] = counts
|
||||
// Per-user generation count now comes from the persistent users.generation_count
|
||||
// column (set in the handler from each user object), not a log COUNT.
|
||||
return users, stats, nil
|
||||
}
|
||||
|
||||
@@ -66,10 +59,6 @@ func (s *AdminReadService) ModelsView(ctx context.Context) ([]map[string]any, er
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
counts, err := s.events.ModelSuccessCounts(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]map[string]any, 0, len(items))
|
||||
for _, item := range items {
|
||||
out = append(out, map[string]any{
|
||||
@@ -89,7 +78,7 @@ func (s *AdminReadService) ModelsView(ctx context.Context) ([]map[string]any, er
|
||||
"max_reference_images": item.MaxReferenceImages,
|
||||
"reference_mode": item.ReferenceMode,
|
||||
"weight": item.Weight,
|
||||
"generation_count": counts[item.ID],
|
||||
"generation_count": item.GenerationCount,
|
||||
"created_at": item.CreatedAt,
|
||||
"updated_at": item.UpdatedAt,
|
||||
})
|
||||
@@ -97,12 +86,13 @@ func (s *AdminReadService) ModelsView(ctx context.Context) ([]map[string]any, er
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (s *AdminReadService) Logs(ctx context.Context, limit, offset int, kind, status string, since *time.Time, userID, excludeSource, source string, hasFile bool) ([]model.EventLog, int64, *repo.EventStats, error) {
|
||||
func (s *AdminReadService) Logs(ctx context.Context, limit, offset int, kind, status string, statuses []string, since *time.Time, userID, excludeSource, source string, hasFile bool) ([]model.EventLog, int64, *repo.EventStats, error) {
|
||||
items, total, err := s.events.List(ctx, repo.EventListFilter{
|
||||
Limit: limit,
|
||||
Offset: offset,
|
||||
Kind: kind,
|
||||
Status: status,
|
||||
Statuses: statuses,
|
||||
Since: since,
|
||||
UserID: userID,
|
||||
ExcludeSource: excludeSource,
|
||||
@@ -173,7 +163,7 @@ func (s *AdminReadService) Stats(ctx context.Context) (map[string]any, error) {
|
||||
func (s *AdminReadService) Dashboard(ctx context.Context) (map[string]any, error) {
|
||||
now := time.Now()
|
||||
dayCut := now.Add(-24 * time.Hour)
|
||||
weekCut := now.Add(-7 * 24 * time.Hour)
|
||||
weekCut := now.Add(-3 * 24 * time.Hour) // "week" key = last 3 days (per admin request)
|
||||
|
||||
day, err := s.events.WindowStats(ctx, dayCut)
|
||||
if err != nil {
|
||||
@@ -199,6 +189,12 @@ func (s *AdminReadService) Dashboard(ctx context.Context) (map[string]any, error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// All-time persistent counters (total/success/failed/image/video/api) — these
|
||||
// survive log retention/clearing, unlike the windowed day/week stats.
|
||||
lifetime, err := s.events.Counters(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Per-window top-N analytics so the frontend can toggle 24h / 7d without a
|
||||
// re-fetch (the lists are small — top 6 / top 5).
|
||||
@@ -263,6 +259,7 @@ func (s *AdminReadService) Dashboard(ctx context.Context) (map[string]any, error
|
||||
"dau": dau,
|
||||
"wau": wau,
|
||||
"hourly": hourly,
|
||||
"lifetime": lifetime,
|
||||
"analytics": map[string]any{
|
||||
"day": dayAnalytics,
|
||||
"week": weekAnalytics,
|
||||
|
||||
@@ -358,6 +358,12 @@ func (s *AppSettingsService) loadSMTPConfig(ctx context.Context) (SMTPConfig, er
|
||||
if err != nil {
|
||||
return SMTPConfig{}, err
|
||||
}
|
||||
// The verification-email subject uses the site title, e.g. "<title> 邮箱验证码".
|
||||
title, _ := s.settings.GetValue(ctx, "site.title")
|
||||
title = strings.TrimSpace(title)
|
||||
if title == "" {
|
||||
title = "Vivid"
|
||||
}
|
||||
return SMTPConfig{
|
||||
Host: current.Host,
|
||||
Port: current.Port,
|
||||
@@ -365,6 +371,7 @@ func (s *AppSettingsService) loadSMTPConfig(ctx context.Context) (SMTPConfig, er
|
||||
Password: password,
|
||||
FromAddr: current.FromAddr,
|
||||
UseTLS: current.UseTLS,
|
||||
Subject: title + " 邮箱验证码",
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,28 @@ func (s *SiteService) SetTitle(ctx context.Context, title string) (string, error
|
||||
return title, nil
|
||||
}
|
||||
|
||||
func (s *SiteService) get(ctx context.Context, key string) string {
|
||||
v, _ := s.settings.GetValue(ctx, key)
|
||||
return strings.TrimSpace(v)
|
||||
}
|
||||
|
||||
// Logo / Subtitle are admin-editable branding shown on the public site.
|
||||
func (s *SiteService) Logo(ctx context.Context) string { return s.get(ctx, "site.logo") }
|
||||
func (s *SiteService) Subtitle(ctx context.Context) string { return s.get(ctx, "site.subtitle") }
|
||||
|
||||
// SetBranding persists logo / subtitle (either may be empty).
|
||||
func (s *SiteService) SetBranding(ctx context.Context, logo, subtitle string) error {
|
||||
for k, v := range map[string]string{
|
||||
"site.logo": strings.TrimSpace(logo),
|
||||
"site.subtitle": strings.TrimSpace(subtitle),
|
||||
} {
|
||||
if err := s.settings.UpsertValue(ctx, k, v); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Contact is the admin-editable "联系我们" info shown in the public 关于 section.
|
||||
type Contact struct {
|
||||
QQ string `json:"qq"`
|
||||
|
||||
@@ -18,6 +18,7 @@ type SMTPConfig struct {
|
||||
Password string
|
||||
FromAddr string
|
||||
UseTLS bool
|
||||
Subject string // verification-code email subject (empty → default)
|
||||
}
|
||||
|
||||
type SMTPService struct{}
|
||||
@@ -35,7 +36,10 @@ func (s *SMTPService) SendCode(ctx context.Context, cfg SMTPConfig, to, code, pu
|
||||
if purpose == "reset" {
|
||||
action = "找回密码"
|
||||
}
|
||||
subject := "Vivid AI 邮箱验证码"
|
||||
subject := strings.TrimSpace(cfg.Subject)
|
||||
if subject == "" {
|
||||
subject = "Vivid AI 邮箱验证码"
|
||||
}
|
||||
body := fmt.Sprintf("你正在进行%s,验证码为:%s\n\n验证码 6 分钟内有效。", action, code)
|
||||
msg := buildSMTPMessage(cfg.FromAddr, to, subject, body)
|
||||
addr := net.JoinHostPort(cfg.Host, strconv.Itoa(cfg.Port))
|
||||
|
||||
@@ -906,6 +906,7 @@ func (s *TokenService) ImportGrokToken(ctx context.Context, ssoToken, tokenID st
|
||||
return item, nil
|
||||
}
|
||||
|
||||
|
||||
func (s *TokenService) checkPendingGrok(tokenID, ssoToken string) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
|
||||
@@ -495,6 +495,10 @@ func (s *V1Service) prepareImageExecution(ctx context.Context, principal *APIPri
|
||||
if err := s.events.UpdateStatus(ctx, eventID, "success", "", elapsedMS); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_ = s.models.IncrementGenerationCount(ctx, modelItem.ID)
|
||||
if principal != nil && principal.User != nil {
|
||||
_ = s.users.IncrementGenerationCount(ctx, principal.User.ID)
|
||||
}
|
||||
if charge {
|
||||
_ = s.maybeGrantInviteReward(ctx, principal)
|
||||
}
|
||||
@@ -615,6 +619,10 @@ func (s *V1Service) prepareVideoExecution(ctx context.Context, principal *APIPri
|
||||
if err := s.events.UpdateStatus(ctx, eventID, "success", "", elapsedMS); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_ = s.models.IncrementGenerationCount(ctx, modelItem.ID)
|
||||
if principal != nil && principal.User != nil {
|
||||
_ = s.users.IncrementGenerationCount(ctx, principal.User.ID)
|
||||
}
|
||||
if charge {
|
||||
_ = s.maybeGrantInviteReward(ctx, principal)
|
||||
}
|
||||
@@ -710,6 +718,10 @@ func (s *V1Service) runVideoJob(ctx context.Context, principal *APIPrincipal, in
|
||||
if err := s.events.MarkVideoReady(ctx, eventID, videoURL, int(time.Since(startedAt).Milliseconds())); err != nil {
|
||||
return
|
||||
}
|
||||
_ = s.models.IncrementGenerationCount(ctx, modelItem.ID)
|
||||
if principal != nil && principal.User != nil {
|
||||
_ = s.users.IncrementGenerationCount(ctx, principal.User.ID)
|
||||
}
|
||||
_ = s.maybeGrantInviteReward(ctx, principal)
|
||||
}
|
||||
|
||||
@@ -2810,7 +2822,7 @@ func (s *V1Service) markTokenFailure(ctx context.Context, pool string, token mod
|
||||
// the cookie. chatgpt/runway/leonardo auth means the stored credential is
|
||||
// dead — a raw JWT (chatgpt/runway) or a cookie whose session no longer
|
||||
// authenticates (leonardo) — there's nothing left to refresh from.
|
||||
if pool == "chatgpt" || pool == "runway" || pool == "leonardo" || pool == "krea" || pool == "imagine" {
|
||||
if pool == "chatgpt" || pool == "runway" || pool == "leonardo" || pool == "krea" || pool == "imagine" || pool == "grok" {
|
||||
patch["status"] = "disabled"
|
||||
patch["dead"] = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user