Skip to content

Commit

Permalink
Merge branch 'dev' into fix_startup_parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
baimaoshouerkong authored Feb 9, 2025
2 parents bd9d115 + e8db001 commit bb630f2
Show file tree
Hide file tree
Showing 79 changed files with 1,018 additions and 325 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/build-signed-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ jobs:
$xml.Package.Identity.Name = "37126GoldenPotato137.PotatoVN.sideload"
$xml.Package.Identity.Publisher = "${{ vars.PUBLISHER }}"
$xml.Save($manifestPath)
- name: Update app icon
shell: pwsh
run: |
xcopy "GalgameManager\Assets\Pictures\icon-sideload\*" "GalgameManager\Assets\" /s /e /y
echo "Updated app icon"
- name: Create the app package
run: |
Expand Down
15 changes: 15 additions & 0 deletions GalgameManager.Server/Controllers/UserController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ public async Task<ActionResult<UserWithTokenDto>> RegisterAsync([FromBody] UserR
return Ok(new UserWithTokenDto(new UserDto(user), token, userService.GetExpiryDateFromToken(token)));
}

/// <summary>获取一个新jwt token</summary>
/// <remarks>获取一个当前用户的新token</remarks>
[HttpGet("session/refresh")]
[Authorize]
public async Task<ActionResult<UserWithTokenDto>> RefreshTokenAsync()
{
var userId = this.GetUserId();
User? user = await userRepository.GetUserAsync(userId);
if (user == null) return NotFound();
var token = userService.GetToken(user);
UserDto dto = new(user);
await dto.WithAvatarAsync(ossService);
return Ok(new UserWithTokenDto(dto, token, userService.GetExpiryDateFromToken(token)));
}

/// <summary>修改用户信息</summary>
/// <remarks>所有字段均可选</remarks>
/// <response code="200">成功,返回新的用户信息</response>
Expand Down
2 changes: 1 addition & 1 deletion GalgameManager/Assets/Data/vndb-tags-latest.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
7 changes: 7 additions & 0 deletions GalgameManager/Contracts/Services/ICategoryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ public interface ICategoryService
/// <param name="galgame"></param>
/// <returns></returns>
Category? GetDeveloperCategory(Galgame galgame);

/// <summary>
/// 保存分类信息
/// </summary>
/// <param name="category">要保存的分类</param>
/// <param name="categoryGroup">要保存的分类组</param>
public void Save(Category? category = null, CategoryGroup? categoryGroup = null);

/// <summary>
/// 导出数据
Expand Down
20 changes: 20 additions & 0 deletions GalgameManager/Contracts/Services/IGalgameCollectionService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ public interface IGalgameCollectionService
public Task<Galgame> AddGameAsync(GalgameSourceType sourceType, string path, bool force,
bool requireConfirm = true);

/// <summary>
/// 添加一个非本地的虚拟galgame
/// </summary>
/// <param name="game"></param>
public void AddVirtualGalgame(Galgame game);

