feat: 文件搜索、视频续播与目录文件过滤
- 前端 Header 新增搜索栏,接入已有 SearchFiles API,结果支持列表/网格视图 - 新增 PlaybackPosition 数据库列与 /api/files/progress 端点,播放进度存服务端 - 播放中每 5 秒自动保存进度,再次打开视频时弹出"继续播放"提示 - 目录浏览新增媒体类型过滤条(全部/视频/音频/文本),前端即时过滤 - 新增 4 种数据库迁移(AddPlaybackPosition)
This commit is contained in:
parent
ff19f4759f
commit
6ef410fdfa
448
FileShare-EFCore/Migrations/MySQL/20260522092342_AddPlaybackPosition.Designer.cs
generated
Normal file
448
FileShare-EFCore/Migrations/MySQL/20260522092342_AddPlaybackPosition.Designer.cs
generated
Normal file
@ -0,0 +1,448 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FileShare_EFCore.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FileShare_EFCore.Migrations.MySQL
|
||||
{
|
||||
[DbContext(typeof(MySqlAppDataContext))]
|
||||
[Migration("20260522092342_AddPlaybackPosition")]
|
||||
partial class AddPlaybackPosition
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 64);
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ApiRefreshTokenEntity", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("Device")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnName("device");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("expires-at");
|
||||
|
||||
b.Property<string>("IpAddress")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("varchar(64)")
|
||||
.HasColumnName("ip-address");
|
||||
|
||||
b.Property<string>("ReplacedByTokenHash")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)")
|
||||
.HasColumnName("replaced-by-token-hash");
|
||||
|
||||
b.Property<DateTime?>("RevokedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("revoked-at");
|
||||
|
||||
b.Property<string>("TokenHash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("varchar(128)")
|
||||
.HasColumnName("token-hash");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user-id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-api-refresh-token");
|
||||
|
||||
b.HasIndex("TokenHash")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-api-refresh-token-hash");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("idx-api-refresh-token-user-id");
|
||||
|
||||
b.ToTable("api-refresh-token", t =>
|
||||
{
|
||||
t.HasComment("API refresh token");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<string>("AbsolutePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("varchar(2048)")
|
||||
.HasColumnName("absolute-path");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<bool>("Exists")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasColumnName("exists");
|
||||
|
||||
b.Property<string>("Extension")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("varchar(32)")
|
||||
.HasColumnName("extension");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(260)
|
||||
.HasColumnType("varchar(260)")
|
||||
.HasColumnName("file-name");
|
||||
|
||||
b.Property<DateTime?>("LastPlayedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("last-played-at");
|
||||
|
||||
b.Property<DateTime>("LastSeenAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("last-seen-at");
|
||||
|
||||
b.Property<DateTime>("LastWriteTimeUtc")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("last-write-time-utc");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("MediaType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("varchar(20)")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<double?>("PlaybackPosition")
|
||||
.HasColumnType("double")
|
||||
.HasColumnName("playback-position");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("varchar(1024)")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<long>("SizeBytes")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("size-bytes");
|
||||
|
||||
b.Property<int?>("ThumbnailId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("thumbnail-id");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.Property<double?>("VideoDuration")
|
||||
.HasColumnType("double")
|
||||
.HasColumnName("video-duration");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-file-record");
|
||||
|
||||
b.HasIndex("AbsolutePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-file-record-absolute-path");
|
||||
|
||||
b.HasIndex("LastPlayedAt")
|
||||
.HasDatabaseName("idx-managed-file-record-last-played-at");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-file-record-root-id");
|
||||
|
||||
b.HasIndex("ThumbnailId")
|
||||
.HasDatabaseName("idx-managed-file-record-thumbnail-id");
|
||||
|
||||
b.HasIndex("MediaType", "Exists")
|
||||
.HasDatabaseName("idx-managed-file-record-media-type-exists");
|
||||
|
||||
b.ToTable("managed-file-record", t =>
|
||||
{
|
||||
t.HasComment("文件库文件记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("DisplayName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnName("display-name");
|
||||
|
||||
b.Property<bool>("IsAvailable")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasDefaultValue(true)
|
||||
.HasColumnName("is-available");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("tinyint(1)")
|
||||
.HasColumnName("is-enabled");
|
||||
|
||||
b.Property<DateTime?>("LastScanCompletedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("last-scan-completed-at");
|
||||
|
||||
b.Property<string>("LastScanError")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("varchar(2000)")
|
||||
.HasColumnName("last-scan-error");
|
||||
|
||||
b.Property<DateTime?>("LastScanStartedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("last-scan-started-at");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("varchar(1024)")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("ScanIntervalMinutes")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("scan-interval-minutes");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-library-root");
|
||||
|
||||
b.HasIndex("Path")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-library-root-path");
|
||||
|
||||
b.ToTable("managed-library-root", t =>
|
||||
{
|
||||
t.HasComment("文件库根目录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("varchar(1024)")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-thumbnail-map");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-thumbnail-map-root-id");
|
||||
|
||||
b.HasIndex("RelativePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-thumbnail-map-relative-path");
|
||||
|
||||
b.ToTable("managed-thumbnail-map", t =>
|
||||
{
|
||||
t.HasComment("文件缩略图映射记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.UserEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id")
|
||||
.HasComment("用户主键");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnName("email")
|
||||
.HasComment("用户邮箱");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("varchar(100)")
|
||||
.HasColumnName("name")
|
||||
.HasComment("用户名称");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnName("password-hash")
|
||||
.HasComment("密码哈希值");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("varchar(50)")
|
||||
.HasColumnName("phone-number")
|
||||
.HasComment("电话号码");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-user");
|
||||
|
||||
b.ToTable("user", t =>
|
||||
{
|
||||
t.HasComment("用户实体,演示数据库 CRUD 操作");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.WeatherForecastEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id")
|
||||
.HasComment("天气预报主键");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("date")
|
||||
.HasComment("预报日期");
|
||||
|
||||
b.Property<string>("Summary")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("varchar(200)")
|
||||
.HasColumnName("summary")
|
||||
.HasComment("天气摘要");
|
||||
|
||||
b.Property<int>("TemperatureC")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("temperature-c")
|
||||
.HasComment("摄氏温度");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime(6)")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-weather-forecast");
|
||||
|
||||
b.ToTable("weather-forecast", t =>
|
||||
{
|
||||
t.HasComment("天气预报数据实体");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedThumbnailMap", "Thumbnail")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("ThumbnailId")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Thumbnails")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
|
||||
b.Navigation("Thumbnails");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FileShare_EFCore.Migrations.MySQL
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPlaybackPosition : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "playback-position",
|
||||
table: "managed-file-record",
|
||||
type: "double",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "playback-position",
|
||||
table: "managed-file-record");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,6 +140,10 @@ namespace FileShare_EFCore.Migrations.MySQL
|
||||
.HasColumnType("varchar(20)")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<double?>("PlaybackPosition")
|
||||
.HasColumnType("double")
|
||||
.HasColumnName("playback-position");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
|
||||
463
FileShare-EFCore/Migrations/PostgreSQL/20260522092330_AddPlaybackPosition.Designer.cs
generated
Normal file
463
FileShare-EFCore/Migrations/PostgreSQL/20260522092330_AddPlaybackPosition.Designer.cs
generated
Normal file
@ -0,0 +1,463 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FileShare_EFCore.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FileShare_EFCore.Migrations.PostgreSQL
|
||||
{
|
||||
[DbContext(typeof(PostgreSqlAppDataContext))]
|
||||
[Migration("20260522092330_AddPlaybackPosition")]
|
||||
partial class AddPlaybackPosition
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ApiRefreshTokenEntity", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("Device")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)")
|
||||
.HasColumnName("device");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("expires-at");
|
||||
|
||||
b.Property<string>("IpAddress")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)")
|
||||
.HasColumnName("ip-address");
|
||||
|
||||
b.Property<string>("ReplacedByTokenHash")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)")
|
||||
.HasColumnName("replaced-by-token-hash");
|
||||
|
||||
b.Property<DateTime?>("RevokedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("revoked-at");
|
||||
|
||||
b.Property<string>("TokenHash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)")
|
||||
.HasColumnName("token-hash");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("user-id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-api-refresh-token");
|
||||
|
||||
b.HasIndex("TokenHash")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-api-refresh-token-hash");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("idx-api-refresh-token-user-id");
|
||||
|
||||
b.ToTable("api-refresh-token", t =>
|
||||
{
|
||||
t.HasComment("API refresh token");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AbsolutePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("character varying(2048)")
|
||||
.HasColumnName("absolute-path");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<bool>("Exists")
|
||||
.HasColumnType("boolean")
|
||||
.HasColumnName("exists");
|
||||
|
||||
b.Property<string>("Extension")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)")
|
||||
.HasColumnName("extension");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(260)
|
||||
.HasColumnType("character varying(260)")
|
||||
.HasColumnName("file-name");
|
||||
|
||||
b.Property<DateTime?>("LastPlayedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("last-played-at");
|
||||
|
||||
b.Property<DateTime>("LastSeenAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("last-seen-at");
|
||||
|
||||
b.Property<DateTime>("LastWriteTimeUtc")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("last-write-time-utc");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("MediaType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("character varying(20)")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<double?>("PlaybackPosition")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("playback-position");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("character varying(1024)")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<long>("SizeBytes")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("size-bytes");
|
||||
|
||||
b.Property<int?>("ThumbnailId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("thumbnail-id");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.Property<double?>("VideoDuration")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("video-duration");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-file-record");
|
||||
|
||||
b.HasIndex("AbsolutePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-file-record-absolute-path");
|
||||
|
||||
b.HasIndex("LastPlayedAt")
|
||||
.HasDatabaseName("idx-managed-file-record-last-played-at");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-file-record-root-id");
|
||||
|
||||
b.HasIndex("ThumbnailId")
|
||||
.HasDatabaseName("idx-managed-file-record-thumbnail-id");
|
||||
|
||||
b.HasIndex("MediaType", "Exists")
|
||||
.HasDatabaseName("idx-managed-file-record-media-type-exists");
|
||||
|
||||
b.ToTable("managed-file-record", t =>
|
||||
{
|
||||
t.HasComment("文件库文件记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("DisplayName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)")
|
||||
.HasColumnName("display-name");
|
||||
|
||||
b.Property<bool>("IsAvailable")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("boolean")
|
||||
.HasDefaultValue(true)
|
||||
.HasColumnName("is-available");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("boolean")
|
||||
.HasColumnName("is-enabled");
|
||||
|
||||
b.Property<DateTime?>("LastScanCompletedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("last-scan-completed-at");
|
||||
|
||||
b.Property<string>("LastScanError")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("character varying(2000)")
|
||||
.HasColumnName("last-scan-error");
|
||||
|
||||
b.Property<DateTime?>("LastScanStartedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("last-scan-started-at");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("character varying(1024)")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("ScanIntervalMinutes")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("scan-interval-minutes");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-library-root");
|
||||
|
||||
b.HasIndex("Path")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-library-root-path");
|
||||
|
||||
b.ToTable("managed-library-root", t =>
|
||||
{
|
||||
t.HasComment("文件库根目录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("character varying(1024)")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-thumbnail-map");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-thumbnail-map-root-id");
|
||||
|
||||
b.HasIndex("RelativePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-thumbnail-map-relative-path");
|
||||
|
||||
b.ToTable("managed-thumbnail-map", t =>
|
||||
{
|
||||
t.HasComment("文件缩略图映射记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.UserEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasComment("用户主键");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)")
|
||||
.HasColumnName("email")
|
||||
.HasComment("用户邮箱");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("character varying(100)")
|
||||
.HasColumnName("name")
|
||||
.HasComment("用户名称");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)")
|
||||
.HasColumnName("password-hash")
|
||||
.HasComment("密码哈希值");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("character varying(50)")
|
||||
.HasColumnName("phone-number")
|
||||
.HasComment("电话号码");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-user");
|
||||
|
||||
b.ToTable("user", t =>
|
||||
{
|
||||
t.HasComment("用户实体,演示数据库 CRUD 操作");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.WeatherForecastEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("id")
|
||||
.HasComment("天气预报主键");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("date")
|
||||
.HasComment("预报日期");
|
||||
|
||||
b.Property<string>("Summary")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("character varying(200)")
|
||||
.HasColumnName("summary")
|
||||
.HasComment("天气摘要");
|
||||
|
||||
b.Property<int>("TemperatureC")
|
||||
.HasColumnType("integer")
|
||||
.HasColumnName("temperature-c")
|
||||
.HasComment("摄氏温度");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-weather-forecast");
|
||||
|
||||
b.ToTable("weather-forecast", t =>
|
||||
{
|
||||
t.HasComment("天气预报数据实体");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedThumbnailMap", "Thumbnail")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("ThumbnailId")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Thumbnails")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
|
||||
b.Navigation("Thumbnails");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FileShare_EFCore.Migrations.PostgreSQL
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPlaybackPosition : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "playback-position",
|
||||
table: "managed-file-record",
|
||||
type: "double precision",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "playback-position",
|
||||
table: "managed-file-record");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,6 +147,10 @@ namespace FileShare_EFCore.Migrations.PostgreSQL
|
||||
.HasColumnType("character varying(20)")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<double?>("PlaybackPosition")
|
||||
.HasColumnType("double precision")
|
||||
.HasColumnName("playback-position");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
|
||||
446
FileShare-EFCore/Migrations/SQLite/20260522092304_AddPlaybackPosition.Designer.cs
generated
Normal file
446
FileShare-EFCore/Migrations/SQLite/20260522092304_AddPlaybackPosition.Designer.cs
generated
Normal file
@ -0,0 +1,446 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FileShare_EFCore.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FileShare_EFCore.Migrations.SQLite
|
||||
{
|
||||
[DbContext(typeof(SqliteAppDataContext))]
|
||||
[Migration("20260522092304_AddPlaybackPosition")]
|
||||
partial class AddPlaybackPosition
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder.HasAnnotation("ProductVersion", "10.0.7");
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ApiRefreshTokenEntity", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("Device")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("device");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("expires-at");
|
||||
|
||||
b.Property<string>("IpAddress")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("ip-address");
|
||||
|
||||
b.Property<string>("ReplacedByTokenHash")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("replaced-by-token-hash");
|
||||
|
||||
b.Property<DateTime?>("RevokedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("revoked-at");
|
||||
|
||||
b.Property<string>("TokenHash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("token-hash");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("user-id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-api-refresh-token");
|
||||
|
||||
b.HasIndex("TokenHash")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-api-refresh-token-hash");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("idx-api-refresh-token-user-id");
|
||||
|
||||
b.ToTable("api-refresh-token", t =>
|
||||
{
|
||||
t.HasComment("API refresh token");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<string>("AbsolutePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("absolute-path");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<bool>("Exists")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("exists");
|
||||
|
||||
b.Property<string>("Extension")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("extension");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(260)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("file-name");
|
||||
|
||||
b.Property<DateTime?>("LastPlayedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-played-at");
|
||||
|
||||
b.Property<DateTime>("LastSeenAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-seen-at");
|
||||
|
||||
b.Property<DateTime>("LastWriteTimeUtc")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-write-time-utc");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("MediaType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<double?>("PlaybackPosition")
|
||||
.HasColumnType("REAL")
|
||||
.HasColumnName("playback-position");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<long>("SizeBytes")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("size-bytes");
|
||||
|
||||
b.Property<int?>("ThumbnailId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("thumbnail-id");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.Property<double?>("VideoDuration")
|
||||
.HasColumnType("REAL")
|
||||
.HasColumnName("video-duration");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-file-record");
|
||||
|
||||
b.HasIndex("AbsolutePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-file-record-absolute-path");
|
||||
|
||||
b.HasIndex("LastPlayedAt")
|
||||
.HasDatabaseName("idx-managed-file-record-last-played-at");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-file-record-root-id");
|
||||
|
||||
b.HasIndex("ThumbnailId")
|
||||
.HasDatabaseName("idx-managed-file-record-thumbnail-id");
|
||||
|
||||
b.HasIndex("MediaType", "Exists")
|
||||
.HasDatabaseName("idx-managed-file-record-media-type-exists");
|
||||
|
||||
b.ToTable("managed-file-record", t =>
|
||||
{
|
||||
t.HasComment("文件库文件记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("DisplayName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("display-name");
|
||||
|
||||
b.Property<bool>("IsAvailable")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasDefaultValue(true)
|
||||
.HasColumnName("is-available");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("is-enabled");
|
||||
|
||||
b.Property<DateTime?>("LastScanCompletedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-completed-at");
|
||||
|
||||
b.Property<string>("LastScanError")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-error");
|
||||
|
||||
b.Property<DateTime?>("LastScanStartedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("last-scan-started-at");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("ScanIntervalMinutes")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("scan-interval-minutes");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-library-root");
|
||||
|
||||
b.HasIndex("Path")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-library-root-path");
|
||||
|
||||
b.ToTable("managed-library-root", t =>
|
||||
{
|
||||
t.HasComment("文件库根目录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-thumbnail-map");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-thumbnail-map-root-id");
|
||||
|
||||
b.HasIndex("RelativePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-thumbnail-map-relative-path");
|
||||
|
||||
b.ToTable("managed-thumbnail-map", t =>
|
||||
{
|
||||
t.HasComment("文件缩略图映射记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.UserEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id")
|
||||
.HasComment("用户主键");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("email")
|
||||
.HasComment("用户邮箱");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("name")
|
||||
.HasComment("用户名称");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("password-hash")
|
||||
.HasComment("密码哈希值");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("phone-number")
|
||||
.HasComment("电话号码");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-user");
|
||||
|
||||
b.ToTable("user", t =>
|
||||
{
|
||||
t.HasComment("用户实体,演示数据库 CRUD 操作");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.WeatherForecastEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("id")
|
||||
.HasComment("天气预报主键");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("date")
|
||||
.HasComment("预报日期");
|
||||
|
||||
b.Property<string>("Summary")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("summary")
|
||||
.HasComment("天气摘要");
|
||||
|
||||
b.Property<int>("TemperatureC")
|
||||
.HasColumnType("INTEGER")
|
||||
.HasColumnName("temperature-c")
|
||||
.HasComment("摄氏温度");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-weather-forecast");
|
||||
|
||||
b.ToTable("weather-forecast", t =>
|
||||
{
|
||||
t.HasComment("天气预报数据实体");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedThumbnailMap", "Thumbnail")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("ThumbnailId")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Thumbnails")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
|
||||
b.Navigation("Thumbnails");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FileShare_EFCore.Migrations.SQLite
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPlaybackPosition : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "playback-position",
|
||||
table: "managed-file-record",
|
||||
type: "REAL",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "playback-position",
|
||||
table: "managed-file-record");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -138,6 +138,10 @@ namespace FileShare_EFCore.Migrations.SQLite
|
||||
.HasColumnType("TEXT")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<double?>("PlaybackPosition")
|
||||
.HasColumnType("REAL")
|
||||
.HasColumnName("playback-position");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
|
||||
463
FileShare-EFCore/Migrations/SqlServer/20260522092317_AddPlaybackPosition.Designer.cs
generated
Normal file
463
FileShare-EFCore/Migrations/SqlServer/20260522092317_AddPlaybackPosition.Designer.cs
generated
Normal file
@ -0,0 +1,463 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using FileShare_EFCore.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FileShare_EFCore.Migrations.SqlServer
|
||||
{
|
||||
[DbContext(typeof(SqlServerAppDataContext))]
|
||||
[Migration("20260522092317_AddPlaybackPosition")]
|
||||
partial class AddPlaybackPosition
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ApiRefreshTokenEntity", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("Device")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("device");
|
||||
|
||||
b.Property<DateTime>("ExpiresAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("expires-at");
|
||||
|
||||
b.Property<string>("IpAddress")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("nvarchar(64)")
|
||||
.HasColumnName("ip-address");
|
||||
|
||||
b.Property<string>("ReplacedByTokenHash")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("nvarchar(128)")
|
||||
.HasColumnName("replaced-by-token-hash");
|
||||
|
||||
b.Property<DateTime?>("RevokedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("revoked-at");
|
||||
|
||||
b.Property<string>("TokenHash")
|
||||
.IsRequired()
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("nvarchar(128)")
|
||||
.HasColumnName("token-hash");
|
||||
|
||||
b.Property<int>("UserId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("user-id");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-api-refresh-token");
|
||||
|
||||
b.HasIndex("TokenHash")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-api-refresh-token-hash");
|
||||
|
||||
b.HasIndex("UserId")
|
||||
.HasDatabaseName("idx-api-refresh-token-user-id");
|
||||
|
||||
b.ToTable("api-refresh-token", t =>
|
||||
{
|
||||
t.HasComment("API refresh token");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AbsolutePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(2048)
|
||||
.HasColumnType("nvarchar(2048)")
|
||||
.HasColumnName("absolute-path");
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<bool>("Exists")
|
||||
.HasColumnType("bit")
|
||||
.HasColumnName("exists");
|
||||
|
||||
b.Property<string>("Extension")
|
||||
.IsRequired()
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("nvarchar(32)")
|
||||
.HasColumnName("extension");
|
||||
|
||||
b.Property<string>("FileName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(260)
|
||||
.HasColumnType("nvarchar(260)")
|
||||
.HasColumnName("file-name");
|
||||
|
||||
b.Property<DateTime?>("LastPlayedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("last-played-at");
|
||||
|
||||
b.Property<DateTime>("LastSeenAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("last-seen-at");
|
||||
|
||||
b.Property<DateTime>("LastWriteTimeUtc")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("last-write-time-utc");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("MediaType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(20)
|
||||
.HasColumnType("nvarchar(20)")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<double?>("PlaybackPosition")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("playback-position");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("nvarchar(1024)")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<long>("SizeBytes")
|
||||
.HasColumnType("bigint")
|
||||
.HasColumnName("size-bytes");
|
||||
|
||||
b.Property<int?>("ThumbnailId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("thumbnail-id");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.Property<double?>("VideoDuration")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("video-duration");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-file-record");
|
||||
|
||||
b.HasIndex("AbsolutePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-file-record-absolute-path");
|
||||
|
||||
b.HasIndex("LastPlayedAt")
|
||||
.HasDatabaseName("idx-managed-file-record-last-played-at");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-file-record-root-id");
|
||||
|
||||
b.HasIndex("ThumbnailId")
|
||||
.HasDatabaseName("idx-managed-file-record-thumbnail-id");
|
||||
|
||||
b.HasIndex("MediaType", "Exists")
|
||||
.HasDatabaseName("idx-managed-file-record-media-type-exists");
|
||||
|
||||
b.ToTable("managed-file-record", t =>
|
||||
{
|
||||
t.HasComment("文件库文件记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<string>("DisplayName")
|
||||
.IsRequired()
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("display-name");
|
||||
|
||||
b.Property<bool>("IsAvailable")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bit")
|
||||
.HasDefaultValue(true)
|
||||
.HasColumnName("is-available");
|
||||
|
||||
b.Property<bool>("IsEnabled")
|
||||
.HasColumnType("bit")
|
||||
.HasColumnName("is-enabled");
|
||||
|
||||
b.Property<DateTime?>("LastScanCompletedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("last-scan-completed-at");
|
||||
|
||||
b.Property<string>("LastScanError")
|
||||
.HasMaxLength(2000)
|
||||
.HasColumnType("nvarchar(2000)")
|
||||
.HasColumnName("last-scan-error");
|
||||
|
||||
b.Property<DateTime?>("LastScanStartedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("last-scan-started-at");
|
||||
|
||||
b.Property<string>("Path")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("nvarchar(1024)")
|
||||
.HasColumnName("path");
|
||||
|
||||
b.Property<int>("ScanIntervalMinutes")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("scan-interval-minutes");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-library-root");
|
||||
|
||||
b.HasIndex("Path")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-library-root-path");
|
||||
|
||||
b.ToTable("managed-library-root", t =>
|
||||
{
|
||||
t.HasComment("文件库根目录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("ContentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)")
|
||||
.HasColumnName("content-type");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("created-at");
|
||||
|
||||
b.Property<int>("LibraryRootId")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("library-root-id");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
.HasColumnType("nvarchar(1024)")
|
||||
.HasColumnName("relative-path");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("updated-at");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-managed-thumbnail-map");
|
||||
|
||||
b.HasIndex("LibraryRootId")
|
||||
.HasDatabaseName("idx-managed-thumbnail-map-root-id");
|
||||
|
||||
b.HasIndex("RelativePath")
|
||||
.IsUnique()
|
||||
.HasDatabaseName("idx-managed-thumbnail-map-relative-path");
|
||||
|
||||
b.ToTable("managed-thumbnail-map", t =>
|
||||
{
|
||||
t.HasComment("文件缩略图映射记录");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.UserEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id")
|
||||
.HasComment("用户主键");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<string>("Email")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("email")
|
||||
.HasComment("用户邮箱");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.HasMaxLength(100)
|
||||
.HasColumnType("nvarchar(100)")
|
||||
.HasColumnName("name")
|
||||
.HasComment("用户名称");
|
||||
|
||||
b.Property<string>("PasswordHash")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("password-hash")
|
||||
.HasComment("密码哈希值");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(50)
|
||||
.HasColumnType("nvarchar(50)")
|
||||
.HasColumnName("phone-number")
|
||||
.HasComment("电话号码");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-user");
|
||||
|
||||
b.ToTable("user", t =>
|
||||
{
|
||||
t.HasComment("用户实体,演示数据库 CRUD 操作");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.WeatherForecastEntity", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("id")
|
||||
.HasComment("天气预报主键");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("created-at")
|
||||
.HasComment("创建时间");
|
||||
|
||||
b.Property<DateOnly>("Date")
|
||||
.HasColumnType("date")
|
||||
.HasColumnName("date")
|
||||
.HasComment("预报日期");
|
||||
|
||||
b.Property<string>("Summary")
|
||||
.HasMaxLength(200)
|
||||
.HasColumnType("nvarchar(200)")
|
||||
.HasColumnName("summary")
|
||||
.HasComment("天气摘要");
|
||||
|
||||
b.Property<int>("TemperatureC")
|
||||
.HasColumnType("int")
|
||||
.HasColumnName("temperature-c")
|
||||
.HasComment("摄氏温度");
|
||||
|
||||
b.Property<DateTime>("UpdatedAt")
|
||||
.HasColumnType("datetime2")
|
||||
.HasColumnName("updated-at")
|
||||
.HasComment("更新时间");
|
||||
|
||||
b.HasKey("Id")
|
||||
.HasName("pk-weather-forecast");
|
||||
|
||||
b.ToTable("weather-forecast", t =>
|
||||
{
|
||||
t.HasComment("天气预报数据实体");
|
||||
});
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedFileRecord", b =>
|
||||
{
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedThumbnailMap", "Thumbnail")
|
||||
.WithMany("Files")
|
||||
.HasForeignKey("ThumbnailId")
|
||||
.OnDelete(DeleteBehavior.SetNull);
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
|
||||
b.Navigation("Thumbnail");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.HasOne("FileShare_EFCore.Models.ManagedLibraryRoot", "LibraryRoot")
|
||||
.WithMany("Thumbnails")
|
||||
.HasForeignKey("LibraryRootId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("LibraryRoot");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedLibraryRoot", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
|
||||
b.Navigation("Thumbnails");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("FileShare_EFCore.Models.ManagedThumbnailMap", b =>
|
||||
{
|
||||
b.Navigation("Files");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FileShare_EFCore.Migrations.SqlServer
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddPlaybackPosition : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<double>(
|
||||
name: "playback-position",
|
||||
table: "managed-file-record",
|
||||
type: "float",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "playback-position",
|
||||
table: "managed-file-record");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,6 +147,10 @@ namespace FileShare_EFCore.Migrations.SqlServer
|
||||
.HasColumnType("nvarchar(20)")
|
||||
.HasColumnName("media-type");
|
||||
|
||||
b.Property<double?>("PlaybackPosition")
|
||||
.HasColumnType("float")
|
||||
.HasColumnName("playback-position");
|
||||
|
||||
b.Property<string>("RelativePath")
|
||||
.IsRequired()
|
||||
.HasMaxLength(1024)
|
||||
|
||||
@ -79,6 +79,10 @@ namespace FileShare_EFCore.Models
|
||||
[Column("last-played-at")]
|
||||
public DateTime? LastPlayedAt { get; set; }
|
||||
|
||||
/// <summary>视频播放位置(秒)。</summary>
|
||||
[Column("playback-position")]
|
||||
public double? PlaybackPosition { get; set; }
|
||||
|
||||
/// <summary>创建时间。</summary>
|
||||
[Column("created-at")]
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
|
||||
@ -77,6 +77,10 @@ namespace FileShare_Services.Endpoints
|
||||
.WithOpenApi("FileLibrary", "标记文件已播放。")
|
||||
.WithName("MarkFilePlayed");
|
||||
|
||||
endpoints.MapPost<IFileLibraryEndpointService, SaveFileProgressRequest>("api/files/progress", (service, request, _) => service.SaveFileProgressAsync(request))
|
||||
.WithOpenApi("FileLibrary", "保存文件播放进度。")
|
||||
.WithName("SaveFileProgress");
|
||||
|
||||
endpoints.MapGet<IFileLibraryEndpointService, FileQueryRequest>("api/files/detail", (service, request, _) => service.GetFileAsync(request))
|
||||
.WithOpenApi("FileLibrary", "查询文件详情。")
|
||||
.WithName("GetFileDetail");
|
||||
|
||||
@ -59,6 +59,13 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
public sealed record MarkFilePlayedRequest(
|
||||
[property: JsonPropertyName("id")] int Id);
|
||||
|
||||
/// <summary>
|
||||
/// 保存文件播放进度的请求。
|
||||
/// </summary>
|
||||
public sealed record SaveFileProgressRequest(
|
||||
[property: JsonPropertyName("id")] int Id,
|
||||
[property: JsonPropertyName("position")] double Position);
|
||||
|
||||
/// <summary>
|
||||
/// 分页搜索已扫描文件的请求。
|
||||
/// </summary>
|
||||
@ -121,7 +128,8 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
bool BrowserPlayable,
|
||||
string? ThumbnailUrl = null,
|
||||
double? VideoDuration = null,
|
||||
DateTime? LastPlayedAt = null);
|
||||
DateTime? LastPlayedAt = null,
|
||||
double? PlaybackPosition = null);
|
||||
|
||||
/// <summary>
|
||||
/// 浏览文件库目录结构的请求。
|
||||
|
||||
@ -101,6 +101,13 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
return ResponseHelper.Succeed();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<IApiResponse> SaveFileProgressAsync(SaveFileProgressRequest request)
|
||||
{
|
||||
await fileLibrary.SaveFileProgressAsync(request.Id, request.Position);
|
||||
return ResponseHelper.Succeed();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证文件 ID 是否有效,无效时抛出 <see cref="ArgumentException"/>。
|
||||
/// </summary>
|
||||
|
||||
@ -404,6 +404,17 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task SaveFileProgressAsync(int id, double position, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var record = await db.ManagedFileRecords.FindAsync([id], cancellationToken);
|
||||
if (record is not null)
|
||||
{
|
||||
record.PlaybackPosition = Math.Max(0, position);
|
||||
await db.SaveChangesAsync(cancellationToken);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 深度优先遍历目录树,枚举所有被 <see cref="MediaFileTypes"/> 支持的媒体文件路径。
|
||||
/// 遇到无权限的目录时跳过该分支继续遍历。
|
||||
@ -559,7 +570,8 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
MediaFileTypes.IsBrowserPlayable(file.Extension),
|
||||
file.ThumbnailId is null ? null : $"/api/thumbnails/{file.ThumbnailId}",
|
||||
file.VideoDuration,
|
||||
file.LastPlayedAt);
|
||||
file.LastPlayedAt,
|
||||
file.PlaybackPosition);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -98,5 +98,12 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
/// <param name="request">包含文件 ID 的请求。</param>
|
||||
/// <returns>API 响应。</returns>
|
||||
Task<IApiResponse> MarkFilePlayedAsync(MarkFilePlayedRequest request);
|
||||
|
||||
/// <summary>
|
||||
/// 保存文件播放进度位置。
|
||||
/// </summary>
|
||||
/// <param name="request">包含文件 ID 和播放位置的请求。</param>
|
||||
/// <returns>API 响应。</returns>
|
||||
Task<IApiResponse> SaveFileProgressAsync(SaveFileProgressRequest request);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,5 +113,13 @@ namespace FileShare_Services.Services.FileLibrary
|
||||
/// <param name="id">文件记录 ID。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
Task MarkFilePlayedAsync(int id, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// 保存文件的播放进度位置。
|
||||
/// </summary>
|
||||
/// <param name="id">文件记录 ID。</param>
|
||||
/// <param name="position">播放位置(秒)。</param>
|
||||
/// <param name="cancellationToken">取消令牌。</param>
|
||||
Task SaveFileProgressAsync(int id, double position, CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,6 +46,7 @@ export interface FileRecordDto {
|
||||
thumbnailUrl: string | null
|
||||
videoDuration: number | null
|
||||
lastPlayedAt: string | null
|
||||
playbackPosition: number | null
|
||||
}
|
||||
|
||||
export interface BrowseDirectoryResponse {
|
||||
@ -106,5 +107,7 @@ export const api = {
|
||||
request<FileRecordDto[]>(`files/recent${qs({ type, count })}`),
|
||||
markFilePlayed: (id: number) =>
|
||||
request('files/played', { method: 'POST', body: { id } }),
|
||||
saveFileProgress: (id: number, position: number) =>
|
||||
request('files/progress', { method: 'POST', body: { id, position } }),
|
||||
qrCode: () => request<{ url: string; qrCodeBase64: string }>('qrcode'),
|
||||
}
|
||||
|
||||
@ -392,6 +392,8 @@ a {
|
||||
.mobile-header-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
@ -944,6 +946,118 @@ a {
|
||||
background: #111827;
|
||||
}
|
||||
|
||||
/* Search */
|
||||
.search-form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
min-height: 34px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
padding: 4px 12px;
|
||||
font-size: 14px;
|
||||
background: var(--panel);
|
||||
color: var(--text);
|
||||
outline: none;
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.search-input:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.search-submit {
|
||||
flex: 0 0 auto;
|
||||
min-height: 34px;
|
||||
border-radius: 10px;
|
||||
padding: 4px 11px;
|
||||
color: #fff;
|
||||
background: var(--accent);
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.search-results-title {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
overflow-wrap: anywhere;
|
||||
color: var(--muted);
|
||||
font-size: 15px;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
/* Filter chips */
|
||||
.filter-chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.filter-chips button {
|
||||
min-height: 28px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 2px 10px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--muted);
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.filter-chips button.active {
|
||||
color: #fff;
|
||||
background: var(--accent);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
/* Resume banner */
|
||||
.resume-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
margin-top: 10px;
|
||||
border: 1px solid var(--accent);
|
||||
border-radius: 10px;
|
||||
padding: 10px 14px;
|
||||
background: #eef2ff;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: var(--accent-strong);
|
||||
}
|
||||
|
||||
.resume-banner-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.resume-yes,
|
||||
.resume-no {
|
||||
min-height: 30px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
padding: 4px 14px;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.resume-yes {
|
||||
color: #fff;
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
.resume-no {
|
||||
color: var(--muted);
|
||||
background: #f2f4f7;
|
||||
}
|
||||
|
||||
/* Recent files section */
|
||||
.recent-files {
|
||||
margin-top: 4px;
|
||||
@ -988,6 +1102,36 @@ a {
|
||||
.filter-row button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.mobile-header {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.mobile-header-actions {
|
||||
justify-content: flex-start;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.search-form {
|
||||
flex: 1 1 100%;
|
||||
order: -1;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.view-toggle-bar,
|
||||
.section-header {
|
||||
align-items: stretch;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.view-toggle {
|
||||
align-self: flex-start;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 900px) {
|
||||
|
||||
@ -23,6 +23,22 @@ const viewMode = ref<'list' | 'grid'>('list')
|
||||
|
||||
const qrModal = ref<InstanceType<typeof QrCodeModal> | null>(null)
|
||||
|
||||
// Search
|
||||
const searchQuery = ref('')
|
||||
const searchResults = ref<FileRecordDto[]>([])
|
||||
const searchLoading = ref(false)
|
||||
const isSearching = ref(false)
|
||||
|
||||
// File filter
|
||||
const filterType = ref<'all' | 'video' | 'audio' | 'text'>('all')
|
||||
|
||||
// Video resume
|
||||
const videoRef = ref<HTMLVideoElement | null>(null)
|
||||
const resumePosition = ref(0)
|
||||
const showResumePrompt = ref(false)
|
||||
const resumeRequested = ref(false)
|
||||
let lastPositionSave = 0
|
||||
|
||||
const activeRoots = computed(() => roots.value.filter((root) => root.isEnabled && root.isAvailable))
|
||||
const selectedRoot = computed(() => roots.value.find((root) => root.id === selectedFile.value?.libraryRootId))
|
||||
const currentBrowsePath = computed(() => browsePath.value.join('/'))
|
||||
@ -30,15 +46,21 @@ const currentBrowsePath = computed(() => browsePath.value.join('/'))
|
||||
const breadcrumbs = computed(() => {
|
||||
const root = roots.value.find((r) => r.id === rootId.value)
|
||||
const items = [{ label: root?.displayName ?? '文件库', path: '' }]
|
||||
for (let i = 0; i < browsePath.value.length; i++) {
|
||||
browsePath.value.forEach((label, index) => {
|
||||
items.push({
|
||||
label: browsePath.value[i],
|
||||
path: browsePath.value.slice(0, i + 1).join('/'),
|
||||
label,
|
||||
path: browsePath.value.slice(0, index + 1).join('/'),
|
||||
})
|
||||
}
|
||||
})
|
||||
return items
|
||||
})
|
||||
|
||||
const filteredFiles = computed(() => {
|
||||
if (!browseData.value) return []
|
||||
if (filterType.value === 'all') return browseData.value.files
|
||||
return browseData.value.files.filter((f) => f.mediaType === filterType.value)
|
||||
})
|
||||
|
||||
const selectedMediaUrl = computed(() => selectedFile.value ? api.mediaUrl(selectedFile.value.streamUrl) : '')
|
||||
const selectedThumbnailUrl = computed(() =>
|
||||
selectedFile.value?.thumbnailUrl ? api.thumbnailUrl(selectedFile.value.thumbnailUrl) : ''
|
||||
@ -158,11 +180,146 @@ async function enterSubdirectory(name: string) {
|
||||
await browseDirectory()
|
||||
}
|
||||
|
||||
function changeFilter(type: 'all' | 'video' | 'audio' | 'text') {
|
||||
filterType.value = type
|
||||
}
|
||||
|
||||
async function doSearch() {
|
||||
const keyword = searchQuery.value.trim()
|
||||
if (!keyword) return
|
||||
try {
|
||||
errorMessage.value = ''
|
||||
searchLoading.value = true
|
||||
isSearching.value = true
|
||||
const response = await api.searchFiles({ page: 1, pageSize: 48, keyword })
|
||||
searchResults.value = response.items
|
||||
} catch (error) {
|
||||
setError(error)
|
||||
} finally {
|
||||
searchLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function exitSearch() {
|
||||
isSearching.value = false
|
||||
searchQuery.value = ''
|
||||
searchResults.value = []
|
||||
}
|
||||
|
||||
function updatePlaybackPosition(id: number, position: number) {
|
||||
if (selectedFile.value?.id === id) {
|
||||
selectedFile.value.playbackPosition = position
|
||||
}
|
||||
|
||||
for (const files of [searchResults.value, recentFiles.value, browseData.value?.files]) {
|
||||
const file = files?.find((item) => item.id === id)
|
||||
if (file) {
|
||||
file.playbackPosition = position
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function saveVideoProgress(position?: number) {
|
||||
if (!selectedFile.value || selectedFile.value.mediaType !== 'video') return
|
||||
const video = videoRef.value
|
||||
if (!video) return
|
||||
|
||||
const nextPosition = position ?? Math.floor(video.currentTime)
|
||||
if (nextPosition < 0) return
|
||||
|
||||
const fileId = selectedFile.value.id
|
||||
api.saveFileProgress(fileId, nextPosition)
|
||||
.then(() => updatePlaybackPosition(fileId, nextPosition))
|
||||
.catch(() => {})
|
||||
}
|
||||
|
||||
function handleVideoTimeUpdate() {
|
||||
const video = videoRef.value
|
||||
if (!video || video.paused || video.currentTime === 0) return
|
||||
|
||||
const now = Date.now()
|
||||
if (now - lastPositionSave < 5000) return
|
||||
lastPositionSave = now
|
||||
saveVideoProgress()
|
||||
}
|
||||
|
||||
function handleVideoPause() {
|
||||
const video = videoRef.value
|
||||
if (!video || video.currentTime === 0 || video.ended) return
|
||||
saveVideoProgress()
|
||||
}
|
||||
|
||||
function handleVideoPlay() {
|
||||
seekToResumePosition()
|
||||
showResumePrompt.value = false
|
||||
}
|
||||
|
||||
function handleVideoEnded() {
|
||||
saveVideoProgress(0)
|
||||
}
|
||||
|
||||
function resetResume() {
|
||||
resumePosition.value = 0
|
||||
resumeRequested.value = false
|
||||
showResumePrompt.value = false
|
||||
}
|
||||
|
||||
function tryResume(file: FileRecordDto) {
|
||||
if (file.mediaType !== 'video' || !file.playbackPosition || file.playbackPosition <= 0) return
|
||||
resumePosition.value = file.playbackPosition
|
||||
resumeRequested.value = true
|
||||
showResumePrompt.value = true
|
||||
}
|
||||
|
||||
function seekToResumePosition() {
|
||||
const video = videoRef.value
|
||||
if (!video || !resumeRequested.value || resumePosition.value <= 0 || video.readyState < 1) return
|
||||
|
||||
const maxPosition = Number.isFinite(video.duration) && video.duration > 1
|
||||
? Math.max(0, video.duration - 1)
|
||||
: resumePosition.value
|
||||
video.currentTime = Math.min(resumePosition.value, maxPosition)
|
||||
resumeRequested.value = false
|
||||
}
|
||||
|
||||
function resumePlayback() {
|
||||
showResumePrompt.value = false
|
||||
resumeRequested.value = true
|
||||
seekToResumePosition()
|
||||
videoRef.value?.play().catch(() => {})
|
||||
}
|
||||
|
||||
function dismissResume() {
|
||||
if (videoRef.value) {
|
||||
videoRef.value.currentTime = 0
|
||||
}
|
||||
resetResume()
|
||||
}
|
||||
|
||||
async function selectSearchFile(file: FileRecordDto) {
|
||||
const relativeParts = file.relativePath.split(/[\\/]/).filter(Boolean)
|
||||
relativeParts.pop()
|
||||
|
||||
rootId.value = file.libraryRootId
|
||||
browsePath.value = relativeParts
|
||||
isBrowsingRoots.value = false
|
||||
activeTab.value = 'libraries'
|
||||
exitSearch()
|
||||
await browseDirectory()
|
||||
|
||||
await selectFile(browseData.value?.files.find((item) => item.id === file.id) ?? file)
|
||||
}
|
||||
|
||||
async function selectFile(file: FileRecordDto) {
|
||||
resetResume()
|
||||
lastPositionSave = 0
|
||||
selectedFile.value = file
|
||||
textPreview.value = null
|
||||
|
||||
if (file.mediaType === 'video' || file.mediaType === 'audio') {
|
||||
if (file.mediaType === 'video') {
|
||||
api.markFilePlayed(file.id).catch(() => {})
|
||||
tryResume(file)
|
||||
} else if (file.mediaType === 'audio') {
|
||||
api.markFilePlayed(file.id).catch(() => {})
|
||||
}
|
||||
|
||||
@ -203,6 +360,16 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="mobile-header-actions">
|
||||
<button v-if="!isBrowsingRoots" type="button" class="back-button" @click="backToRoots">返回</button>
|
||||
<button v-if="isSearching" type="button" class="back-button" @click="exitSearch">返回</button>
|
||||
<form class="search-form" @submit.prevent="doSearch">
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
type="search"
|
||||
placeholder="搜索文件..."
|
||||
class="search-input"
|
||||
/>
|
||||
<button type="submit" class="search-submit">搜索</button>
|
||||
</form>
|
||||
<button type="button" class="qr-button" title="生成二维码" @click="qrModal?.open()">二维码</button>
|
||||
<a href="/admin" class="admin-link">管理</a>
|
||||
</div>
|
||||
@ -211,7 +378,7 @@ onMounted(async () => {
|
||||
<p v-if="errorMessage" class="error-banner">{{ errorMessage }}</p>
|
||||
|
||||
<!-- Root tabs -->
|
||||
<nav v-if="isBrowsingRoots" class="root-tabs">
|
||||
<nav v-if="isBrowsingRoots && !isSearching" class="root-tabs">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ active: activeTab === 'recent-added' }"
|
||||
@ -229,8 +396,48 @@ onMounted(async () => {
|
||||
>文件库</button>
|
||||
</nav>
|
||||
|
||||
<!-- Search results -->
|
||||
<section v-if="isSearching" class="recent-files">
|
||||
<div class="view-toggle-bar">
|
||||
<h3 class="search-results-title">
|
||||
搜索"{{ searchQuery }}" {{ searchResults.length }} 个结果
|
||||
</h3>
|
||||
<div class="view-toggle">
|
||||
<button type="button" :class="{ active: viewMode === 'list' }" @click="viewMode = 'list'">列表</button>
|
||||
<button type="button" :class="{ active: viewMode === 'grid' }" @click="viewMode = 'grid'">网格</button>
|
||||
</div>
|
||||
</div>
|
||||
<p v-if="searchLoading" class="empty-state">搜索中...</p>
|
||||
<p v-else-if="searchResults.length === 0" class="empty-state">无匹配文件</p>
|
||||
<!-- Grid view -->
|
||||
<div v-else-if="viewMode === 'grid'" class="file-grid">
|
||||
<button v-for="file in searchResults" :key="file.id" class="file-card" type="button" @click="selectSearchFile(file)">
|
||||
<img v-if="file.thumbnailUrl" :src="api.thumbnailUrl(file.thumbnailUrl)" class="card-thumb" alt="" loading="lazy" />
|
||||
<div v-else class="card-thumb-placeholder">{{ file.mediaType }}</div>
|
||||
<div class="card-body">
|
||||
<strong>{{ file.fileName }}</strong>
|
||||
<small>
|
||||
{{ formatSize(file.sizeBytes) }}
|
||||
<template v-if="file.videoDuration"> · {{ formatDuration(file.videoDuration) }}</template>
|
||||
</small>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
<!-- List view -->
|
||||
<div v-else class="file-list">
|
||||
<button v-for="file in searchResults" :key="file.id" class="mobile-file" type="button" @click="selectSearchFile(file)">
|
||||
<img v-if="file.thumbnailUrl" :src="api.thumbnailUrl(file.thumbnailUrl)" class="file-thumb" alt="" loading="lazy" />
|
||||
<span v-else class="type-badge">{{ file.mediaType }}</span>
|
||||
<span>
|
||||
<strong>{{ file.fileName }}</strong>
|
||||
<small>{{ formatSize(file.sizeBytes) }}</small>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- Recently added / played files -->
|
||||
<section v-if="isBrowsingRoots && activeTab !== 'libraries'" class="recent-files">
|
||||
<section v-if="isBrowsingRoots && !isSearching && activeTab !== 'libraries'" class="recent-files">
|
||||
<div class="view-toggle-bar">
|
||||
<div></div>
|
||||
<div class="view-toggle">
|
||||
@ -302,7 +509,7 @@ onMounted(async () => {
|
||||
</section>
|
||||
|
||||
<!-- Library root tiles -->
|
||||
<section v-if="isBrowsingRoots && activeTab === 'libraries'" class="root-picker">
|
||||
<section v-if="isBrowsingRoots && !isSearching && activeTab === 'libraries'" class="root-picker">
|
||||
<button
|
||||
v-for="root in activeRoots"
|
||||
:key="root.id"
|
||||
@ -318,7 +525,7 @@ onMounted(async () => {
|
||||
</section>
|
||||
|
||||
<!-- Directory browser -->
|
||||
<template v-else-if="!isBrowsingRoots">
|
||||
<template v-else-if="!isBrowsingRoots && !isSearching">
|
||||
<!-- Breadcrumb -->
|
||||
<nav class="breadcrumb-nav">
|
||||
<template v-for="(crumb, index) in breadcrumbs" :key="crumb.path">
|
||||
@ -368,15 +575,30 @@ onMounted(async () => {
|
||||
<span>{{ selectedFile.contentType }}</span>
|
||||
</div>
|
||||
|
||||
<div v-if="showResumePrompt" class="resume-banner">
|
||||
<span>从 {{ formatDuration(resumePosition) }} 继续播放?</span>
|
||||
<div class="resume-banner-actions">
|
||||
<button type="button" class="resume-yes" @click="resumePlayback">继续</button>
|
||||
<button type="button" class="resume-no" @click="dismissResume">从头播放</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="player-media-wrapper">
|
||||
<video
|
||||
v-if="selectedFile.mediaType === 'video' && selectedFile.browserPlayable"
|
||||
ref="videoRef"
|
||||
:key="selectedFile.id"
|
||||
:poster="selectedThumbnailUrl || undefined"
|
||||
controls
|
||||
playsinline
|
||||
webkit-playsinline
|
||||
preload="metadata"
|
||||
@loadedmetadata="seekToResumePosition"
|
||||
@canplay="seekToResumePosition"
|
||||
@play="handleVideoPlay"
|
||||
@timeupdate="handleVideoTimeUpdate"
|
||||
@pause="handleVideoPause"
|
||||
@ended="handleVideoEnded"
|
||||
>
|
||||
<source :src="selectedMediaUrl" :type="selectedFile.contentType" />
|
||||
</video>
|
||||
@ -417,7 +639,12 @@ onMounted(async () => {
|
||||
<!-- Files -->
|
||||
<section v-if="browseData.files.length > 0" class="browse-section">
|
||||
<div class="section-header">
|
||||
<h3>文件</h3>
|
||||
<div class="filter-chips">
|
||||
<button type="button" :class="{ active: filterType === 'all' }" @click="changeFilter('all')">全部</button>
|
||||
<button type="button" :class="{ active: filterType === 'video' }" @click="changeFilter('video')">视频</button>
|
||||
<button type="button" :class="{ active: filterType === 'audio' }" @click="changeFilter('audio')">音频</button>
|
||||
<button type="button" :class="{ active: filterType === 'text' }" @click="changeFilter('text')">文本</button>
|
||||
</div>
|
||||
<div class="view-toggle">
|
||||
<button type="button" :class="{ active: viewMode === 'list' }" @click="viewMode = 'list'">列表</button>
|
||||
<button type="button" :class="{ active: viewMode === 'grid' }" @click="viewMode = 'grid'">网格</button>
|
||||
@ -427,7 +654,7 @@ onMounted(async () => {
|
||||
<!-- Grid view -->
|
||||
<div v-if="viewMode === 'grid'" class="file-grid">
|
||||
<button
|
||||
v-for="file in browseData.files"
|
||||
v-for="file in filteredFiles"
|
||||
:key="file.id"
|
||||
class="file-card"
|
||||
:class="{ active: selectedFile?.id === file.id }"
|
||||
@ -455,7 +682,7 @@ onMounted(async () => {
|
||||
<!-- List view -->
|
||||
<div v-else class="file-list">
|
||||
<button
|
||||
v-for="file in browseData.files"
|
||||
v-for="file in filteredFiles"
|
||||
:key="file.id"
|
||||
class="mobile-file"
|
||||
:class="{ active: selectedFile?.id === file.id }"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user