Skip to content

Commit 6083315

Browse files
committed
Merge branch 'main' into doc-table
2 parents 1c3100d + 2c5f4ca commit 6083315

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+860
-52
lines changed

src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@
4646
<PackageReference Include="BootstrapBlazor.Html2Pdf" Version="9.0.3" />
4747
<PackageReference Include="BootstrapBlazor.IconPark" Version="9.0.3" />
4848
<PackageReference Include="BootstrapBlazor.ImageCropper" Version="9.0.3" />
49-
<PackageReference Include="BootstrapBlazor.IP2Region" Version="9.0.1" />
49+
<PackageReference Include="BootstrapBlazor.IP2Region" Version="9.0.2" />
5050
<PackageReference Include="BootstrapBlazor.JitsiMeet" Version="9.0.0" />
5151
<PackageReference Include="BootstrapBlazor.JuHeIpLocatorProvider" Version="9.0.0" />
5252
<PackageReference Include="BootstrapBlazor.Live2DDisplay" Version="9.0.1" />
5353
<PackageReference Include="BootstrapBlazor.Markdown" Version="9.0.2" />
5454
<PackageReference Include="BootstrapBlazor.MaterialDesign" Version="9.0.1" />
55-
<PackageReference Include="BootstrapBlazor.MeiliSearch" Version="9.1.9" />
55+
<PackageReference Include="BootstrapBlazor.MeiliSearch" Version="9.1.10" />
5656
<PackageReference Include="BootstrapBlazor.Mermaid" Version="9.0.4" />
5757
<PackageReference Include="BootstrapBlazor.Middleware" Version="9.0.0" />
5858
<PackageReference Include="BootstrapBlazor.MindMap" Version="9.1.6" />
5959
<PackageReference Include="BootstrapBlazor.MouseFollower" Version="9.0.1" />
6060
<PackageReference Include="BootstrapBlazor.OctIcon" Version="9.0.4" />
6161
<PackageReference Include="BootstrapBlazor.OfficeViewer" Version="9.0.0" />
6262
<PackageReference Include="BootstrapBlazor.OnScreenKeyboard" Version="9.0.1" />
63-
<PackageReference Include="BootstrapBlazor.OpcDa" Version="9.0.1" />
63+
<PackageReference Include="BootstrapBlazor.OpcDa" Version="9.0.3" />
6464
<PackageReference Include="BootstrapBlazor.PdfReader" Version="9.0.1" />
6565
<PackageReference Include="BootstrapBlazor.PdfViewer" Version="9.0.6" />
6666
<PackageReference Include="BootstrapBlazor.Player" Version="9.0.1" />

src/BootstrapBlazor.Server/Components/App.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242

4343
<BlazorReconnector @rendermode="new InteractiveServerRenderMode(false)" />
4444

