Skip to content

Commit 1dc7599

Browse files
committed
🐛 fix(SearchAppFunctionPage): Hide unsupported features in search results
1 parent 770ac5b commit 1dc7599

File tree

8 files changed

+46
-33
lines changed

8 files changed

+46
-33
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace SwashbucklerDiary.Rcl.Models
22
{
3-
public class AppFunction
3+
public class AppFeatures
44
{
55
public string? Name { get; set; }
66

@@ -9,5 +9,7 @@ public class AppFunction
99
public string? Path { get; set; }
1010

1111
public string? Href { get; set; }
12+
13+
public string[]? HidePlatforms { get; set; }
1214
}
1315
}

src/SwashbucklerDiary.Rcl/Pages/Mine/MinePage.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ private async Task OpenQQGroup()
254254
private void Search(string? value)
255255
{
256256
string? queryParameters = string.IsNullOrWhiteSpace(value) ? null : $"?query={value}";
257-
To($"searchAppFunction{queryParameters}");
257+
To($"searchAppFeatures{queryParameters}");
258258
}
259259

260260
private async Task UpdateStatisticalDataAsync()

src/SwashbucklerDiary.Rcl/Pages/SearchAppFunctionPage.razor renamed to src/SwashbucklerDiary.Rcl/Pages/SearchAppFeaturesPage.razor

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@page "/searchAppFunction"
1+
@page "/searchAppFeatures"
22
@inherits ImportantComponentBase
33

44
<MyAppBar>
@@ -8,8 +8,8 @@
88
</MButton>
99

1010
<TransparentTextField @bind-Value="search"
11-
Placeholder="@(I18n.T("SearchAppFunction.Placeholder"))"
12-
OnInput="UpdateAppFunctions">
11+
Placeholder="@(I18n.T("SearchAppFeatures.Placeholder"))"
12+
OnInput="UpdateAppFeatures">
1313
</TransparentTextField>
1414
</MyAppBar>
1515

@@ -37,7 +37,7 @@
3737
</MCard>
3838
}
3939

40-
<Virtualize Items="_appFunctions"
40+
<Virtualize Items="_appFeatures"
4141
ItemSize="@ItemHeight"
4242
Context="item">
4343
<MCard @key="item"
@@ -65,6 +65,6 @@
6565
</MCard>
6666
</Virtualize>
6767

68-
<EmptyResult Show="_appFunctions.Count == 0 && !ShowPrivacyModeItem"></EmptyResult>
68+
<EmptyResult Show="_appFeatures.Count == 0 && !ShowPrivacyModeItem"></EmptyResult>
6969

7070
</ScrollContainer>

src/SwashbucklerDiary.Rcl/Pages/SearchAppFunctionPage.razor.cs renamed to src/SwashbucklerDiary.Rcl/Pages/SearchAppFeaturesPage.razor.cs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
namespace SwashbucklerDiary.Rcl.Pages
99
{
10-
public partial class SearchAppFunctionPage : ImportantComponentBase
10+
public partial class SearchAppFeaturesPage : ImportantComponentBase
1111
{
1212
private string? search;
1313

1414
private bool showPrivacyModeSearch;
1515

1616
private string? privacyModeSearchKey;
1717

18-
private List<AppFunction> allAppFunctions = [];
18+
private List<AppFeatures> allAppFeatures = [];
1919

20-
private List<AppFunction> _appFunctions = [];
20+
private List<AppFeatures> _appFeatures = [];
2121

2222
[Inject]
2323
protected MasaBlazorHelper MasaBlazorHelper { get; set; } = default!;
@@ -39,7 +39,7 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
3939
await base.OnAfterRenderAsync(firstRender);
4040
if (firstRender)
4141
{
42-
await LoadAppFunctions();
42+
await LoadAppFeatures();
4343
StateHasChanged();
4444
}
4545
}
@@ -53,7 +53,7 @@ protected override async ValueTask DisposeAsyncCore()
5353

5454
protected override async Task OnResume()
5555
{
56-
UpdateAppFunctions();
56+
UpdateAppFeatures();
5757
await base.OnResume();
5858
}
5959

@@ -77,32 +77,37 @@ private void LoadQuery()
7777
}
7878
}
7979

80-
private async Task LoadAppFunctions()
80+
private async Task LoadAppFeatures()
8181
{
82-
var appFunctions = await StaticWebAssets.ReadJsonAsync<List<AppFunction>>("json/app-functions/app-functions.json");
83-
allAppFunctions = appFunctions;
84-
UpdateAppFunctions(appFunctions);
82+
var appFeatures = await StaticWebAssets.ReadJsonAsync<List<AppFeatures>>("json/app-features/app-features.json");
83+
allAppFeatures = appFeatures;
84+
UpdateAppFeatures(appFeatures);
8585
}
8686

87-
private void UpdateAppFunctions(List<AppFunction> appFunctions)
87+
private void UpdateAppFeatures(List<AppFeatures> appFeatures)
8888
{
89-
Expression<Func<AppFunction, bool>> exp = GetExpression();
90-
_appFunctions = appFunctions.Where(exp.Compile()).ToList();
89+
Expression<Func<AppFeatures, bool>> exp = GetExpression();
90+
_appFeatures = appFeatures.Where(exp.Compile()).ToList();
9191
}
9292

