- 新增 VideoThumbnailService,基于 ffmpeg 截取视频缩略图,ffprobe 提取时长
- 新增 ManagedThumbnailMap 模型及多数据库迁移,存储缩略图元数据
- 新增 /api/thumbnails/{id} 缩略图流端点
- 新增最近添加/最近播放 API 与前端面板,支持列表/网格双视图切换
- FileRecordDto 扩展 thumbnailUrl、videoDuration、lastPlayedAt 字段
- 前端新增文件库 Tab 导航、卡片网格视图、视频海报与时长信息栏
- 添加文件库目录不再同步全量扫描,改为后台异步自动扫描
96 lines
3.2 KiB
C#
96 lines
3.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
||
using System.ComponentModel.DataAnnotations;
|
||
using System.ComponentModel.DataAnnotations.Schema;
|
||
|
||
namespace FileShare_EFCore.Models
|
||
{
|
||
/// <summary>
|
||
/// 扫描入库的可在线查看文件。
|
||
/// </summary>
|
||
[Comment("文件库文件记录")]
|
||
[Table("managed-file-record")]
|
||
public class ManagedFileRecord
|
||
{
|
||
/// <summary>主键 ID。</summary>
|
||
[Key]
|
||
[Column("id")]
|
||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||
public int Id { get; set; }
|
||
|
||
/// <summary>所属根目录 ID。</summary>
|
||
[Column("library-root-id")]
|
||
public int LibraryRootId { get; set; }
|
||
|
||
/// <summary>文件名。</summary>
|
||
[Column("file-name")]
|
||
[MaxLength(260)]
|
||
public string FileName { get; set; } = string.Empty;
|
||
|
||
/// <summary>相对根目录路径。</summary>
|
||
[Column("relative-path")]
|
||
[MaxLength(1024)]
|
||
public string RelativePath { get; set; } = string.Empty;
|
||
|
||
/// <summary>服务器本机绝对路径。</summary>
|
||
[Column("absolute-path")]
|
||
[MaxLength(2048)]
|
||
public string AbsolutePath { get; set; } = string.Empty;
|
||
|
||
/// <summary>扩展名,小写并包含点。</summary>
|
||
[Column("extension")]
|
||
[MaxLength(32)]
|
||
public string Extension { get; set; } = string.Empty;
|
||
|
||
/// <summary>文件大小,字节。</summary>
|
||
[Column("size-bytes")]
|
||
public long SizeBytes { get; set; }
|
||
|
||
/// <summary>文件最后修改时间 UTC。</summary>
|
||
[Column("last-write-time-utc")]
|
||
public DateTime LastWriteTimeUtc { get; set; }
|
||
|
||
/// <summary>媒体类型:text、video、audio。</summary>
|
||
[Column("media-type")]
|
||
[MaxLength(20)]
|
||
public string MediaType { get; set; } = string.Empty;
|
||
|
||
/// <summary>MIME 类型。</summary>
|
||
[Column("content-type")]
|
||
[MaxLength(100)]
|
||
public string ContentType { get; set; } = "application/octet-stream";
|
||
|
||
/// <summary>文件是否仍存在。</summary>
|
||
[Column("exists")]
|
||
public bool Exists { get; set; } = true;
|
||
|
||
/// <summary>最近扫描时间。</summary>
|
||
[Column("last-seen-at")]
|
||
public DateTime LastSeenAt { get; set; } = DateTime.UtcNow;
|
||
|
||
/// <summary>视频缩略图路径(相对于 wwwroot)。</summary>
|
||
[Column("thumbnail-id")]
|
||
public int? ThumbnailId { get; set; }
|
||
|
||
/// <summary>视频时长(秒)。</summary>
|
||
[Column("video-duration")]
|
||
public double? VideoDuration { get; set; }
|
||
|
||
/// <summary>最近一次播放时间 UTC。</summary>
|
||
[Column("last-played-at")]
|
||
public DateTime? LastPlayedAt { get; set; }
|
||
|
||
/// <summary>创建时间。</summary>
|
||
[Column("created-at")]
|
||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||
|
||
/// <summary>更新时间。</summary>
|
||
[Column("updated-at")]
|
||
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
||
|
||
/// <summary>所属根目录。</summary>
|
||
public ManagedLibraryRoot? LibraryRoot { get; set; }
|
||
|
||
public ManagedThumbnailMap? Thumbnail { get; set; }
|
||
}
|
||
}
|