45-
<script src="_content/BootstrapBlazor.SummerNote/js/jquery-3.6.0.min.js"></script>
46-
<script src="_content/BootstrapBlazor/js/bootstrap.blazor.bundle.min.js"></script>
47-
<script src="_framework/blazor.web.js"></script>
45+
<script src="@Assets["_content/BootstrapBlazor.SummerNote/js/jquery-3.6.0.min.js"]"></script>
46+
<script src="@Assets["_content/BootstrapBlazor/js/bootstrap.blazor.bundle.min.js"]"></script>
47+
<script src="@Assets["_framework/blazor.web.js"]"></script>
4848
@if (Env.IsProduction())
4949
{
5050
<script type="text/javascript" src="https://cdn.wwads.cn/js/makemoney.js"></script>

src/BootstrapBlazor.Server/Components/Components/Pre.razor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { copy, getDescribedElement, addLink, removeLink, addScript, getHeight, getPreferredTheme, registerBootstrapBlazorModule } from "../../_content/BootstrapBlazor/modules/utility.js"
1+
import { copy, getDescribedElement, addLink, removeLink, addScript, getHeight, getTheme, registerBootstrapBlazorModule } from "../../_content/BootstrapBlazor/modules/utility.js"
22
import EventHandler from "../../_content/BootstrapBlazor/modules/event-handler.js"
33

44
export async function init(id, title, assetRoot) {
@@ -9,7 +9,7 @@ export async function init(id, title, assetRoot) {
99

1010
await addScript(`${assetRoot}lib/highlight/highlight.min.js`)
1111
await addScript(`${assetRoot}lib/highlight/cshtml-razor.min.js`)
12-
await switchTheme(getPreferredTheme(), assetRoot);
12+
await switchTheme(getTheme(), assetRoot);
1313

1414
const preElement = el.querySelector('pre')
1515
const code = el.querySelector('pre > code')

src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
@inherits LayoutComponentBase
22

33
<BootstrapBlazorRoot>
4-
<Header></Header>
5-
<main>
6-
@Body
7-
</main>
4+
@if (_init)
5+
{
6+
<Header></Header>
7+
<main>
8+
@Body
9+
</main>
10+
}
811
</BootstrapBlazorRoot>
912

1013
<div id="blazor-error-ui">

src/BootstrapBlazor.Server/Components/Layout/BaseLayout.razor.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

6+
using BootstrapBlazor.Server.Data;
7+
using Microsoft.Extensions.Options;
8+
using Microsoft.JSInterop;
9+
610
namespace BootstrapBlazor.Server.Components.Layout;
711

812
/// <summary>
913
/// 母版页基类
1014
/// </summary>
1115
public partial class BaseLayout : IDisposable
1216
{
17+
[Inject]
18+
[NotNull]
19+
private IJSRuntime? JSRuntime { get; set; }
20+
1321
[Inject]
1422
[NotNull]
1523
private IStringLocalizer<BaseLayout>? Localizer { get; set; }
@@ -26,6 +34,10 @@ public partial class BaseLayout : IDisposable
2634
[NotNull]
2735
private IDispatchService<bool>? RebootDispatchService { get; set; }
2836

37+
[Inject]
38+
[NotNull]
39+
private IOptions<WebsiteOptions>? WebsiteOption { get; set; }
40+
2941
[NotNull]
3042
private string? FlowText { get; set; }
3143

@@ -38,6 +50,8 @@ public partial class BaseLayout : IDisposable
3850
[NotNull]
3951
private string? CancelText { get; set; }
4052

53+
private bool _init = false;
54+
4155
/// <summary>
4256
/// <inheritdoc/>
4357
/// </summary>
@@ -54,6 +68,19 @@ protected override void OnInitialized()
5468
RebootDispatchService.Subscribe(NotifyReboot);
5569
}
5670

71+
/// <summary>
72+
/// <inheritdoc/>
73+
/// </summary>
74+
/// <returns></returns>
75+
protected override async Task OnInitializedAsync()
76+
{
77+
await base.OnInitializedAsync();
78+
79+
var module = await JSRuntime.LoadModule($"{WebsiteOption.Value.JSModuleRootPath}Layout/BaseLayout.razor.js");
80+
await module.InvokeVoidAsync("initTheme");
81+
_init = true;
82+
}
83+
5784
private async Task NotifyCommit(DispatchEntry<GiteePostBody> payload)
5885
{
5986
if (payload.CanDispatch())
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { getTheme, setTheme } from "../../_content/BootstrapBlazor/modules/utility.js"
2+
3+
export function initTheme() {
4+
const currentTheme = getTheme();
5+
setTheme(currentTheme, false);
6+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
@page "/navbar"
2+
@inject IStringLocalizer<Navbars> Localizer
3+
4+
<h3>@Localizer["NavbarTitle"]</h3>
5+
6+
<h4>@Localizer["NavbarDescription"]</h4>
7+
8+
<DemoBlock Title="@Localizer["NormalTitle"]" Introduction="@Localizer["NormalIntro"]" Name="Normal">
9+
<Navbar>
10+
<NavbarBrand>
11+
<a>Navbar</a>
12+
</NavbarBrand>
13+
<NavbarToggleButton Target="#test"></NavbarToggleButton>
14+
<NavbarCollapse Id="test">
15+
<NavbarGroup IsScrolling="true">
16+
<NavbarLink>Home</NavbarLink>
17+
<NavbarLink Text="Link"></NavbarLink>
18+
<NavbarDropdown Text="Dropdown">
19+
<NavbarDropdownItem>
20+
<i class="fa-solid fa-fw fa-home"></i><span>Action</span>
21+
</NavbarDropdownItem>
22+
<NavbarDropdownItem>
23+
<i class="fa-solid fa-fw fa-flag"></i><span>Another action</span>
24+
</NavbarDropdownItem>
25+
<NavbarDropdownDivider></NavbarDropdownDivider>
26+
<NavbarDropdownItem>
27+
<i class="fa-solid fa-fw fa-home"></i><span>Something else here</span>
28+
</NavbarDropdownItem>
29+
</NavbarDropdown>
30+
<NavbarLink IsDisabled="true">Disabled</NavbarLink>
31+
<NavbarItem>
32+
<a class="nav-link">About</a>
33+
</NavbarItem>
34+
</NavbarGroup>
35+
<NavbarGroup>
36+
<ValidateForm class="d-flex" role="search" Model="_searchModel" OnValidSubmit="OnValidSubmit">
37+
<BootstrapInput class="me-2" placeholder="Search" @bind-Value="_searchModel.SearchText"
38+
ShowLabel="false" SkipValidate="true"></BootstrapInput>
39+
<Button Color="Color.Success" IsOutline="true" ButtonType="ButtonType.Submit">Search</Button>
40+
</ValidateForm>
41+
</NavbarGroup>
42+
</NavbarCollapse>
43+
</Navbar>
44+
<section ignore>
45+
<p class="code-label">Nav</p>
46+
<ul class="ul-demo mb-3">
47+
<li><code>Size</code>: 指定导航栏响应阈值,默认 <code>Size.Medium</code></li>
48+
<li><code>BackgroundColorCssClass</code>: 导航栏背景色样式,默认 null 未设置使用 <code>bg-body-tertiary</code></li>
49+
</ul>
50+
<p class="code-label">NavbarBrand</p>
51+
<p>渲染 <code>navbar-brand</code> 样式,导航栏 Brand 当屏幕宽度小于特定阈值时导航栏会响应式收起,<code>NavbarBrand</code> 的内容始终显示</p>
52+
<p class="code-label">NavbarToggleButton</p>
53+
<p>渲染 <code>navbar-toggler</code> 样式,导航栏中的折叠展开按钮,当屏幕宽度小于特定阈值时显示,通过设置参数 <code>Target</code> 值指定折叠展开组件 <code>NavbarCollapse</code></p>
54+
<p class="code-label">NavbarCollapse</p>
55+
<p>渲染 <code>collapse navbar-collapse</code> 样式,导航栏中的可折叠展开区域,通过设置参数 <code>Id</code> 值,与组件 <code>NavbarToggleButton</code> 联动</p>
56+
<p class="code-label">NavbarGroup</p>
57+
<p>渲染 <code>navbar-nav</code> 样式,导航栏中区域分组容器组件</p>
58+
<ul class="ul-demo">
59+
<li><code>IsScrolling</code>: 是否开启滚动条</li>
60+
<li><code>Height</code>: 组件高度,默认 <b>200px</b></li>
61+
</ul>
62+
<p class="code-label">NavbarItem</p>
63+
<p>渲染 <code>navbar-item</code> 样式,导航栏中单项容器组件,通过内置自定义组件或者 <code>Html</code> 实现导航项</p>
64+
<p class="code-label">NavbarLink</p>
65+
<p>渲染 <code>nav-link</code> 样式,导航栏中导航组件,内部渲染为 <code>a</code> 链接</p>
66+
<ul class="ul-demo">
67+
<li><code>Url</code>: 导航地址</li>
68+
<li><code>Target</code>: 导航目标</li>
69+
<li><code>ImageUrl</code>: 图片地址</li>
70+
<li><code>ImageCss</code>: 图片样式</li>
71+
</ul>
72+
<p class="code-label">NavbarDropdown</p>
73+
<p>渲染 <code>nav-item dropdown</code> 样式,导航栏中下拉菜单组件</p>
74+
<p class="code-label">NavbarDropdownItem</p>
75+
<p>渲染 <code>dropdown-item</code> 样式,导航栏中下拉菜单组件内项目</p>
76+
</section>
77+
</DemoBlock>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
5+
6+
using Microsoft.AspNetCore.Components.Forms;
7+
8+
namespace BootstrapBlazor.Server.Components.Samples;
9+
10+
/// <summary>
11+
/// Navbar 示例
12+
/// </summary>
13+
public partial class Navbars
14+
{
15+
private List<SelectedItem> _dropdownItems = [];
16+
private SearchModel _searchModel = new SearchModel();
17+
18+
/// <summary>
19+
/// <inheritdoc/>
20+
/// </summary>
21+
protected override void OnInitialized()
22+
{
23+
base.OnInitialized();
24+
25+
_dropdownItems.AddRange([
26+
new SelectedItem() { Text="Item1", Value="0"},
27+
new SelectedItem() { Text="Item2", Value="1"},
28+
new SelectedItem() { Text="Item3", Value="2"}
29+
]);
30+
}
31+
32+
private Task OnValidSubmit(EditContext context)
33+
{
34+
return Task.CompletedTask;
35+
}
36+
37+
class SearchModel
38+
{
39+
public string? SearchText { get; set; }
40+
}
41+
}

src/BootstrapBlazor.Server/Components/Samples/OpcDa.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@
5858
<div class="col-12 col-sm-6">
5959
<BootstrapInputGroup>
6060
<BootstrapInputGroupLabel DisplayText="转速"></BootstrapInputGroupLabel>
61-
<BootstrapInputGroupLabel DisplayText="@Tag3"></BootstrapInputGroupLabel>
61+
<BootstrapInputGroupLabel DisplayText="@Tag1"></BootstrapInputGroupLabel>
6262
<Display @bind-Value="@_tagValue3"></Display>
6363
</BootstrapInputGroup>
6464
</div>
6565
<div class="col-12 col-sm-6">
6666
<BootstrapInputGroup>
6767
<BootstrapInputGroupLabel DisplayText="流速"></BootstrapInputGroupLabel>
68-
<BootstrapInputGroupLabel DisplayText="@Tag4"></BootstrapInputGroupLabel>
68+
<BootstrapInputGroupLabel DisplayText="@Tag2"></BootstrapInputGroupLabel>
6969
<Display @bind-Value="@_tagValue4"></Display>
7070
</BootstrapInputGroup>
7171
</div>

src/BootstrapBlazor.Server/Components/Samples/OpcDa.razor.cs

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone
55

66
using BootstrapBlazor.OpcDa;
7-
using System.Globalization;
87

98
namespace BootstrapBlazor.Server.Components.Samples;
109

@@ -17,12 +16,10 @@ public partial class OpcDa : ComponentBase
1716
[NotNull]
1817
private IOpcDaServer? OpcDaServer { get; set; }
1918

20-
private string? _serverName = "opcda://localhost/Kepware.KEPServerEX.V6/Mock";
19+
private string? _serverName = "opcda://localhost/Kepware.KEPServerEX.V6";
2120

2221
private const string Tag1 = "Channel1.Device1.Tag1";
2322
private const string Tag2 = "Channel1.Device1.Tag2";
24-
private const string Tag3 = "Channel1.Device1.Tag3";
25-
private const string Tag4 = "Channel1.Device1.Tag4";
2623

2724
private string? _tagValue1;
2825
private string? _tagValue2;
@@ -49,19 +46,25 @@ private void OnDisConnect()
4946

5047
private void OnRead()
5148
{
52-
var values = OpcDaServer.Read(Tag1, Tag2);
53-
_tagValue1 = values.ElementAt(0).Value?.ToString();
54-
55-
var v = (int)values.ElementAt(1).Value! / 100d;
56-
_tagValue2 = v.ToString(CultureInfo.InvariantCulture);
49+
var items = OpcDaServer.Read(Tag1, Tag2);
50+
var value1 = items.FirstOrDefault(i => i.Name == Tag1).Value;
51+
if (value1 != null)
52+
{
53+
_tagValue1 = value1.ToString();
54+
}
55+
var value2 = items.FirstOrDefault(i => i.Name == Tag2).Value;
56+
if (value2 != null)
57+
{
58+
_tagValue2 = value2.ToString();
59+
}
5760
}
5861

5962
private void OnCreateSubscription()
6063
{
6164
_subscribed = true;
6265
_subscription = OpcDaServer.CreateSubscription("Subscription1", 1000, true);
6366
_subscription.DataChanged += UpdateValues;
64-
_subscription.AddItems([Tag3, Tag4]);
67+
_subscription.AddItems([Tag1, Tag2]);
6568
}
6669

6770
private void OnCancelSubscription()
@@ -76,9 +79,16 @@ private void OnCancelSubscription()
7679

7780
private void UpdateValues(List<OpcReadItem> items)
7881
{
79-
_tagValue3 = items[0].Value?.ToString();
80-
var v = (int)items[1].Value! / 100d;
81-
_tagValue4 = v.ToString(CultureInfo.InvariantCulture);
82+
var value1 = items.Find(i => i.Name == Tag1).Value;
83+
if (value1 != null)
84+
{
85+
_tagValue3 = value1.ToString();
86+
}
87+
var value2 = items.Find(i => i.Name == Tag2).Value;
88+
if (value2 != null)
89+
{
90+
_tagValue4 = value2.ToString();
91+
}
8292

8393
InvokeAsync(StateHasChanged);
8494
}
@@ -88,12 +98,12 @@ private void UpdateValues(List<OpcReadItem> items)
8898
private void OnBrowse()
8999
{
90100
var elements = OpcDaServer.Browse("", new OpcBrowseFilters(), out _);
91-
_roots = elements.Select(element => new TreeViewItem<OpcBrowseElement>(element)
101+
_roots = [.. elements.Select(element => new TreeViewItem<OpcBrowseElement>(element)
92102
{
93103
Text = element.Name,
94104
HasChildren = element.HasChildren,
95105
Icon = "fa-solid fa-fw fa-cubes"
96-
}).ToList();
106+
})];
97107
}
98108

99109
private Task<IEnumerable<TreeViewItem<OpcBrowseElement>>> OnExpandNodeAsync(TreeViewItem<OpcBrowseElement> element)

0 commit comments

Comments
 (0)