Skip to content

Commit

Permalink
🐛 fix: Some minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-Core committed Apr 28, 2024
1 parent fdf77fc commit ae85c00
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
Expand Up @@ -4,15 +4,10 @@ namespace SwashbucklerDiary.Maui.Essentials
{
public class StaticWebAssets : Rcl.Essentials.StaticWebAssets
{
private readonly JsonSerializerOptions defaultJsonSerializerOptions = new()
{
PropertyNameCaseInsensitive = true
};

public override async Task<T> ReadJsonAsync<T>(string relativePath, bool isRcl = true, JsonSerializerOptions? jsonSerializerOptions = null)
{
var contents = await ReadContentAsync(relativePath, isRcl).ConfigureAwait(false);
return JsonSerializer.Deserialize<T>(contents, jsonSerializerOptions ?? defaultJsonSerializerOptions) ?? throw new($"{relativePath} deserialize fail");
return JsonSerializer.Deserialize<T>(contents, jsonSerializerOptions ?? DefaultJsonSerializerOptions) ?? throw new($"{relativePath} deserialize fail");
}

public override async Task<string> ReadContentAsync(string relativePath, bool isRcl = true)
Expand Down
Expand Up @@ -5,7 +5,7 @@
<wc-waterfall @ref="elementReference" class="video-waterfall" gap="@Gap" cols="@Cols">
@foreach (var item in LoadedItems)
{
<video @key="item.ResourceUri" class="rounded-lg" src="@item.ResourceUri" />
<video @key="item.ResourceUri" class="video-card rounded-lg" src="@item.ResourceUri" />
}
</wc-waterfall>

Expand Down
Expand Up @@ -8,6 +8,11 @@ public abstract class StaticWebAssets : IStaticWebAssets

public static string? RclAssemblyName => _rclAssemblyName.Value;

protected virtual JsonSerializerOptions DefaultJsonSerializerOptions { get; set; } = new()
{
PropertyNameCaseInsensitive = true
};

public abstract Task<T> ReadJsonAsync<T>(string relativePath, bool isRcl = true, JsonSerializerOptions? jsonSerializerOptions = null);

public abstract Task<string> ReadContentAsync(string relativePath, bool isRcl = true);
Expand Down
6 changes: 5 additions & 1 deletion src/SwashbucklerDiary.Rcl/wwwroot/css/app.css
Expand Up @@ -331,6 +331,10 @@ html {
cursor: pointer;
}

.video-card {
cursor: pointer;
}

/*消息条提示样式,仿照masa旧版中的Toast*/
.m-snack__wrapper {
border-radius: 8px !important;
Expand Down Expand Up @@ -527,7 +531,7 @@ html.m-overlay-scroll-blocked {
}

.adaptive-card-container {
grid-template-columns: 1fr;
grid-template-columns: minmax(0, 1fr);
}

@media screen and (min-width: 960px) {
Expand Down
Expand Up @@ -12,15 +12,10 @@ public StaticWebAssets(HttpClient httpClient)
_httpClient = httpClient;
}

private readonly JsonSerializerOptions defaultJsonSerializerOptions = new()
{
PropertyNameCaseInsensitive = true
};

public override async Task<T> ReadJsonAsync<T>(string relativePath, bool isRcl = true, JsonSerializerOptions? jsonSerializerOptions = null)
{
string path = RelativePathToPath(relativePath, isRcl);
var result = await _httpClient.GetFromJsonAsync<T>(path, jsonSerializerOptions ?? defaultJsonSerializerOptions);
var result = await _httpClient.GetFromJsonAsync<T>(path, jsonSerializerOptions ?? DefaultJsonSerializerOptions);
return result ?? throw new($"{relativePath} deserialize fail");
}

Expand Down
Expand Up @@ -24,7 +24,7 @@ public async Task InitializedAsync()
public Task OnSystemThemeChanged(bool isDarkTheme)
{
SystemTheme = isDarkTheme ? Theme.Dark : Theme.Light;
return SystemThemeChanged?.Invoke(SystemTheme) ?? Task.FromResult(0);
return SystemThemeChanged?.Invoke(SystemTheme) ?? Task.CompletedTask;
}
}
}

0 comments on commit ae85c00

Please sign in to comment.