feat: 更改结构

main
bicijinlian 1 year ago
parent d4b88cf515
commit 268a919e48

@ -1,4 +1,4 @@
<Router AppAssembly="@typeof(App).Assembly">
<Router AppAssembly="@typeof(BlazorSharedDemo.ServerApp.App).Assembly">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
@ -10,3 +10,6 @@
</LayoutView>
</NotFound>
</Router>
@{
}

@ -1,3 +1,4 @@
@page "/"
@*如果组件的路由与共享Razor类库中组件的路由相同则会覆盖(替换)共享类库的路由*@
@page "/"
<h1>ServerApp Hello!</h1>

@ -5,10 +5,11 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<!DOCTYPE html>
<html lang="en">
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<base href="~/" />
<link rel="shortcut icon" href="favicon.ico">
<link href="css/site.css" rel="stylesheet" />
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" />
</head>
@ -22,7 +23,7 @@
<environment include="Development">
An unhandled exception has occurred. See browser dev tools for details.
</environment>
<a href="" class="reload">Reload</a>
<a href="" class="reload">重新加载</a>
<a class="dismiss">🗙</a>
</div>

@ -2,6 +2,13 @@ using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
var builder = WebApplication.CreateBuilder(args);
//非开发模式也启用静态资产
if (!builder.Environment.IsDevelopment())
{
builder.WebHost.UseStaticWebAssets();
}
builder.WebHost.UseStaticWebAssets();
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();

@ -6,20 +6,20 @@
}
},
"profiles": {
"http": {
"ServerApp": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5037",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Production"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Production"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@ -17,7 +17,6 @@
<ItemGroup>
<Folder Include="Services\" />
<Folder Include="Shared\" />
<Folder Include="Models\" />
</ItemGroup>

@ -1,5 +1,14 @@
@inherits LayoutComponentBase
<HeadContent>
<link rel="stylesheet" href="_content/BlazorSharedDemo.SharedUI/css/SharedUI.css" />
<link rel="apple-touch-icon" sizes="180x180" href="_content/BlazorSharedDemo.SharedUI/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="_content/BlazorSharedDemo.SharedUI/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="_content/BlazorSharedDemo.SharedUI/favicon/favicon-16x16.png">
<link rel="manifest" href="_content/BlazorSharedDemo.SharedUI/favicon/site.webmanifest">
<link rel="shortcut icon" href="_content/BlazorSharedDemo.SharedUI/favicon/favicon.ico">
</HeadContent>
<main>
@Body
</main>

@ -1,7 +1,9 @@

@page "/"
<h3>SharedUI Hello!</h3>
<h1>SharedUI Hello!</h1>
<div>
<MyImage></MyImage>
</div>
@code {
}

@ -0,0 +1,24 @@
<div>
<ul>
<li>
<img src="_content/BlazorSharedDemo.SharedUI/images/01.jpg" alt="" />
</li>
<li>
<img src="_content/BlazorSharedDemo.SharedUI/images/02.jpg" alt="" />
</li>
<li>
<img src="_content/BlazorSharedDemo.SharedUI/images/03.jpg" alt="" />
</li>
<li>
<img src="_content/BlazorSharedDemo.SharedUI/images/04.jpg" alt="" />
</li>
<li>
<img src="_content/BlazorSharedDemo.SharedUI/images/05.jpg" alt="" />
</li>
</ul>
</div>
@code {
}

@ -1,2 +1,6 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.Routing
@using BlazorSharedDemo.SharedUI
@using BlazorSharedDemo.SharedUI.Pages
@using BlazorSharedDemo.SharedUI.Shared

@ -0,0 +1,3 @@
.SharedUI {
border:2px groove red;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 688 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 750 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 762 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 785 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 890 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 739 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@ -0,0 +1,12 @@
<Router AppAssembly="@typeof(App).Assembly" AdditionalAssemblies="new[] { typeof(BlazorSharedDemo.SharedUI.MainLayout).Assembly }">
<Found Context="routeData">
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
</Found>
<NotFound>
<PageTitle>未找到路由</PageTitle>
<LayoutView Layout="@typeof(MainLayout)">
<p role="alert">抱歉,此路由地址不存在!</p>
</LayoutView>
</NotFound>
</Router>

@ -1,3 +1,4 @@
@page "/"
@*路由不能与共享Razor类库的路由重复*@
@page "/app-index"
<h1>Hello, world!</h1>
<h1>Wasl Hello</h1>

@ -4,4 +4,6 @@
@using Microsoft.AspNetCore.Components.Web
@using Microsoft.AspNetCore.Components.WebAssembly.Http
@using Microsoft.JSInterop
@using BlazorSharedDemo.SharedUI
@using BlazorSharedDemo.WaslApp

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@ -5,6 +5,7 @@
<meta charset="utf-8" />
<title>WaslApp</title>
<base href="/" />
<link rel="shortcut icon" href="favicon.ico">
<link href="css/app.css" rel="stylesheet" />
<!-- If you add any scoped CSS files, uncomment the following to load them

Loading…
Cancel
Save