93-
private void UpdateAppFunctions()
94-
=> UpdateAppFunctions(allAppFunctions);
93+
private void UpdateAppFeatures()
94+
=> UpdateAppFeatures(allAppFeatures);
9595

96-
private Expression<Func<AppFunction, bool>> GetExpression()
96+
private Expression<Func<AppFeatures, bool>> GetExpression()
9797
{
98-
Expression<Func<AppFunction, bool>>? exp = null;
98+
Expression<Func<AppFeatures, bool>>? exp = null;
9999

100100
if (!string.IsNullOrWhiteSpace(search))
101101
{
102-
Expression<Func<AppFunction, bool>> expSearch
102+
Expression<Func<AppFeatures, bool>> expSearch
103103
= it => I18n.T(it.Name ?? string.Empty).Contains(search, StringComparison.CurrentCultureIgnoreCase)
104104
|| I18n.T(it.Path ?? string.Empty).Contains(search, StringComparison.CurrentCultureIgnoreCase);
105105
exp = exp.And(expSearch);
106+
107+
Expression<Func<AppFeatures, bool>> expPlatform
108+
= it => it.HidePlatforms == null
109+
|| !it.HidePlatforms.Contains(PlatformIntegration.CurrentPlatform.ToString());
110+
exp = exp.And(expPlatform);
106111
}
107112

108113
if (exp == null)

src/SwashbucklerDiary.Rcl/wwwroot/i18n/en-US.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@
658658
"Content": "Are you sure to clear all caches?",
659659
"ClearSuccess": "Clear success"
660660
},
661-
"SearchAppFunction": {
661+
"SearchAppFeatures": {
662662
"Placeholder": "Please enter the function you want to search for"
663663
},
664664
"DateTimeFormat": {

src/SwashbucklerDiary.Rcl/wwwroot/i18n/zh-CN.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@
658658
"Content": "确定清除所有缓存吗?",
659659
"ClearSuccess": "清理成功"
660660
},
661-
"SearchAppFunction": {
661+
"SearchAppFeatures": {
662662
"Placeholder": "请输入想要搜索的功能"
663663
},
664664
"DateTimeFormat": {

src/SwashbucklerDiary.Rcl/wwwroot/json/app-functions/app-functions.json renamed to src/SwashbucklerDiary.Rcl/wwwroot/json/app-features/app-features.json

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,25 +45,29 @@
4545
"Name": "Backups.WebDAV.Name",
4646
"Icon": "mdi-cloud-sync-outline",
4747
"Path": "Backups.WebDAV.Path",
48-
"Href": "backups?tabs=webDAV"
48+
"Href": "backups?tabs=webDAV",
49+
"HidePlatforms": [ "Browser" ]
4950
},
5051
{
5152
"Name": "Backups.Config.Title",
5253
"Icon": "mdi-cog-sync-outline",
5354
"Path": "Backups.Config.Path",
54-
"Href": "backups?tabs=webDAV"
55+
"Href": "backups?tabs=webDAV",
56+
"HidePlatforms": [ "Browser" ]
5557
},
5658
{
5759
"Name": "Backups.Upload.Title",
5860
"Icon": "mdi-cloud-arrow-up-outline",
5961
"Path": "Backups.Upload.Path",
60-
"Href": "backups?tabs=webDAV"
62+
"Href": "backups?tabs=webDAV",
63+
"HidePlatforms": [ "Browser" ]
6164
},
6265
{
6366
"Name": "Backups.Download.Title",
6467
"Icon": "mdi-cloud-arrow-down-outline",
6568
"Path": "Backups.Download.Path",
66-
"Href": "backups?tabs=webDAV"
69+
"Href": "backups?tabs=webDAV",
70+
"HidePlatforms": [ "Browser" ]
6771
},
6872
{
6973
"Name": "Export.Local.Name",
@@ -87,7 +91,8 @@
8791
"Name": "Export.LAN.Name",
8892
"Icon": "mdi-lan",
8993
"Path": "Export.LAN.Path",
90-
"Href": "export?tabs=LAN"
94+
"Href": "export?tabs=LAN",
95+
"HidePlatforms": [ "Browser" ]
9196
},
9297
{
9398
"Name": "Mine.Achievement.Name",
@@ -279,7 +284,8 @@
279284
"Name": "Url Scheme",
280285
"Icon": "mdi-link-variant",
281286
"Path": "About.UrlScheme.Path",
282-
"Href": "urlScheme"
287+
"Href": "urlScheme",
288+
"HidePlatforms": [ "Browser" ]
283289
},
284290
{
285291
"Name": "About.Evaluation.Name",

src/SwashbucklerDiary.Rcl/wwwroot/json/url-scheme/url-scheme.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
{
2323
"Name": "UrlScheme.SearchFunction",
24-
"Path": "searchAppFunction?query="
24+
"Path": "searchAppFeatures?query="
2525
},
2626
{
2727
"Name": "UrlScheme.Write",

0 commit comments

Comments
 (0)