refactor: 彻底移除 Sora 视频生成模块(全栈清理)
Some checks failed
CI / test (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
Security Scan / backend-security (push) Has been cancelled
Security Scan / frontend-security (push) Has been cancelled

## 后端变更
- 删除 21 个 sora_*.go 服务文件(service/handler/repository/routes)
- 删除 Sora 相关 migration 文件(046/047/063/090)
- 清理 config 中的 sora_* 配置项和平台常量
- 清理 wire 依赖注入中的 Sora 组件
- 修复 wire_gen.go 语法错误(缺少逗号和闭合括号)
- 移除 go.mod 中的 go-sora2api 依赖
- 更新 ent schema usage_log.go 注释

## 前端变更
- 删除 SoraView、SoraAdminView 及 8 个 Sora 子组件
- 删除 sora API 层和路由配置
- 清理 UserEditModal 中的 Sora 存储配额 UI
- 清理 types/index.ts 中 Sora 相关类型定义
- 清理 stores/app.ts 默认配置
- 清理 i18n 翻译文件 en.ts/zh.ts (~110 行)
- 更新相关测试文件

## 文档更新
- README.md / README_CN.md / README_JA.md: 移除 Sora 状态说明和配置段落
- PROJECT_DIFF.md: 移除 Sora 相关差异描述

## 验证结果
-  Go 编译通过 (go build ./...)
-  TypeScript 类型检查通过 (vue-tsc --noEmit)
-  后端测试全通过 (0 failures)
-  前端测试全通过 (59 files, 329 tests, 0 failures)
-  前端生产构建成功 (23.81s)
This commit is contained in:
2026-05-10 14:15:45 +08:00
parent 1da074cfd6
commit 0e057904e6
96 changed files with 726 additions and 20525 deletions

View File

@@ -1,6 +1,6 @@
-- Migration: 045_add_accounts_extra_index
-- 为 accounts.extra 字段添加 GIN 索引,优化 FindByExtraField 查询性能
-- 用于支持通过 extra 字段中的 linked_openai_account_id 快速查找关联的 Sora 账号
-- 用于支持通过 extra 字段中的 linked_openai_account_id 快速查找关联的账号
CREATE INDEX IF NOT EXISTS idx_accounts_extra_gin
ON accounts USING GIN (extra);
@@ -8,6 +8,5 @@ ON accounts USING GIN (extra);
-- 查询示例(使用 @> 操作符)
-- EXPLAIN ANALYZE
-- SELECT * FROM accounts
-- WHERE platform = 'sora'
-- AND extra @> '{"linked_openai_account_id": 123}'::jsonb
-- WHERE extra @> '{"linked_openai_account_id": 123}'::jsonb
-- AND deleted_at IS NULL;

View File

@@ -1,24 +0,0 @@
-- Migration: 046_add_sora_accounts
-- 新增 sora_accounts 扩展表,存储 Sora 账号的 OAuth 凭证
-- 与 accounts 主表形成双表结构:
-- - accounts: 统一账号管理和调度
-- - sora_accounts: Sora gateway 快速读取和资格校验
--
-- 设计说明:
-- - account_id 为主键,外键关联 accounts.id
-- - ON DELETE CASCADE 确保删除账号时自动清理扩展表
-- - access_token/refresh_token 与 accounts.credentials 保持同步
CREATE TABLE IF NOT EXISTS sora_accounts (
account_id BIGINT PRIMARY KEY,
access_token TEXT NOT NULL,
refresh_token TEXT NOT NULL,
session_token TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
CONSTRAINT fk_sora_accounts_account_id
FOREIGN KEY (account_id) REFERENCES accounts(id)
ON DELETE CASCADE
);
-- 索引说明:主键已自动创建唯一索引,无需额外创建 idx_sora_accounts_account_id

View File

@@ -1,11 +0,0 @@
-- Migration: 047_add_sora_pricing_and_media_type
-- 新增 Sora 按次计费字段与 usage_logs.media_type
ALTER TABLE groups
ADD COLUMN IF NOT EXISTS sora_image_price_360 decimal(20,8),
ADD COLUMN IF NOT EXISTS sora_image_price_540 decimal(20,8),
ADD COLUMN IF NOT EXISTS sora_video_price_per_request decimal(20,8),
ADD COLUMN IF NOT EXISTS sora_video_price_per_request_hd decimal(20,8);
ALTER TABLE usage_logs
ADD COLUMN IF NOT EXISTS media_type VARCHAR(16);

View File

@@ -1,56 +0,0 @@
-- Migration: 063_add_sora_client_tables
-- Sora 客户端功能所需的数据库变更:
-- 1. 新增 sora_generations 表:记录 Sora 客户端 UI 的生成历史
-- 2. users 表新增存储配额字段
-- 3. groups 表新增存储配额字段
-- ============================================================
-- 1. sora_generations 表(生成记录)
-- ============================================================
CREATE TABLE IF NOT EXISTS sora_generations (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
api_key_id BIGINT,
-- 生成参数
model VARCHAR(64) NOT NULL,
prompt TEXT NOT NULL DEFAULT '',
media_type VARCHAR(16) NOT NULL DEFAULT 'video', -- video / image
-- 结果
status VARCHAR(16) NOT NULL DEFAULT 'pending', -- pending / generating / completed / failed / cancelled
media_url TEXT NOT NULL DEFAULT '',
media_urls JSONB, -- 多图时的 URL 数组
file_size_bytes BIGINT NOT NULL DEFAULT 0,
storage_type VARCHAR(16) NOT NULL DEFAULT 'none', -- s3 / local / upstream / none
s3_object_keys JSONB, -- S3 object key 数组
-- 上游信息
upstream_task_id VARCHAR(128) NOT NULL DEFAULT '',
error_message TEXT NOT NULL DEFAULT '',
-- 时间
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
completed_at TIMESTAMPTZ
);
-- 按用户+时间查询(作品库列表、历史记录)
CREATE INDEX IF NOT EXISTS idx_sora_gen_user_created
ON sora_generations(user_id, created_at DESC);
-- 按用户+状态查询(恢复进行中任务)
CREATE INDEX IF NOT EXISTS idx_sora_gen_user_status
ON sora_generations(user_id, status);
-- ============================================================
-- 2. users 表新增 Sora 存储配额字段
-- ============================================================
ALTER TABLE users
ADD COLUMN IF NOT EXISTS sora_storage_quota_bytes BIGINT NOT NULL DEFAULT 0,
ADD COLUMN IF NOT EXISTS sora_storage_used_bytes BIGINT NOT NULL DEFAULT 0;
-- ============================================================
-- 3. groups 表新增 Sora 存储配额字段
-- ============================================================
ALTER TABLE groups
ADD COLUMN IF NOT EXISTS sora_storage_quota_bytes BIGINT NOT NULL DEFAULT 0;

View File

@@ -1,34 +0,0 @@
-- Migration: 090_drop_sora
-- Remove all Sora-related database objects.
-- Drops tables: sora_tasks, sora_generations, sora_accounts
-- Drops columns from: groups, users, usage_logs
-- ============================================================
-- 1. Drop Sora tables
-- ============================================================
DROP TABLE IF EXISTS sora_tasks;
DROP TABLE IF EXISTS sora_generations;
DROP TABLE IF EXISTS sora_accounts;
-- ============================================================
-- 2. Drop Sora columns from groups table
-- ============================================================
ALTER TABLE groups
DROP COLUMN IF EXISTS sora_image_price_360,
DROP COLUMN IF EXISTS sora_image_price_540,
DROP COLUMN IF EXISTS sora_video_price_per_request,
DROP COLUMN IF EXISTS sora_video_price_per_request_hd,
DROP COLUMN IF EXISTS sora_storage_quota_bytes;
-- ============================================================
-- 3. Drop Sora columns from users table
-- ============================================================
ALTER TABLE users
DROP COLUMN IF EXISTS sora_storage_quota_bytes,
DROP COLUMN IF EXISTS sora_storage_used_bytes;
-- ============================================================
-- 4. Drop Sora column from usage_logs table
-- ============================================================
ALTER TABLE usage_logs
DROP COLUMN IF EXISTS media_type;