diff --git a/BlazorSharedDemo.SharedUI/App.razor b/BlazorSharedDemo.ServerApp/App.razor similarity index 82% rename from BlazorSharedDemo.SharedUI/App.razor rename to BlazorSharedDemo.ServerApp/App.razor index 39b707d..221332b 100644 --- a/BlazorSharedDemo.SharedUI/App.razor +++ b/BlazorSharedDemo.ServerApp/App.razor @@ -1,4 +1,4 @@ - + @@ -10,3 +10,6 @@ +@{ + +} diff --git a/BlazorSharedDemo.ServerApp/Pages/Index.razor b/BlazorSharedDemo.ServerApp/Pages/Index.razor index 864a8e9..37f8527 100644 --- a/BlazorSharedDemo.ServerApp/Pages/Index.razor +++ b/BlazorSharedDemo.ServerApp/Pages/Index.razor @@ -1,3 +1,4 @@ -@page "/" +@*如果组件的路由与共享Razor类库中组件的路由相同,则会覆盖(替换)共享类库的路由*@ +@page "/"

ServerApp Hello!

diff --git a/BlazorSharedDemo.ServerApp/Pages/_Host.cshtml b/BlazorSharedDemo.ServerApp/Pages/_Host.cshtml index 36bd90d..f82229a 100644 --- a/BlazorSharedDemo.ServerApp/Pages/_Host.cshtml +++ b/BlazorSharedDemo.ServerApp/Pages/_Host.cshtml @@ -5,10 +5,11 @@ @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers - + + @@ -22,7 +23,7 @@ An unhandled exception has occurred. See browser dev tools for details. - Reload + 重新加载 🗙 diff --git a/BlazorSharedDemo.ServerApp/Program.cs b/BlazorSharedDemo.ServerApp/Program.cs index 64f3979..31e81fc 100644 --- a/BlazorSharedDemo.ServerApp/Program.cs +++ b/BlazorSharedDemo.ServerApp/Program.cs @@ -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(); diff --git a/BlazorSharedDemo.ServerApp/Properties/launchSettings.json b/BlazorSharedDemo.ServerApp/Properties/launchSettings.json index d26524f..6978070 100644 --- a/BlazorSharedDemo.ServerApp/Properties/launchSettings.json +++ b/BlazorSharedDemo.ServerApp/Properties/launchSettings.json @@ -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" } } } diff --git a/BlazorSharedDemo.ServerApp/wwwroot/favicon.ico b/BlazorSharedDemo.ServerApp/wwwroot/favicon.ico new file mode 100644 index 0000000..f73913a Binary files /dev/null and b/BlazorSharedDemo.ServerApp/wwwroot/favicon.ico differ diff --git a/BlazorSharedDemo.SharedUI/BlazorSharedDemo.SharedUI.csproj b/BlazorSharedDemo.SharedUI/BlazorSharedDemo.SharedUI.csproj index 64059cd..b7fa154 100644 --- a/BlazorSharedDemo.SharedUI/BlazorSharedDemo.SharedUI.csproj +++ b/BlazorSharedDemo.SharedUI/BlazorSharedDemo.SharedUI.csproj @@ -17,7 +17,6 @@ - diff --git a/BlazorSharedDemo.SharedUI/MainLayout.razor b/BlazorSharedDemo.SharedUI/MainLayout.razor index de2be6c..cc352c0 100644 --- a/BlazorSharedDemo.SharedUI/MainLayout.razor +++ b/BlazorSharedDemo.SharedUI/MainLayout.razor @@ -1,5 +1,14 @@ @inherits LayoutComponentBase - + + + + + + + +
@Body
+ + diff --git a/BlazorSharedDemo.SharedUI/Pages/Index.razor b/BlazorSharedDemo.SharedUI/Pages/Index.razor index 77bf548..479c79b 100644 --- a/BlazorSharedDemo.SharedUI/Pages/Index.razor +++ b/BlazorSharedDemo.SharedUI/Pages/Index.razor @@ -1,7 +1,9 @@  @page "/" -

SharedUI Hello!

- +

SharedUI Hello!

