Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64,linux/arm64
platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7
push: true
tags: |
${{ steps.tags.outputs.dockerTagWithVersion }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/verify-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
checkTargetBranch:
runs-on: ubuntu-latest
steps:
- uses: Vankka/pr-target-branch-action@v1.1
- uses: Vankka/pr-target-branch-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 3.3.0
- Feature[#935]: Web 新增登录功能
- Feature[#935]: Web 新增修改密码功能
- Feature: 镜像新增 linux/386 和 linux/arm/v7 架构
- Feature[#935]: 更新文档
- Feature: 更新开源协议为 GNU GPLv3
## 3.2.0
- Fix: 修复大会员大积分签到任务
- Fix: 修复大会员大积分的签到和浏览追番频道任务
Expand Down
695 changes: 674 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>
<PropertyGroup>
<Authors>Ray</Authors>
<Version>3.2.0</Version>
<Version>3.3.0</Version>
<NoWarn>$(NoWarn);CS1591;CS0436</NoWarn>
</PropertyGroup>
</Project>
23 changes: 16 additions & 7 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
- [4.1. Docker启动](#41-docker启动)
- [4.2. 其他指令参考](#42-其他指令参考)
- [4.3. 使用Watchtower更新容器](#43-使用watchtower更新容器)
- [5. 登录 Bili](#5-登录-bili)
- [6. 自己构建镜像(非必须)](#6-自己构建镜像非必须)
- [7. 其他](#7-其他)
- [5. 登录](#5-登录)
- [6. 添加 Bili 账号](#6-添加-bili-账号)
- [7. 自己构建镜像(非必须)](#7-自己构建镜像非必须)
- [8. 其他](#8-其他)

<!-- /TOC -->

## 1. 前期工作

```
Expand Down Expand Up @@ -130,15 +132,22 @@ docker run --rm \
bili_tool_web
```

## 5. 登录 Bili
## 5. 登录

- 默认用户:`admin`
- 默认密码:`BiliTool@2233`

首次登陆后,请到`Admin`页面修改密码。

## 6. 添加 Bili 账号

扫码进行登录
扫码进行账号添加

![trigger](../docs/imgs/web-trigger-login.png)

![login](../docs/imgs/docker-login.png)

## 6. 自己构建镜像(非必须)
## 7. 自己构建镜像(非必须)

目前我提供和维护的镜像:

Expand All @@ -153,7 +162,7 @@ docker run --rm \

`TARGET_NAME`为镜像名称和版本,可以自己起个名字

## 7. 其他
## 8. 其他

代码编译和发布环境: mcr.microsoft.com/dotnet/sdk:8.0

Expand Down
24 changes: 16 additions & 8 deletions podman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@

- [1. 前期工作](#1-前期工作)
- [1.1. Podman环境](#11-podman环境)
- [从Docker迁移](#从docker迁移)
- [1.2. 从Docker迁移](#12-从docker迁移)
- [2. 运行容器](#2-运行容器)
- [2.1. 极简版](#21-极简版)
- [2.2. 综合版](#22-综合版)
- [登录](#登录)
- [3. 自己构建镜像(非必须)](#3-自己构建镜像非必须)
- [4. 其他](#4-其他)
- [3. 登录](#3-登录)
- [4. 添加 Bili 账号](#4-添加-bili-账号)
- [5. 自己构建镜像(非必须)](#5-自己构建镜像非必须)
- [6. 其他](#6-其他)

<!-- /TOC -->

Expand Down Expand Up @@ -37,7 +38,7 @@ podman machine start
podman info
```

### 从Docker迁移
### 1.2. 从Docker迁移

Podman可以和Docker共存,命令也基本可以通用。

Expand Down Expand Up @@ -97,15 +98,22 @@ podman ps -a
podman exec -it bili bash
```

## 登录
## 3. 登录

- 默认用户:`admin`
- 默认密码:`BiliTool@2233`

首次登陆后,请到`Admin`页面修改密码。

## 4. 添加 Bili 账号

扫码进行登录。

![trigger](../docs/imgs/web-trigger-login.png)

![login](../docs/imgs/docker-login.png)

## 3. 自己构建镜像(非必须)
## 5. 自己构建镜像(非必须)

目前我提供和维护的镜像:`[zai7lou/bilibili_tool_web](https://hub.docker.com/repository/docker/zai7lou/bilibili_tool_web)`;

Expand All @@ -117,6 +125,6 @@ podman exec -it bili bash

`TARGET_NAME`为镜像名称和版本,可以自己起个名字

## 4. 其他
## 6. 其他

镜像使用的是docker仓库的镜像。
15 changes: 15 additions & 0 deletions src/Ray.BiliBiliTool.Domain/User.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Ray.BiliBiliTool.Domain;

[Table("bili_user")]
public class User
{
[Key]
public long Id { get; set; }
public required string Username { get; set; }
public required string PasswordHash { get; set; }
public required string Salt { get; set; }
public List<string> Roles { get; set; } = [];
}
17 changes: 17 additions & 0 deletions src/Ray.BiliBiliTool.Infrastructure.EF/BiliDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class BiliDbContext(IConfiguration config) : DbContext
{
public DbSet<ExecutionLog> ExecutionLogs { get; set; }
public DbSet<BiliLogs> BiliLogs { get; set; }
public DbSet<User> Users { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
Expand Down Expand Up @@ -69,6 +70,22 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.HasIndex(x => x.FireInstanceIdComputed) // 在计算列上创建索引
.HasDatabaseName("IX_Logs_FireInstanceIdComputed");
});

modelBuilder.Entity<User>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.Username).IsRequired().HasMaxLength(50);
entity.Property(e => e.PasswordHash).IsRequired();
entity.Property(e => e.Salt).IsRequired();
entity
.Property(e => e.Roles)
.HasConversion(
v => string.Join(',', v),
v => v.Split(',', StringSplitOptions.RemoveEmptyEntries).ToList()
);

entity.HasIndex(e => e.Username).IsUnique();
});
}

private void AddSqliteDateTimeOffsetSupport(ModelBuilder builder)
Expand Down
38 changes: 38 additions & 0 deletions src/Ray.BiliBiliTool.Infrastructure.EF/DbInitializer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore;
using Ray.BiliBiliTool.Domain;
using Ray.BiliBiliTool.Infrastructure.Helpers;

namespace Ray.BiliBiliTool.Infrastructure.EF;

public class DbInitializer(BiliDbContext context)
{
private const string DefaultUserName = "admin";
private const string DefaultPassword = "BiliTool@2233";

public async Task InitializeAsync()
{
await context.Database.MigrateAsync();

await InitUserAsync();
}

private async Task InitUserAsync()
{
if (await context.Users.AnyAsync())
{
return;
}

var (hash, salt) = PasswordHelper.HashPassword(DefaultPassword);
var adminUser = new User
{
Username = DefaultUserName,
PasswordHash = hash,
Salt = salt,
Roles = ["Administrator"],
};

context.Users.Add(adminUser);
await context.SaveChangesAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public static class ServiceCollectionExtension
public static IServiceCollection AddEF(this IServiceCollection services)
{
services.AddDbContextFactory<BiliDbContext>();
services.AddScoped<DbInitializer>();
return services;
}
}
Loading
Loading