Skip to content

Commit 28b9e75

Browse files
committed
fix some bug
1 parent d581c63 commit 28b9e75

File tree

7 files changed

+71
-50
lines changed

7 files changed

+71
-50
lines changed

src/BlazorAdmin/BlazorAdmin.Core/Data/DatabaseExtension.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ public static void InitialData(this BlazorAdminDbContext dbContext, bool isCreat
119119
var entry = dbContext.Menus.Add(new Menu { Name = "日志", Type = 1, Route = "/", Order = 2, Icon = Icons.Material.Filled.Info });
120120
var entry2 = dbContext.Menus.Add(new Menu { Name = "权限", Type = 1, Route = "/", Order = 3, Icon = Icons.Material.Filled.VerifiedUser });
121121
var entry3 = dbContext.Menus.Add(new Menu { Name = "系统", Type = 1, Route = "/", Order = 4, Icon = Icons.Material.Filled.Computer });
122-
dbContext.Menus.Add(new Menu { Name = "关于", Type = 1, Route = "/about", Order = 4, Icon = Icons.Material.Filled.TextFields });
122+
//var aiEntry = dbContext.Menus.Add(new Menu { Name = "AI", Type = 1, Route = "/", Order = 5, Icon = Icons.Material.Filled.Grain });
123+
dbContext.Menus.Add(new Menu { Name = "关于", Type = 1, Route = "/about", Order = 6, Icon = Icons.Material.Filled.TextFields });
123124
dbContext.SaveChanges();
124125

125126
dbContext.Menus.Add(new Menu { ParentId = entry.Entity.Id, Name = "审计", Type = 1, Route = "/auditLog", Order = 1, Icon = Icons.Material.Filled.Verified });
126127
dbContext.Menus.Add(new Menu { ParentId = entry.Entity.Id, Name = "登录", Type = 1, Route = "/loginLog", Order = 2, Icon = Icons.Material.Filled.Login });
127-
128128
dbContext.SaveChanges();
129129

130130
var userManageEnty = dbContext.Menus.Add(new Menu { ParentId = entry2.Entity.Id, Name = "用户", Type = 1, Route = "/user", Order = 1, Icon = Icons.Material.Filled.Person });
@@ -135,11 +135,13 @@ public static void InitialData(this BlazorAdminDbContext dbContext, bool isCreat
135135

136136
dbContext.Menus.Add(new Menu { ParentId = entry3.Entity.Id, Name = "配置", Type = 1, Route = "/setting", Order = 1, Icon = Icons.Material.Filled.Settings });
137137
dbContext.Menus.Add(new Menu { ParentId = entry3.Entity.Id, Name = "指标", Type = 1, Route = "/appmetric", Order = 2, Icon = Icons.Material.Filled.AutoGraph });
138-
//var aiConfigPage = dbContext.Menus.Add(new Menu { ParentId = entry3.Entity.Id, Name = "Ai配置", Type = 1, Route = "/ai/config", Order = 3, Icon = Icons.Material.Filled.Grain });
139-
//var arRecordPage = dbContext.Menus.Add(new Menu { ParentId = entry3.Entity.Id, Name = "Ai记录", Type = 1, Route = "/ai/requestrecord", Order = 4, Icon = Icons.Material.Filled.RequestPage });
140-
//var arPromptPage = dbContext.Menus.Add(new Menu { ParentId = entry3.Entity.Id, Name = "Ai提示词", Type = 1, Route = "/ai/prompt", Order = 5, Icon = Icons.Material.Filled.RequestPage });
141138
dbContext.SaveChanges();
142139

140+
//var aiConfigPage = dbContext.Menus.Add(new Menu { ParentId = aiEntry.Entity.Id, Name = "Ai配置", Type = 1, Route = "/ai/config", Order = 3, Icon = Icons.Material.Filled.SettingsInputComponent });
141+
//var arRecordPage = dbContext.Menus.Add(new Menu { ParentId = aiEntry.Entity.Id, Name = "Ai记录", Type = 1, Route = "/ai/requestrecord", Order = 4, Icon = Icons.Material.Filled.RequestPage });
142+
//var arPromptPage = dbContext.Menus.Add(new Menu { ParentId = aiEntry.Entity.Id, Name = "Ai提示词", Type = 1, Route = "/ai/prompt", Order = 5, Icon = Icons.Material.Filled.TipsAndUpdates });
143+
//dbContext.SaveChanges();
144+
143145
dbContext.Menus.Add(new Menu { ParentId = userManageEnty.Entity.Id, Name = "添加按钮", Type = 2, Order = 1, Identify = "UserAddBtn" });
144146
dbContext.Menus.Add(new Menu { ParentId = userManageEnty.Entity.Id, Name = "修改按钮", Type = 2, Order = 2, Identify = "UserUpdateBtn" });
145147
dbContext.Menus.Add(new Menu { ParentId = userManageEnty.Entity.Id, Name = "删除按钮", Type = 2, Order = 3, Identify = "UserDeleteBtn" });

src/BlazorAdmin/BlazorAdmin.Core/Services/AccessService.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using BlazorAdmin.Core.Extension;
22
using BlazorAdmin.Data;
3+
using BlazorAdmin.Data.Entities.Rbac;
34
using Microsoft.AspNetCore.Components.Authorization;
45
using Microsoft.EntityFrameworkCore;
56
using Microsoft.Extensions.Caching.Memory;
@@ -14,6 +15,10 @@ public interface IAccessService
1415
Task<bool> CheckUriCanAccess(string url);
1516

1617
Task<bool> CheckHasElementRights(string identify);
18+
19+
Task<List<int>> GetUserOrganizationIds();
20+
21+
Task<User?> GetUserInfo();
1722
}
1823

1924
public class AccessService : IAccessService
@@ -132,5 +137,19 @@ join o in context.Organizations on ou.OrganizationId equals o.Id
132137
});
133138
return identities ?? new();
134139
}
140+
141+
public async Task<User?> GetUserInfo()
142+
{
143+
var userState = await _stateProvider.GetAuthenticationStateAsync();
144+
if (userState.User.Identity == null || !userState.User.Identity.IsAuthenticated)
145+
{
146+
return null;
147+
}
148+
149+
var userId = userState.User.GetUserId();
150+
151+
using var context = await _dbContextFactory.CreateDbContextAsync();
152+
return await context.Users.FindAsync(userId);
153+
}
135154
}
136155
}

