Skip to content

Commit 7bb19dd

Browse files
committed
添加复现demo
1 parent a609da9 commit 7bb19dd

26 files changed

+618
-4
lines changed

BootstrapBlazor.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
3+
# 17
44
VisualStudioVersion = 17.0.31912.275
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootstrapBlazor", "src\BootstrapBlazor\BootstrapBlazor.csproj", "{D0AE3016-4878-4807-A04C-C33CBEC7B092}"
@@ -60,6 +60,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "configuration", "configurat
6060
EndProject
6161
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UniTestSvgIcon", "test\UniTestSvgIcon\UniTestSvgIcon.csproj", "{01DA4687-0973-4CA6-97F5-04E0B8DD1B13}"
6262
EndProject
63+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorApp2", "src\BlazorApp2\BlazorApp2.csproj", "{85A53603-77B8-4051-9D4C-5655C20571ED}"
64+
EndProject
6365
Global
6466
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6567
Debug|Any CPU = Debug|Any CPU
@@ -94,6 +96,10 @@ Global
9496
{01DA4687-0973-4CA6-97F5-04E0B8DD1B13}.Debug|Any CPU.Build.0 = Debug|Any CPU
9597
{01DA4687-0973-4CA6-97F5-04E0B8DD1B13}.Release|Any CPU.ActiveCfg = Release|Any CPU
9698
{01DA4687-0973-4CA6-97F5-04E0B8DD1B13}.Release|Any CPU.Build.0 = Release|Any CPU
99+
{85A53603-77B8-4051-9D4C-5655C20571ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
100+
{85A53603-77B8-4051-9D4C-5655C20571ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
101+
{85A53603-77B8-4051-9D4C-5655C20571ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
102+
{85A53603-77B8-4051-9D4C-5655C20571ED}.Release|Any CPU.Build.0 = Release|Any CPU
97103
EndGlobalSection
98104
GlobalSection(SolutionProperties) = preSolution
99105
HideSolutionNode = FALSE
@@ -109,6 +115,7 @@ Global
109115
{6D73FED6-0086-460B-84FA-1FA78176BF59} = {7C1D79F1-87BC-42C1-BD5A-CDE4044AC1BD}
110116
{D8AEAFE7-10AF-4A5B-BC67-FE740A2CA1DF} = {7C1D79F1-87BC-42C1-BD5A-CDE4044AC1BD}
111117
{01DA4687-0973-4CA6-97F5-04E0B8DD1B13} = {7C1D79F1-87BC-42C1-BD5A-CDE4044AC1BD}
118+
{85A53603-77B8-4051-9D4C-5655C20571ED} = {A2182155-43ED-44C1-BF6F-1B70EBD2DFFE}
112119
EndGlobalSection
113120
GlobalSection(ExtensibilityGlobals) = postSolution
114121
SolutionGuid = {0DCB0756-34FA-4FD0-AE1D-D3F08B5B3A6B}

src/BlazorApp2/BlazorApp2.csproj

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
</ItemGroup>
10+
<ItemGroup>
11+
<ProjectReference Include="..\BootstrapBlazor\BootstrapBlazor.csproj" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
@using BootstrapBlazor.Components
2+
@using Microsoft.AspNetCore.Components.Web
3+
@using Microsoft.Extensions.Localization
4+
@using ThingsGateway.Razor
5+
@inject IHostEnvironment Env
6+
@inject IStringLocalizer<App> Localizer
7+
@namespace ThingsGateway
8+
<!DOCTYPE html>
9+
<html lang="en" data-bs-theme='light'>
10+
11+
<head>
12+
<meta charset="utf-8" />
13+
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
14+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
15+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
16+
<meta name="keywords" content="thingsgateway,iot,netcore,blazor">
17+
<meta name="description" content="ThingsGateway边缘采集网关">
18+
<meta name="author" content="Diego">
19+
<link rel="icon" href="favicon.ico" type="image/x-icon">
20+
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
21+
<link rel="apple-touch-icon" href="favicon.png">
22+
<base href="/" />
23+
<title>ThingsGateway</title>
24+
<link rel="stylesheet" href="_content/BootstrapBlazor.FontAwesome/css/font-awesome.min.css" />
25+
<link rel="stylesheet" href="_content/BootstrapBlazor/css/bootstrap.blazor.bundle.min.css" />
26+
<link rel="stylesheet" href="_content/BootstrapBlazor/css/motronic.min.css" />
27+
<link rel="stylesheet" href="BlazorApp2.styles.css" />
28+
@* <script src=@($"{WebsiteConst.DefaultResourceUrl}js/theme.js") type="module"></script><!-- 初始主题 --> *@
29+
<!-- PWA Manifest -->
30+
<link rel="manifest" href="./manifest.json" />
31+
<HeadOutlet @rendermode="new InteractiveServerRenderMode(false)" />
32+
</head>
33+
34+
<body>
35+
<Routes @rendermode="new InteractiveServerRenderMode(false)" />
36+
37+
<script src="_content/BootstrapBlazor/js/bootstrap.blazor.bundle.min.js"></script>
38+
<script src="_framework/blazor.web.js"></script>
39+
<!-- PWA Service Worker -->
40+
<script type="text/javascript">'serviceWorker' in navigator && navigator.serviceWorker.register('./service-worker.js')</script>
41+
42+
</body>
43+
44+
</html>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@inherits LayoutComponentBase
2+
@using BootstrapBlazor.Components
3+
@namespace ThingsGateway.Razor
4+
5+
@* BB根组件 *@
6+
<BootstrapBlazorRoot>
7+
@Body
8+
9+
</BootstrapBlazorRoot>
10+
11+
12+

src/BlazorApp2/Components/Layout/BaseLayout.razor.css

Whitespace-only changes.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//------------------------------------------------------------------------------
2+
// 此代码版权声明为全文件覆盖,如有原作者特别声明,会在下方手动补充
3+
// 此代码版权(除特别声明外的代码)归作者本人Diego所有
4+
// 源代码使用协议遵循本仓库的开源协议及附加协议
5+
// Gitee源代码仓库:https://gitee.com/diego2098/ThingsGateway
6+
// Github源代码仓库:https://github.com/kimdiego2098/ThingsGateway
7+
// 使用文档:https://thingsgateway.cn/
8+
// QQ群:605534569
9+
//------------------------------------------------------------------------------
10+
11+
using BootstrapBlazor.Components;
12+
13+
namespace ThingsGateway.Razor;
14+
15+
/// <inheritdoc/>
16+
public interface IMenuService
17+
{
18+
/// <inheritdoc/>
19+
public IEnumerable<MenuItem>? MenuItems { get; }
20+
21+
}
22+
23+
public class DefaultMenuService : IMenuService
24+
{
25+
26+
public IEnumerable<MenuItem>? MenuItems => new List<MenuItem>() {
27+
28+
new MenuItem("home","/"),
29+
new MenuItem("counter","/counter"),
30+
new MenuItem("error","/error"),
31+
new MenuItem("weather","/weather"),
32+
33+
34+
35+
};
36+
37+
38+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@using BootstrapBlazor.Components
2+
@using System.Diagnostics.CodeAnalysis
3+
@using ThingsGateway.Razor
4+
@inherits BaseLayout
5+
<Layout SideWidth="0" IsPage="true" IsFullSide="true" IsFixedHeader="true"
6+
ShowGotoTop="true" ShowCollapseBar="true"
7+
AllowDragTab=true Menus="@MenuService.MenuItems"
8+
UseTabSet="false" TabDefaultUrl="/">
9+
<Side>
10+
11+
</Side>
12+
<Main>
13+
<Tab ClickTabToNavigation="true" ShowExtendButtons="false" ShowClose="true" AllowDrag=true Menus="@MenuService.MenuItems"
14+
DefaultUrl=@("/") Body=@(Body!) >
15+
</Tab>
16+
17+
</Main>
18+
</Layout>
19+
20+
21+
22+
23+
@code{
24+
[Inject]
25+
[NotNull]
26+
private IMenuService? MenuService { get; set; }
27+
}

src/BlazorApp2/Components/Layout/MainLayout.razor.css

Whitespace-only changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<div class="top-row ps-3 navbar navbar-dark">
2+
<div class="container-fluid">
3+
<a class="navbar-brand" href="">BlazorApp2</a>
4+
</div>
5+
</div>
6+
7+
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
8+
9+
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
10+
<nav class="flex-column">
11+
<div class="nav-item px-3">
12+
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
13+
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
14+
</NavLink>
15+
</div>
16+
17+
<div class="nav-item px-3">
18+
<NavLink class="nav-link" href="counter">
19+
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
20+
</NavLink>
21+
</div>
22+
23+
<div class="nav-item px-3">
24+
<NavLink class="nav-link" href="weather">
25+
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
26+
</NavLink>
27+
</div>
28+
</nav>
29+
</div>
30+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
.navbar-toggler {
2+
appearance: none;
3+
cursor: pointer;
4+
width: 3.5rem;
5+
height: 2.5rem;
6+
color: white;
7+
position: absolute;
8+
top: 0.5rem;
9+
right: 1rem;
10+
border: 1px solid rgba(255, 255, 255, 0.1);
11+
background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1);
12+
}
13+
14+
.navbar-toggler:checked {
15+
background-color: rgba(255, 255, 255, 0.5);
16+
}
17+
18+
.top-row {
19+
height: 3.5rem;
20+
background-color: rgba(0,0,0,0.4);
21+
}
22+
23+
.navbar-brand {
24+
font-size: 1.1rem;
25+
}
26+
27+
.bi {
28+
display: inline-block;
29+
position: relative;
30+
width: 1.25rem;
31+
height: 1.25rem;
32+
margin-right: 0.75rem;
33+
top: -1px;
34+
background-size: cover;
35+
}
36+
37+
.bi-house-door-fill-nav-menu {
38+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E");
39+
}
40+
41+
.bi-plus-square-fill-nav-menu {
42+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E");
43+
}
44+
45+
.bi-list-nested-nav-menu {
46+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E");
47+
}
48+
49+
.nav-item {
50+
font-size: 0.9rem;
51+
padding-bottom: 0.5rem;
52+
}
53+
54+
.nav-item:first-of-type {
55+
padding-top: 1rem;
56+
}
57+
58+
.nav-item:last-of-type {
59+
padding-bottom: 1rem;
60+
}
61+
62+
.nav-item ::deep .nav-link {
63+
color: #d7d7d7;
64+
background: none;
65+
border: none;
66+
border-radius: 4px;
67+
height: 3rem;
68+
display: flex;
69+
align-items: center;
70+
line-height: 3rem;
71+
width: 100%;
72+
}
73+
74+
.nav-item ::deep a.active {
75+
background-color: rgba(255,255,255,0.37);
76+
color: white;
77+
}
78+
79+
.nav-item ::deep .nav-link:hover {
80+
background-color: rgba(255,255,255,0.1);
81+
color: white;
82+
}
83+
84+
.nav-scrollable {
85+
display: none;
86+
}
87+
88+
.navbar-toggler:checked ~ .nav-scrollable {
89+
display: block;
90+
}
91+
92+
@media (min-width: 641px) {
93+
.navbar-toggler {
94+
display: none;
95+
}
96+
97+
.nav-scrollable {
98+
/* Never collapse the sidebar for wide screens */
99+
display: block;
100+
101+
/* Allow sidebar to scroll for tall menus */
102+
height: calc(100vh - 3.5rem);
103+
overflow-y: auto;
104+
}
105+
}

0 commit comments

Comments
 (0)