+
+ +
@code { } diff --git a/BlazorSharedDemo.SharedUI/Shared/MyImage.razor b/BlazorSharedDemo.SharedUI/Shared/MyImage.razor new file mode 100644 index 0000000..bea9c54 --- /dev/null +++ b/BlazorSharedDemo.SharedUI/Shared/MyImage.razor @@ -0,0 +1,24 @@ +
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+ +
+ +@code { + +} diff --git a/BlazorSharedDemo.SharedUI/_Imports.razor b/BlazorSharedDemo.SharedUI/_Imports.razor index cef1c7e..84d56ad 100644 --- a/BlazorSharedDemo.SharedUI/_Imports.razor +++ b/BlazorSharedDemo.SharedUI/_Imports.razor @@ -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 diff --git a/BlazorSharedDemo.SharedUI/wwwroot/css/SharedUI.css b/BlazorSharedDemo.SharedUI/wwwroot/css/SharedUI.css new file mode 100644 index 0000000..849ac4f --- /dev/null +++ b/BlazorSharedDemo.SharedUI/wwwroot/css/SharedUI.css @@ -0,0 +1,3 @@ +.SharedUI { + border:2px groove red; +} diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/01.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/01.jpg new file mode 100644 index 0000000..b174767 Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/01.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/02.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/02.jpg new file mode 100644 index 0000000..c2f53b4 Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/02.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/03.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/03.jpg new file mode 100644 index 0000000..b610528 Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/03.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/04.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/04.jpg new file mode 100644 index 0000000..0632bc3 Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/04.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/05.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/05.jpg new file mode 100644 index 0000000..df28078 Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/05.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/06.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/06.jpg new file mode 100644 index 0000000..5554c7a Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/06.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/07.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/07.jpg new file mode 100644 index 0000000..5aabbd9 Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/07.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/08.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/08.jpg new file mode 100644 index 0000000..3ddeb1a Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/08.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/09.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/09.jpg new file mode 100644 index 0000000..b5b1b0f Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/09.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/10.jpg b/BlazorSharedDemo.SharedUI/wwwroot/images/10.jpg new file mode 100644 index 0000000..fcb595d Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/10.jpg differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/background.png b/BlazorSharedDemo.SharedUI/wwwroot/images/background.png similarity index 100% rename from BlazorSharedDemo.SharedUI/wwwroot/background.png rename to BlazorSharedDemo.SharedUI/wwwroot/images/background.png diff --git a/BlazorSharedDemo.SharedUI/wwwroot/images/favicon.ico b/BlazorSharedDemo.SharedUI/wwwroot/images/favicon.ico new file mode 100644 index 0000000..f73913a Binary files /dev/null and b/BlazorSharedDemo.SharedUI/wwwroot/images/favicon.ico differ diff --git a/BlazorSharedDemo.SharedUI/wwwroot/exampleJsInterop.js b/BlazorSharedDemo.SharedUI/wwwroot/js/exampleJsInterop.js similarity index 100% rename from BlazorSharedDemo.SharedUI/wwwroot/exampleJsInterop.js rename to BlazorSharedDemo.SharedUI/wwwroot/js/exampleJsInterop.js diff --git a/BlazorSharedDemo.WaslApp/App.razor b/BlazorSharedDemo.WaslApp/App.razor new file mode 100644 index 0000000..6d86efd --- /dev/null +++ b/BlazorSharedDemo.WaslApp/App.razor @@ -0,0 +1,12 @@ + + + + + + + 未找到路由 + +

抱歉,此路由地址不存在!

+
+
+
diff --git a/BlazorSharedDemo.WaslApp/Pages/Index.razor b/BlazorSharedDemo.WaslApp/Pages/Index.razor index cba3252..15e37e2 100644 --- a/BlazorSharedDemo.WaslApp/Pages/Index.razor +++ b/BlazorSharedDemo.WaslApp/Pages/Index.razor @@ -1,3 +1,4 @@ -@page "/" +@*路由不能与共享Razor类库的路由重复*@ +@page "/app-index" -

Hello, world!

+

Wasl Hello

diff --git a/BlazorSharedDemo.WaslApp/_Imports.razor b/BlazorSharedDemo.WaslApp/_Imports.razor index 31f23a9..67d5f0e 100644 --- a/BlazorSharedDemo.WaslApp/_Imports.razor +++ b/BlazorSharedDemo.WaslApp/_Imports.razor @@ -4,4 +4,6 @@ @using Microsoft.AspNetCore.Components.Web @using Microsoft.AspNetCore.Components.WebAssembly.Http @using Microsoft.JSInterop + +@using BlazorSharedDemo.SharedUI @using BlazorSharedDemo.WaslApp diff --git a/BlazorSharedDemo.WaslApp/wwwroot/favicon.ico b/BlazorSharedDemo.WaslApp/wwwroot/favicon.ico new file mode 100644 index 0000000..f73913a Binary files /dev/null and b/BlazorSharedDemo.WaslApp/wwwroot/favicon.ico differ diff --git a/BlazorSharedDemo.WaslApp/wwwroot/index.html b/BlazorSharedDemo.WaslApp/wwwroot/index.html index a6f2bb3..92cc7c7 100644 --- a/BlazorSharedDemo.WaslApp/wwwroot/index.html +++ b/BlazorSharedDemo.WaslApp/wwwroot/index.html @@ -5,6 +5,7 @@ WaslApp +