Skip to content

Commit 13d3d50

Browse files
committed
2 parents b681b91 + 60d1be7 commit 13d3d50

File tree

12 files changed

+86
-44
lines changed

12 files changed

+86
-44
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+
}

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)

src/BootstrapBlazor.Server/Components/Samples/Table/TablesEdit.razor

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@
101101
OnQueryAsync="@OnQueryAsync"
102102
OnAddAsync="@OnAddAsync" OnSaveAsync="@OnSaveAsync" OnDeleteAsync="@OnDeleteAsync">
103103
<TableColumns>
104-
<TableColumn @bind-Field="@context.DateTime" Width="180" />
104+
<TableColumn @bind-Field="@context.DateTime" Width="180">
105+
<EditTemplate Context="v">
106+
<div class="col-12 col-sm-6">
107+
<DateTimePicker @bind-Value="v.DateTime" ViewMode="DatePickerViewMode.DateTime" />
108+
</div>
109+
</EditTemplate>
110+
</TableColumn>
105111
<TableColumn @bind-Field="@context.Name">
106112
<EditTemplate Context="v">
107113
<div class="col-12 col-sm-6">

src/BootstrapBlazor/Components/Reconnector/ReconnectorContent.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
@inherits BootstrapModuleComponentBase
33
@attribute [BootstrapModuleAutoLoader("Reconnector/ReconnectorContent.razor.js", AutoInvokeDispose = false)]
44

5-
<div id="components-reconnect-modal">
5+
<div id="components-reconnect-modal" data-nosnippet>
66
<div class="reconnect-state show">
77
@if (ReconnectingTemplate != null)
88
{

0 commit comments

Comments
 (0)