src/BlazorAdmin/BlazorAdmin.Modules/BlazorAdmin.Layout/Components/NavMenus/NavOpenButton.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@rendermode InteractiveServer
22

3-
<MudHidden Breakpoint="Breakpoint.Sm|Breakpoint.Xs" Invert="true">
3+
<MudHidden Breakpoint="Breakpoint.SmAndDown|Breakpoint.Xs" Invert="true">
44
<MudIconButton Icon="@(_layoutState.NavIsOpen ? IconsConstant.MenuCollapsed : IconsConstant.MenuExpand)" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => DrawerToggle())" />
55
</MudHidden>
66
@code {
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
@using BlazorAdmin.Layout.Components.Themes
22
@inherits LayoutComponentBase
33

4+
<ProvidersAggregate></ProvidersAggregate>
5+
46
<div style="width: 100%; height: 100vh;">
5-
@ChildContent
7+
@Body
68
</div>

src/BlazorAdmin/BlazorAdmin.Web/Components/Layout/MainLayout.razor

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
</AuthorizedLayout>
1919
</Authorized>
2020
<NotAuthorized>
21-
<EmptyLayout>
22-
@Body
23-
</EmptyLayout>
21+
@Body
2422
</NotAuthorized>
2523
</AuthorizeView>
2624
</MudLayout>

src/BlazorAdmin/BlazorAdmin.Web/Components/Shared/NoAuthorizedPage.razor

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,45 @@
77
@page "/noauthorized"
88

99
<MudPaper Style="width:100%;height:100vh;" Class="d-flex justify-center align-center flex-column">
10-
<div class="container">
11-
<div class="tree">
12-
<div class="branch" style="--x:0">
13-
<span style="--i:0;"></span>
14-
<span style="--i:1;"></span>
15-
<span style="--i:2;"></span>
16-
<span style="--i:3;"></span>
17-
</div>
18-
<div class="branch" style="--x:1">
19-
<span style="--i:0;"></span>
20-
<span style="--i:1;"></span>
21-
<span style="--i:2;"></span>
22-
<span style="--i:3;"></span>
23-
</div>
24-
<div class="branch" style="--x:2">
25-
<span style="--i:0;"></span>
26-
<span style="--i:1;"></span>
27-
<span style="--i:2;"></span>
28-
<span style="--i:3;"></span>
29-
</div>
30-
<div class="branch" style="--x:3">
31-
<span style="--i:0;"></span>
32-
<span style="--i:1;"></span>
33-
<span style="--i:2;"></span>
34-
<span style="--i:3;"></span>
35-
</div>
36-
<div class="stem">
37-
<span style="--i:0;"></span>
38-
<span style="--i:1;"></span>
39-
<span style="--i:2;"></span>
40-
<span style="--i:3;"></span>
41-
</div>
42-
<span class="shadow"></span>
43-
</div>
44-
</div>
45-
<MudText Typo="Typo.h4">@Loc["NoAuhtorized_Text"]</MudText>
46-
<MudButton OnClick="LogoutClick" Variant="Variant.Text" Color="Color.Primary">
47-
@Loc["NoAuhtorized_ChangeUserText"]
48-
</MudButton>
10+
<div class="container">
11+
<div class="tree">
12+
<div class="branch" style="--x:0">
13+
<span style="--i:0;"></span>
14+
<span style="--i:1;"></span>
15+
<span style="--i:2;"></span>
16+
<span style="--i:3;"></span>
17+
</div>
18+
<div class="branch" style="--x:1">
19+
<span style="--i:0;"></span>
20+
<span style="--i:1;"></span>
21+
<span style="--i:2;"></span>
22+
<span style="--i:3;"></span>
23+
</div>
24+
<div class="branch" style="--x:2">
25+
<span style="--i:0;"></span>
26+
<span style="--i:1;"></span>
27+
<span style="--i:2;"></span>
28+
<span style="--i:3;"></span>
29+
</div>
30+
<div class="branch" style="--x:3">
31+
<span style="--i:0;"></span>
32+
<span style="--i:1;"></span>
33+
<span style="--i:2;"></span>
34+
<span style="--i:3;"></span>
35+
</div>
36+
<div class="stem">
37+
<span style="--i:0;"></span>
38+
<span style="--i:1;"></span>
39+
<span style="--i:2;"></span>
40+
<span style="--i:3;"></span>
41+
</div>
42+
<span class="shadow"></span>
43+
</div>
44+
</div>
45+
<MudText Typo="Typo.h4">@Loc["NoAuhtorized_Text"]</MudText>
46+
<MudButton OnClick="LogoutClick" Variant="Variant.Filled" Color="Color.Primary">
47+
@Loc["NoAuhtorized_ChangeUserText"]
48+
</MudButton>
4949

5050

5151

src/BlazorAdmin/BlazorAdmin.Web/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"AllowedHosts": "*",
4848
"Application": {
4949
"DatabaseProvider": "Sqlite", // Supported values: Sqlite, SqlServer
50-
"ConnectionString": "Data Source=DB/BlazorAdmin20250221.db;Cache=Shared",
50+
"ConnectionString": "Data Source=DB/BlazorAdmin20250226.db;Cache=Shared",
5151
"UseQuartz": true
5252
}
5353
}

0 commit comments

Comments
 (0)