/// <summary>
/// 指定某个游戏的本地路径,注意捕获异常
/// </summary>
Expand Down Expand Up @@ -74,6 +80,20 @@ public Task<Galgame> AddGameAsync(GalgameSourceType sourceType, string path, boo
/// <param name="name">名字</param>
/// <returns>galgame,找不到返回null</returns>
public Galgame? GetGalgameFromName(string? name);

/// <summary>
/// 保存galgame列表(以及其内部的galgame)
/// </summary>
public Task SaveGalgamesAsync();

/// <summary>
/// 保存galgame
/// </summary>
/// <param name="galgame">
/// 要指定保存的galgame<br/>
/// 如果设置中没有打开保存备份则不会保存到游戏文件夹
/// </param>
public Task SaveGalgameAsync(Galgame galgame);

/// <summary>
/// 从信息源中搜刮游戏信息,会直接修改传入的galgame <br/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ public Task<GalgameSourceBase> AddGalgameSourceAsync(GalgameSourceType sourceTyp
/// </summary>
public void ScanAll();

/// <summary>
/// 保存某个库
/// </summary>
/// <param name="source"></param>
public void Save(GalgameSourceBase source);

/// <summary>
/// 将一个游戏移入某个库,不进行物理移动操作(如复制文件节、上传游戏等)
/// </summary>
Expand All @@ -82,12 +88,12 @@ public Task<GalgameSourceBase> AddGalgameSourceAsync(GalgameSourceType sourceTyp
/// </summary>
/// <param name="target"></param>
/// <param name="game"></param>
public void MoveOutOperate(GalgameSourceBase target, Galgame game);
public void MoveOutNoOperate(GalgameSourceBase target, Galgame game);

/// <summary>
/// 移动游戏,<b>会进行物理操作</b>(如删除文件夹、复制文件夹、上传游戏到云端等)<br/>
/// 可以组合移入和移出操作,例如可以不移入任何库,只移出;也可以不移出任何库,只移入;也可以同时移入和移出 <br/>
/// 若不需要物理移动位置,请用<see cref="MoveInNoOperate"/>与<see cref="MoveOutOperate"/>>>
/// 若不需要物理移动位置,请用<see cref="MoveInNoOperate"/>与<see cref="MoveOutNoOperate"/>>>
/// </summary>
/// <param name="moveInSrc">要移入的库,若设为null则表示不移入任何库</param>
/// <param name="moveInPath">要移入的路径,若设置为null则表示让service自行决定路径</param>
Expand Down
11 changes: 11 additions & 0 deletions GalgameManager/Contracts/Services/ILocalSettingsService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Windows.Storage;
using Newtonsoft.Json;
using LiteDB;

namespace GalgameManager.Contracts.Services;

Expand All @@ -13,6 +14,16 @@ public interface ILocalSettingsService
public DirectoryInfo LocalFolder { get; }

public DirectoryInfo TemporaryFolder { get; }

public LiteDatabase Database { get; }

public bool IsDatabaseUsable { get; }

/// <summary>
/// 初始化数据库链接,注意捕获异常 <br/>
/// 事实上这个方法只会被ActivationService调用。若数据库链接失败(被占用等)会直接退出程序
/// </summary>
public void InitDatabase();

Task<T?> ReadSettingAsync<T>(string key, bool isLarge = false, List<JsonConverter>? converters = null,
bool typeNameHandling = false);
Expand Down
2 changes: 2 additions & 0 deletions GalgameManager/Contracts/Services/IPvnService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public interface IPvnService
public Task<PvnAccount?> RegisterAsync(string username, string password);

public Task<PvnAccount?> LoginViaBangumiAsync();

public Task<PvnAccount?> RefreshTokenAsync();

public Task<PvnAccount?> ModifyAccountAsync(string? userDisplayName = null, string? avatarPath = null,
string? newPassword = null, string? oldPassword = null);
Expand Down
2 changes: 2 additions & 0 deletions GalgameManager/GalgameManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</PropertyGroup>
<ItemGroup>
<Content Remove="Assets\Pictures\icon-dev\*" />
<Content Remove="Assets\Pictures\icon-sideload\*" />
<Content Remove="Assets\Potato.altform-lightunplated_targetsize-16.png" />
<Content Remove="Assets\Potato.altform-lightunplated_targetsize-24.png" />
<Content Remove="Assets\Potato.altform-lightunplated_targetsize-256.png" />
Expand Down Expand Up @@ -107,6 +108,7 @@
</PackageReference>
<PackageReference Include="H.NotifyIcon.WinUI" Version="2.0.118" />
<PackageReference Include="KnowledgePicker.WordCloud" Version="1.3.1" />
<PackageReference Include="LiteDB" Version="5.0.21" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="5.0.6" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="5.0.2" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
Expand Down
5 changes: 3 additions & 2 deletions GalgameManager/Helpers/DownloadHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Windows.Storage;
using System.Net;
using Windows.Storage;

namespace GalgameManager.Helpers;

Expand Down Expand Up @@ -56,7 +57,7 @@ public static class DownloadHelper
}
catch (HttpRequestException e)
{
if (retry < 3)
if (retry < 3 && e.StatusCode != HttpStatusCode.NotFound)
{
await Task.Delay(5000);
return await DownloadAndSaveImageAsync(imageUrl, retry + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ public static class ObservableCollectionExtensions
/// </summary>
/// <param name="collection">待同步的ObservableCollection</param>
/// <param name="other">要匹配的列表</param>
/// <param name="sort">是否要求顺序一致</param>
/// <typeparam name="T"></typeparam>
public static void SyncCollection<T>(this ObservableCollection<T> collection, IList<T> other)
public static void SyncCollection<T>(this ObservableCollection<T> collection, IList<T> other, bool sort = false)
where T : notnull
{
// var delta = other.Count - collection.Count;
// for (var i = 0; i < delta; i++)
Expand All @@ -25,7 +27,25 @@ public static void SyncCollection<T>(this ObservableCollection<T> collection, IL
HashSet<T> toAdd = new(other.Where(obj => !collection.Contains(obj)));
foreach (T obj in toRemove)
collection.Remove(obj);
foreach(T obj in toAdd)
foreach (T obj in toAdd)
collection.Add(obj);

if (!sort) return;
Dictionary<T, int> index = new();
for (var i = 0; i < other.Count; i++)
index[other[i]] = i;
collection.Sort((a, b) => index[a].CompareTo(index[b]));
}

public static ObservableCollection<T> Sort<T>(this ObservableCollection<T> collection, Func<T, T, int> cmp)
{
List<T> list = new(collection);
list.Sort((a, b) => cmp(a, b));
for (var i = 0; i < list.Count; i++)
{
if (!list[i]!.Equals(collection[i]))
collection.Move(collection.IndexOf(list[i]), i);
}
return collection;
}
}
1 change: 1 addition & 0 deletions GalgameManager/Models/Accounts/PvnAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class PvnAccount
public required string UserDisplayName;
public string? Avatar;
public required long ExpireTimestamp;
public long RefreshTimestamp => ExpireTimestamp - 60 * 60 * 24 * 10; // 提前10天刷新
public required LoginMethodEnum LoginMethod;
public required long TotalSpace;
public required long UsedSpace;
Expand Down
2 changes: 1 addition & 1 deletion GalgameManager/Models/BgTasks/ExportTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected async override Task RunInternal()
LocalSettingStatus status = await _settingService
.ReadSettingAsync<LocalSettingStatus>(KeyValues.DataStatus, true) ?? new();
status = status.Clone(); // 防止修改原数据
status.SetImportToFalse();
status.SetToExport();
await _settingService.AddToExportAsync(KeyValues.DataStatus, status);
// 导出主页设置
await _settingService.AddToExportDirectlyAsync(KeyValues.MultiStreamPageList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,14 @@ await UiThreadInvokeHelper.InvokeAsync(async Task () =>
}
});
log += $"{game.Name.Value}->{character.Name} Done\n";
await galgameService.SaveGalgameAsync(game);
}
onProgress.Invoke(new Progress
{
Current = total, Total = total,
Message = "Galgame_GetCharacterInfo_Saving".GetLocalized(),
});
await galgameService.SaveGalgameAsync(game);
FileHelper.SaveWithoutJson(game.GetLogName(), log, "Logs");
await Task.Delay(1000); //等待文件保存
onProgress.Invoke(new Progress
Expand Down
1 change: 1 addition & 0 deletions GalgameManager/Models/BgTasks/GetGalgameInfoFromRssTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected override Task RunInternal()
await UiThreadInvokeHelper.InvokeAsync(async Task() =>
{
Galgame result = await galgameService.PhraseGalInfoAsync(galgame);
await galgameService.SaveGalgameAsync(result);
log += $"{result.Name} Done\n";
});
}
Expand Down
Loading

0 comments on commit bb630f2

Please sign in to comment.