From f9c3c85301748c2204e4389e07b33c896b594d04 Mon Sep 17 00:00:00 2001 From: hello Date: Thu, 15 May 2025 22:35:31 +0800 Subject: [PATCH] =?UTF-8?q?Blazor=20=E7=BB=84=E4=BB=B6=20CSS=20=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E7=9A=84=E5=85=B1=E4=BA=AB=E4=B8=8E=E9=9A=94=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DaprComponents/redis-lock.yaml | 5 ++--- src/HelloShop.AppHost/Program.cs | 3 ++- src/HelloShop.AppHost/appsettings.json | 3 ++- .../Components/Demo/CountComponent.razor | 19 +++++++++++++++++++ .../Components/Demo/CountComponent.razor.css | 3 +++ .../Components/Pages/Counter.razor | 16 ++-------------- src/HelloShop.AppShared/wwwroot/app.css | 4 ++++ .../Components/Pages/Component1.razor | 2 +- src/HelloShop.HybridApp/wwwroot/index.html | 2 +- .../Components/Pages/Component2.razor | 5 ++++- .../Components/Pages/Component1.razor | 13 ++++++++++++- .../Components/Pages/Component1.razor.css | 4 ++++ .../Properties/launchSettings.json | 4 ++-- 13 files changed, 58 insertions(+), 25 deletions(-) create mode 100644 src/HelloShop.AppShared/Components/Demo/CountComponent.razor create mode 100644 src/HelloShop.AppShared/Components/Demo/CountComponent.razor.css create mode 100644 src/HelloShop.WebApp/HelloShop.WebApp/Components/Pages/Component1.razor.css diff --git a/src/HelloShop.AppHost/DaprComponents/redis-lock.yaml b/src/HelloShop.AppHost/DaprComponents/redis-lock.yaml index fe28ae5..9839bc6 100644 --- a/src/HelloShop.AppHost/DaprComponents/redis-lock.yaml +++ b/src/HelloShop.AppHost/DaprComponents/redis-lock.yaml @@ -7,9 +7,8 @@ spec: version: v1 metadata: - name: redisHost - secretKeyRef: - name: ConnectionStrings__cache + value: "localhost:6379" - name: redisPassword - value: "" + value: "guest" auth: secretStore: env-secretstore \ No newline at end of file diff --git a/src/HelloShop.AppHost/Program.cs b/src/HelloShop.AppHost/Program.cs index 2558785..52cb8aa 100644 --- a/src/HelloShop.AppHost/Program.cs +++ b/src/HelloShop.AppHost/Program.cs @@ -13,7 +13,8 @@ var identitydb = postgres.AddDatabase("identitydb"); var productdb = postgres.AddDatabase("productdb"); var orderingdb = postgres.AddDatabase("orderingdb"); -var cache = builder.AddRedis("cache", port: 6380).WithLifetime(ContainerLifetime.Persistent).WithPersistence(); +var redisPassword = builder.AddParameter("redisPassword", secret: true); +var cache = builder.AddRedis("cache", port: 6379, password: redisPassword).WithLifetime(ContainerLifetime.Persistent).WithPersistence(); var rabbitmqUser = builder.AddParameter("rabbitmqUser", secret: true); var rabbitmqPassword = builder.AddParameter("rabbitmqPassword", secret: true); diff --git a/src/HelloShop.AppHost/appsettings.json b/src/HelloShop.AppHost/appsettings.json index ec31b2e..a141799 100644 --- a/src/HelloShop.AppHost/appsettings.json +++ b/src/HelloShop.AppHost/appsettings.json @@ -10,6 +10,7 @@ "postgreUser": "postgres", "postgrePassword": "postgres", "rabbitmqUser": "guest", - "rabbitmqPassword": "guest" + "rabbitmqPassword": "guest", + "redisPassword": "guest" } } diff --git a/src/HelloShop.AppShared/Components/Demo/CountComponent.razor b/src/HelloShop.AppShared/Components/Demo/CountComponent.razor new file mode 100644 index 0000000..ca873a7 --- /dev/null +++ b/src/HelloShop.AppShared/Components/Demo/CountComponent.razor @@ -0,0 +1,19 @@ +

@Title

+ +

Current count: @InitCount

