Skip to content

Commit

Permalink
🆕 feat(UrlScheme): add Url Scheme Page
Browse files Browse the repository at this point in the history
  • Loading branch information
Yu-Core committed Sep 16, 2024
1 parent 0808558 commit 6bd21d6
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/SwashbucklerDiary.Rcl/Models/UrlScheme.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SwashbucklerDiary.Rcl.Models
{
public class UrlScheme
{
public string Name { get; set; } = string.Empty;

public string Path { get; set; } = string.Empty;
}
}
9 changes: 7 additions & 2 deletions src/SwashbucklerDiary.Rcl/Pages/Mine/About/AboutPage.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@ private void LoadView()
viewLists =
[
[
new(this, "About.SourceCode.Name","mdi-book-open-page-variant-outline",() => showSourceCode = true),
new(this, "About.Agreement.Name","mdi-file-document-multiple-outline",() => To("user-agreement")),
new(this, "About.Privacy.Name","mdi-lock-outline",() => To("privacy-policy")),
],
[
new(this, "About.Check for updates.Name","mdi-update",CheckForUpdates),
new(this, "About.LogFile.Name","mdi-file-document-edit-outline",() => To("log")),
new(this, "Url Scheme","mdi-link-variant",() => To("urlScheme"),()=>PlatformIntegration.CurrentPlatform != AppDevicePlatform.Browser),
],
[
new(this, "About.SourceCode.Name","mdi-book-open-page-variant-outline",() => showSourceCode = true),
new(this, "About.Related.Name","mdi-xml",() => To("relatedOSP")),
new(this, "About.LogFile.Name","mdi-file-document-edit-outline",() => To("log")),
],
[
new(this, "About.Evaluation.Name","mdi-star-outline",OpenAppDetails),
new(this, "About.Sponsor.Name","mdi-hand-heart-outline",()=>To("sponsor")),
]
Expand Down
50 changes: 50 additions & 0 deletions src/SwashbucklerDiary.Rcl/Pages/Mine/About/UrlSchemePage.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@page "/urlScheme"
@namespace SwashbucklerDiary.Rcl.Pages
@inherits ImportantComponentBase

<MyAppBar Title="UrlScheme"
OnClick="NavigateToBack">
</MyAppBar>

<ScrollContainer>
<MChipGroup @bind-Value="scheme"
Class="mb-2"
Mandatory>
@foreach (var item in schemes)
{
<MChip Value="item"
Filter
Outlined>
@item
</MChip>
}
</MChipGroup>

<MCard Class="my-list-card"
Elevation="0"
Rounded="@("lg")">
<MList Class="dynamic-list-item-collection">
@foreach (var item in urlSchemes)
{
<MListItem @key="item"
OnClick="()=>CopyAsync(item.Path)">
<MListItemContent>
<MListItemTitle>
@(I18n.T(item.Name))
</MListItemTitle>
<MListItemSubtitle>
@($"{scheme}://{item.Path}")
</MListItemSubtitle>
</MListItemContent>
<MListItemAction>
<MIcon>mdi-content-copy</MIcon>
</MListItemAction>
</MListItem>

<MDivider Class="mx-5"></MDivider>
}

</MList>
</MCard>
</ScrollContainer>

34 changes: 34 additions & 0 deletions src/SwashbucklerDiary.Rcl/Pages/Mine/About/UrlSchemePage.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Masa.Blazor;
using SwashbucklerDiary.Rcl.Components;
using SwashbucklerDiary.Rcl.Models;

namespace SwashbucklerDiary.Rcl.Pages
{
public partial class UrlSchemePage : ImportantComponentBase
{
private StringNumber? scheme;

private readonly string[] schemes = ["swashbucklerdiary", "xiakeriji"];

private List<UrlScheme> urlSchemes = [];

protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();

await ReadJson();
}

private async Task ReadJson()
{
urlSchemes = await StaticWebAssets.ReadJsonAsync<List<UrlScheme>>("json/url-scheme/url-scheme.json");
}

private async Task CopyAsync(string path)
{
var text = $"{scheme}://{path}";
await PlatformIntegration.SetClipboard(text);
await PopupServiceHelper.Success(I18n.T("Share.CopySuccess"));
}
}
}
16 changes: 16 additions & 0 deletions src/SwashbucklerDiary.Rcl/wwwroot/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@
"Name": "Log file",
"Path": "About / Log file"
},
"UrlScheme": {
"Path": "About / Url Scheme"
},
"Sponsor": {
"Name": "Sponsor we",
"Path": "About / Sponsor we",
Expand Down Expand Up @@ -780,5 +783,18 @@
"Name": "Support it",
"Content": "If you think this software is pretty good, you can donate and support it. Your support is the greatest motivation for developers.",
"To support": "Sponsor"
},
"UrlScheme": {
"Index": "Index",
"History": "History",
"FileBrowse": "File browse",
"Mine": "Mine",
"Search": "Search",
"SearchFunction": "Search function",
"Write": "Write diary",
"Setting": "Setting",
"Backup": "Backup",
"Export": "Export",
"About": "About"
}
}
16 changes: 16 additions & 0 deletions src/SwashbucklerDiary.Rcl/wwwroot/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@
"Name": "日志文件",
"Path": "关于 / 日志文件"
},
"UrlScheme": {
"Path": "关于 / Url Scheme"
},
"Sponsor": {
"Name": "捐助我们",
"Path": "关于 / 捐助我们",
Expand Down Expand Up @@ -780,5 +783,18 @@
"Name": "支持一下",
"Content": "如果你觉得此软件还不错的话,可以捐助支持一下。你的支持就是开发者最大的动力。",
"To support": "捐助"
},
"UrlScheme": {
"Index": "首页",
"History": "日历",
"FileBrowse": "文件",
"Mine": "我的",
"Search": "搜索",
"SearchFunction": "搜索功能",
"Write": "创建日记",
"Setting": "设置",
"Backup": "备份",
"Export": "导出",
"About": "关于"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@
"Path": "About.LogFile.Path",
"Href": "log"
},
{
"Name": "Url Scheme",
"Icon": "mdi-link-variant",
"Path": "About.UrlScheme.Path",
"Href": "urlScheme"
},
{
"Name": "About.Evaluation.Name",
"Icon": "mdi-star-outline",
Expand Down
46 changes: 46 additions & 0 deletions src/SwashbucklerDiary.Rcl/wwwroot/json/url-scheme/url-scheme.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[
{
"Name": "UrlScheme.Index",
"Path": ""
},
{
"Name": "UrlScheme.History",
"Path": "history"
},
{
"Name": "UrlScheme.FileBrowse",
"Path": "fileBrowse"
},
{
"Name": "UrlScheme.Mine",
"Path": "mine"
},
{
"Name": "UrlScheme.Search",
"Path": "search?query="
},
{
"Name": "UrlScheme.SearchFunction",
"Path": "searchAppFunction?query="
},
{
"Name": "UrlScheme.Write",
"Path": "write"
},
{
"Name": "UrlScheme.Setting",
"Path": "setting"
},
{
"Name": "UrlScheme.Backup",
"Path": "backups"
},
{
"Name": "UrlScheme.Export",
"Path": "export"
},
{
"Name": "UrlScheme.About",
"Path": "about"
}
]

0 comments on commit 6bd21d6

Please sign in to comment.