- 新增 VideoThumbnailService,基于 ffmpeg 截取视频缩略图,ffprobe 提取时长
- 新增 ManagedThumbnailMap 模型及多数据库迁移,存储缩略图元数据
- 新增 /api/thumbnails/{id} 缩略图流端点
- 新增最近添加/最近播放 API 与前端面板,支持列表/网格双视图切换
- FileRecordDto 扩展 thumbnailUrl、videoDuration、lastPlayedAt 字段
- 前端新增文件库 Tab 导航、卡片网格视图、视频海报与时长信息栏
- 添加文件库目录不再同步全量扫描,改为后台异步自动扫描
101 lines
4.1 KiB
C#
101 lines
4.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace FileShare_EFCore.Migrations.PostgreSQL
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddThumbnailMap : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropColumn(
|
|
name: "thumbnail-path",
|
|
table: "managed-file-record");
|
|
|
|
migrationBuilder.AddColumn<int>(
|
|
name: "thumbnail-id",
|
|
table: "managed-file-record",
|
|
type: "integer",
|
|
nullable: true);
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "managed-thumbnail-map",
|
|
columns: table => new
|
|
{
|
|
id = table.Column<int>(type: "integer", nullable: false)
|
|
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
|
libraryrootid = table.Column<int>(name: "library-root-id", type: "integer", nullable: false),
|
|
relativepath = table.Column<string>(name: "relative-path", type: "character varying(1024)", maxLength: 1024, nullable: false),
|
|
contenttype = table.Column<string>(name: "content-type", type: "character varying(100)", maxLength: 100, nullable: false),
|
|
createdat = table.Column<DateTime>(name: "created-at", type: "timestamp with time zone", nullable: false),
|
|
updatedat = table.Column<DateTime>(name: "updated-at", type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("pk-managed-thumbnail-map", x => x.id);
|
|
table.ForeignKey(
|
|
name: "FK_managed-thumbnail-map_managed-library-root_library-root-id",
|
|
column: x => x.libraryrootid,
|
|
principalTable: "managed-library-root",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
},
|
|
comment: "文件缩略图映射记录");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "idx-managed-file-record-thumbnail-id",
|
|
table: "managed-file-record",
|
|
column: "thumbnail-id");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "idx-managed-thumbnail-map-relative-path",
|
|
table: "managed-thumbnail-map",
|
|
column: "relative-path",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "idx-managed-thumbnail-map-root-id",
|
|
table: "managed-thumbnail-map",
|
|
column: "library-root-id");
|
|
|
|
migrationBuilder.AddForeignKey(
|
|
name: "FK_managed-file-record_managed-thumbnail-map_thumbnail-id",
|
|
table: "managed-file-record",
|
|
column: "thumbnail-id",
|
|
principalTable: "managed-thumbnail-map",
|
|
principalColumn: "id",
|
|
onDelete: ReferentialAction.SetNull);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropForeignKey(
|
|
name: "FK_managed-file-record_managed-thumbnail-map_thumbnail-id",
|
|
table: "managed-file-record");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "managed-thumbnail-map");
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "idx-managed-file-record-thumbnail-id",
|
|
table: "managed-file-record");
|
|
|
|
migrationBuilder.DropColumn(
|
|
name: "thumbnail-id",
|
|
table: "managed-file-record");
|
|
|
|
migrationBuilder.AddColumn<string>(
|
|
name: "thumbnail-path",
|
|
table: "managed-file-record",
|
|
type: "character varying(512)",
|
|
maxLength: 512,
|
|
nullable: true);
|
|
}
|
|
}
|
|
}
|