+ + + +@code { + + [Parameter] + public string? Title { get; set; } + + [Parameter] + public int InitCount { get; set; } + + private void IncrementCount() + { + InitCount++; + } +} \ No newline at end of file diff --git a/src/HelloShop.AppShared/Components/Demo/CountComponent.razor.css b/src/HelloShop.AppShared/Components/Demo/CountComponent.razor.css new file mode 100644 index 0000000..acd1008 --- /dev/null +++ b/src/HelloShop.AppShared/Components/Demo/CountComponent.razor.css @@ -0,0 +1,3 @@ +h1 { + color:dodgerblue; +} diff --git a/src/HelloShop.AppShared/Components/Pages/Counter.razor b/src/HelloShop.AppShared/Components/Pages/Counter.razor index edb6b54..ea26617 100644 --- a/src/HelloShop.AppShared/Components/Pages/Counter.razor +++ b/src/HelloShop.AppShared/Components/Pages/Counter.razor @@ -1,19 +1,7 @@ @page "/counter" @rendermode InteractiveAuto +@using HelloShop.AppShared.Components.Demo Counter -

Counter

- -

Current count: @currentCount

- - - -@code { - private int currentCount = 0; - - private void IncrementCount() - { - currentCount++; - } -} \ No newline at end of file + diff --git a/src/HelloShop.AppShared/wwwroot/app.css b/src/HelloShop.AppShared/wwwroot/app.css index 73a69d6..1d4ad64 100644 --- a/src/HelloShop.AppShared/wwwroot/app.css +++ b/src/HelloShop.AppShared/wwwroot/app.css @@ -57,4 +57,8 @@ h1:focus { .form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder { text-align: start; +} + +.counter-value { + color:orangered; } \ No newline at end of file diff --git a/src/HelloShop.HybridApp/Components/Pages/Component1.razor b/src/HelloShop.HybridApp/Components/Pages/Component1.razor index 17018ba..1876ab1 100644 --- a/src/HelloShop.HybridApp/Components/Pages/Component1.razor +++ b/src/HelloShop.HybridApp/Components/Pages/Component1.razor @@ -1,3 +1,3 @@ @page "/component1" -

Component1

\ No newline at end of file +

Component1

\ No newline at end of file diff --git a/src/HelloShop.HybridApp/wwwroot/index.html b/src/HelloShop.HybridApp/wwwroot/index.html index 73abb89..1dc847b 100644 --- a/src/HelloShop.HybridApp/wwwroot/index.html +++ b/src/HelloShop.HybridApp/wwwroot/index.html @@ -6,7 +6,7 @@ HelloShop.HybridApp - + diff --git a/src/HelloShop.WebApp/HelloShop.WebApp.Client/Components/Pages/Component2.razor b/src/HelloShop.WebApp/HelloShop.WebApp.Client/Components/Pages/Component2.razor index 612de20..53e3cca 100644 --- a/src/HelloShop.WebApp/HelloShop.WebApp.Client/Components/Pages/Component2.razor +++ b/src/HelloShop.WebApp/HelloShop.WebApp.Client/Components/Pages/Component2.razor @@ -1,4 +1,7 @@ @page "/component2" @rendermode InteractiveAuto +@using HelloShop.AppShared.Components.Demo -

Component2

\ No newline at end of file +

Component2

+ + diff --git a/src/HelloShop.WebApp/HelloShop.WebApp/Components/Pages/Component1.razor b/src/HelloShop.WebApp/HelloShop.WebApp/Components/Pages/Component1.razor index 389a130..16aefde 100644 --- a/src/HelloShop.WebApp/HelloShop.WebApp/Components/Pages/Component1.razor +++ b/src/HelloShop.WebApp/HelloShop.WebApp/Components/Pages/Component1.razor @@ -1,4 +1,15 @@ @page "/component1" @rendermode InteractiveServer -

Component1

\ No newline at end of file +@using HelloShop.AppShared.Components.Demo + +

Component1

+ +
+ +
+ +
+ +
+ diff --git a/src/HelloShop.WebApp/HelloShop.WebApp/Components/Pages/Component1.razor.css b/src/HelloShop.WebApp/HelloShop.WebApp/Components/Pages/Component1.razor.css new file mode 100644 index 0000000..60f04d6 --- /dev/null +++ b/src/HelloShop.WebApp/HelloShop.WebApp/Components/Pages/Component1.razor.css @@ -0,0 +1,4 @@ +::deep .counter-value { + font-size: 2rem; + font-weight: bold; +} diff --git a/src/HelloShop.WebApp/HelloShop.WebApp/Properties/launchSettings.json b/src/HelloShop.WebApp/HelloShop.WebApp/Properties/launchSettings.json index 914a563..82abc87 100644 --- a/src/HelloShop.WebApp/HelloShop.WebApp/Properties/launchSettings.json +++ b/src/HelloShop.WebApp/HelloShop.WebApp/Properties/launchSettings.json @@ -6,7 +6,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "http://localhost:5224", + "applicationUrl": "http://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -16,7 +16,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", - "applicationUrl": "https://localhost:7169;http://localhost:5224", + "applicationUrl": "https://localhost:8181;http://localhost:8080", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" }