From 48cd5e7c7ff3cbea49d8f70f552bfaa223252757 Mon Sep 17 00:00:00 2001 From: Diego <2248356998@qq.com> Date: Sat, 31 May 2025 00:43:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=BC=94=E7=A4=BA=E7=AB=99?= =?UTF-8?q?=E7=9A=84gitee=E6=8E=88=E6=9D=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- .../Controller/AuthController.cs | 15 ++ .../Gitee/AdminOAuthHandler.cs | 212 ++++++++++++++++++ .../Gitee/AdminOAuthOptions.cs | 33 +++ .../Gitee/GiteeOAuthOptions.cs | 64 ++++++ .../Gitee/GiteeOAuthSettings.cs | 7 + .../Gitee/GiteeOAuthUser.cs | 12 + .../Gitee/OAuthUserExtensions.cs | 22 ++ .../Services/Auth/AuthService.cs | 15 +- .../Services/User/SysUserService.cs | 8 +- .../Context/BlazorAppContext.cs | 2 + .../Pages/UserCenter/UserCenterPage.razor.cs | 2 +- .../Index/AdminIndex.razor.cs | 4 - .../Layout/AccessDenied.razor.cs | 2 - .../Layout/Login.razor.cs | 9 - .../Layout/MainLayout.razor | 2 +- .../Layout/MainLayout.razor.cs | 36 --- .../Program/Program.cs | 2 - .../Program/Startup.cs | 11 - .../Const/ClaimConst.cs | 5 + .../Static/UserManager.cs | 6 + src/Directory.Build.props | 4 +- .../MainLayout.razor.cs | 33 --- src/ThingsGateway.Photino/Startup.cs | 7 - .../Layout/Login.razor.cs | 52 +++-- .../Layout/MainLayout.razor | 2 +- .../Layout/MainLayout.razor.cs | 33 --- src/ThingsGateway.Server/Program/Startup.cs | 20 +- .../Controler/AutoUpdateControler.cs | 2 - .../Index/AdminIndex.razor.cs | 6 - .../Layout/AccessDenied.razor.cs | 2 - .../Layout/Login.razor.cs | 9 - .../Layout/MainLayout.razor | 2 +- .../Layout/MainLayout.razor.cs | 39 ---- .../Program/Program.cs | 2 - .../Program/Startup.cs | 12 - .../Program/Startup1.cs | 2 - .../SeedData/SysRelationSeedData.cs | 1 - .../SeedData/SysResourceSeedData.cs | 2 - src/Version.props | 2 +- 40 files changed, 440 insertions(+), 264 deletions(-) create mode 100644 src/Admin/ThingsGateway.Admin.Application/Gitee/AdminOAuthHandler.cs create mode 100644 src/Admin/ThingsGateway.Admin.Application/Gitee/AdminOAuthOptions.cs create mode 100644 src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthOptions.cs create mode 100644 src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthSettings.cs create mode 100644 src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthUser.cs create mode 100644 src/Admin/ThingsGateway.Admin.Application/Gitee/OAuthUserExtensions.cs diff --git a/.gitignore b/.gitignore index 9d098c4ab..f6737084e 100644 --- a/.gitignore +++ b/.gitignore @@ -365,4 +365,5 @@ FodyWeavers.xsd /src/*Pro*/ /src/*Pro* /src/*pro* -/src/*pro*/ \ No newline at end of file +/src/*pro*/ +/src/ThingsGateway.Server/Configuration/GiteeOAuthSettings.json diff --git a/src/Admin/ThingsGateway.Admin.Application/Controller/AuthController.cs b/src/Admin/ThingsGateway.Admin.Application/Controller/AuthController.cs index 8a00e06bd..7e2568b0f 100644 --- a/src/Admin/ThingsGateway.Admin.Application/Controller/AuthController.cs +++ b/src/Admin/ThingsGateway.Admin.Application/Controller/AuthController.cs @@ -8,6 +8,7 @@ // QQ群:605534569 //------------------------------------------------------------------------------ +using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -29,9 +30,23 @@ public class AuthController : ControllerBase [AllowAnonymous] public Task LoginAsync([FromBody] LoginInput input) { + return _authService.LoginAsync(input); + } + [HttpGet("oauth-login")] + [AllowAnonymous] + public IActionResult OAuthLogin(string scheme = "Gitee", string returnUrl = "/") + { + var props = new AuthenticationProperties + { + RedirectUri = returnUrl + }; + return Challenge(props, scheme); + } + + [HttpPost("logout")] [Authorize] [IgnoreRolePermission] diff --git a/src/Admin/ThingsGateway.Admin.Application/Gitee/AdminOAuthHandler.cs b/src/Admin/ThingsGateway.Admin.Application/Gitee/AdminOAuthHandler.cs new file mode 100644 index 000000000..5158da21b --- /dev/null +++ b/src/Admin/ThingsGateway.Admin.Application/Gitee/AdminOAuthHandler.cs @@ -0,0 +1,212 @@ +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; + +using System.Net.Http.Headers; +using System.Security.Claims; +using System.Text; +using System.Text.Encodings.Web; +using System.Text.Json; + +namespace ThingsGateway.Admin.Application; + +/// +/// 只适合 Demo 登录,会直接授权超管的权限 +/// +public class AdminOAuthHandler( + IVerificatInfoService verificatInfoService, + IAppService appService, + ISysUserService sysUserService, + ISysDictService configService, + IOptionsMonitor options, + ILoggerFactory logger, + UrlEncoder encoder +) : OAuthHandler(options, logger, encoder) + where TOptions : AdminOAuthOptions, new() +{ + private async Task GetLogin() + { + var sysUser = await sysUserService.GetUserByIdAsync(RoleConst.SuperAdminId).ConfigureAwait(false);//获取用户信息 + + var appConfig = await configService.GetAppConfigAsync().ConfigureAwait(false); + + + var expire = appConfig.LoginPolicy.VerificatExpireTime; + + var loginEvent = new LoginEvent + { + Ip = appService.RemoteIpAddress, + Device = appService.UserAgent?.Platform, + Expire = expire, + SysUser = sysUser, + VerificatId = CommonUtils.GetSingleId() + }; + + //获取verificat列表 + var tokenTimeout = loginEvent.DateTime.AddMinutes(loginEvent.Expire); + //生成verificat信息 + var verificatInfo = new VerificatInfo + { + Device = loginEvent.Device, + Expire = loginEvent.Expire, + VerificatTimeout = tokenTimeout, + Id = loginEvent.VerificatId, + UserId = loginEvent.SysUser.Id, + LoginIp = loginEvent.Ip, + LoginTime = loginEvent.DateTime + }; + + + //添加到verificat列表 + verificatInfoService.Add(verificatInfo); + + return loginEvent; + } + /// + /// 登录事件 + /// + /// + /// + private async Task UpdateUser(LoginEvent loginEvent) + { + var sysUser = loginEvent.SysUser; + + #region 登录/密码策略 + + var key = CacheConst.Cache_LoginErrorCount + sysUser.Account;//获取登录错误次数Key值 + App.CacheService.Remove(key);//移除登录错误次数 + + //获取用户verificat列表 + var userToken = verificatInfoService.GetOne(loginEvent.VerificatId); + + #endregion 登录/密码策略 + + #region 重新赋值属性,设置本次登录信息为最新的信息 + + sysUser.LastLoginIp = sysUser.LatestLoginIp; + sysUser.LastLoginTime = sysUser.LatestLoginTime; + sysUser.LatestLoginIp = loginEvent.Ip; + sysUser.LatestLoginTime = loginEvent.DateTime; + + #endregion 重新赋值属性,设置本次登录信息为最新的信息 + + using var db = DbContext.Db.GetConnectionScopeWithAttr().CopyNew(); + //更新用户登录信息 + if (await db.Updateable(sysUser).UpdateColumns(it => new + { + it.LastLoginIp, + it.LastLoginTime, + it.LatestLoginIp, + it.LatestLoginTime, + }).ExecuteCommandAsync().ConfigureAwait(false) > 0) + App.CacheService.HashAdd(CacheConst.Cache_SysUser, sysUser.Id.ToString(), sysUser);//更新Cache信息 + } + + protected override async Task CreateTicketAsync( + ClaimsIdentity identity, + AuthenticationProperties properties, + OAuthTokenResponse tokens) + { + properties.RedirectUri = Options.HomePath; + properties.IsPersistent = true; + + if (!string.IsNullOrEmpty(tokens.ExpiresIn) && int.TryParse(tokens.ExpiresIn, out var result)) + { + properties.ExpiresUtc = TimeProvider.System.GetUtcNow().AddSeconds(result); + } + var user = await HandleUserInfoAsync(tokens).ConfigureAwait(false); + + var sysUser = await GetLogin().ConfigureAwait(false); + await UpdateUser(sysUser).ConfigureAwait(false); + identity.AddClaim(new Claim(ClaimConst.VerificatId, sysUser.VerificatId.ToString())); + identity.AddClaim(new Claim(ClaimConst.UserId, RoleConst.SuperAdminId.ToString())); + + identity.AddClaim(new Claim(ClaimConst.SuperAdmin, "true")); + identity.AddClaim(new Claim(ClaimConst.OrgId, RoleConst.DefaultTenantId.ToString())); + identity.AddClaim(new Claim(ClaimConst.TenantId, RoleConst.DefaultTenantId.ToString())); + + + var context = new OAuthCreatingTicketContext( + new ClaimsPrincipal(identity), + properties, + Context, + Scheme, + Options, + Backchannel, + tokens, + user + ); + + context.RunClaimActions(); + await Events.CreatingTicket(context).ConfigureAwait(false); + + return new AuthenticationTicket(context.Principal, context.Properties, Scheme.Name); + } + + /// 刷新 Token 方法 + protected virtual async Task RefreshTokenAsync(OAuthTokenResponse oAuthToken) + { + var query = new Dictionary + { + { "refresh_token", oAuthToken.RefreshToken }, + { "grant_type", "refresh_token" } + }; + + var request = new HttpRequestMessage(HttpMethod.Post, QueryHelpers.AddQueryString(Options.TokenEndpoint, query)); + request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + + var response = await Backchannel.SendAsync(request, Context.RequestAborted).ConfigureAwait(false); + + var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + return OAuthTokenResponse.Success(JsonDocument.Parse(content)); + } + + return OAuthTokenResponse.Failed(new OAuthTokenException($"OAuth token endpoint failure: {await Display(response).ConfigureAwait(false)}")); + } + + /// 处理用户信息方法 + protected virtual async Task HandleUserInfoAsync(OAuthTokenResponse tokens) + { + var request = new HttpRequestMessage(HttpMethod.Get, BuildUserInfoUrl(tokens)); + request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); + + var response = await Backchannel.SendAsync(request, Context.RequestAborted).ConfigureAwait(false); + + var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + + if (response.IsSuccessStatusCode) + { + return JsonDocument.Parse(content).RootElement; + } + + throw new OAuthTokenException($"OAuth user info endpoint failure: {await Display(response).ConfigureAwait(false)}"); + } + + /// 生成用户信息请求地址方法 + protected virtual string BuildUserInfoUrl(OAuthTokenResponse tokens) + { + return QueryHelpers.AddQueryString(Options.UserInformationEndpoint, new Dictionary + { + { "access_token", tokens.AccessToken } + }); + } + + /// 生成错误信息方法 + protected static async Task Display(HttpResponseMessage response) + { + var output = new StringBuilder(); + output.Append($"Status: {response.StatusCode}; "); + output.Append($"Headers: {response.Headers}; "); + output.Append($"Body: {await response.Content.ReadAsStringAsync().ConfigureAwait(false)};"); + + return output.ToString(); + } +} + +/// 自定义 Token 异常 +public class OAuthTokenException(string message) : Exception(message); diff --git a/src/Admin/ThingsGateway.Admin.Application/Gitee/AdminOAuthOptions.cs b/src/Admin/ThingsGateway.Admin.Application/Gitee/AdminOAuthOptions.cs new file mode 100644 index 000000000..0f249edab --- /dev/null +++ b/src/Admin/ThingsGateway.Admin.Application/Gitee/AdminOAuthOptions.cs @@ -0,0 +1,33 @@ +using Microsoft.AspNetCore.Authentication.OAuth; + +namespace ThingsGateway.Admin.Application; + +/// OAuthOptions 配置类 +public abstract class AdminOAuthOptions : OAuthOptions +{ + /// 默认构造函数 + protected AdminOAuthOptions() + { + ConfigureClaims(); + + this.Events.OnRemoteFailure = context => + { + var redirectUri = string.IsNullOrEmpty(HomePath) ? "/" : HomePath; + context.Response.Redirect(redirectUri); + context.HandleResponse(); + return Task.CompletedTask; + }; + + + } + + /// 配置 Claims 映射 + protected virtual void ConfigureClaims() + { + + } + + /// 获得/设置 登陆后首页 + public string HomePath { get; set; } = "/"; + +} diff --git a/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthOptions.cs b/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthOptions.cs new file mode 100644 index 000000000..1fae82fbb --- /dev/null +++ b/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthOptions.cs @@ -0,0 +1,64 @@ +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Authentication.OAuth; +using Microsoft.AspNetCore.WebUtilities; + +using System.Net.Http.Headers; + +namespace ThingsGateway.Admin.Application; + +public class GiteeOAuthOptions : AdminOAuthOptions +{ + public GiteeOAuthOptions() : base() + { + this.SignInScheme = ClaimConst.Scheme; + this.AuthorizationEndpoint = "https://gitee.com/oauth/authorize"; + this.TokenEndpoint = "https://gitee.com/oauth/token"; + this.UserInformationEndpoint = "https://gitee.com/api/v5/user"; + this.HomePath = "/"; + this.CallbackPath = "/signin-gitee"; + + Events.OnCreatingTicket = async context => + { + await HandlerGiteeStarredUrl(context).ConfigureAwait(false); + }; + + Events.OnRedirectToAuthorizationEndpoint = context => + { + //context.RedirectUri = context.RedirectUri.Replace("http%3A%2F%2F", "https%3A%2F%2F"); // 强制替换 + context.Response.Redirect(context.RedirectUri); + return Task.CompletedTask; + }; + } + private static async Task HandlerGiteeStarredUrl(OAuthCreatingTicketContext context, string repoFullName = "ThingsGateway/ThingsGateway") + { + if (string.IsNullOrWhiteSpace(context.AccessToken)) + throw new InvalidOperationException("Access token is missing."); + + var uri = $"https://gitee.com/api/v5/user/starred/{repoFullName}"; + + var queryString = new Dictionary + { + { "access_token", context.AccessToken } + }; + + var request = new HttpRequestMessage(HttpMethod.Put, QueryHelpers.AddQueryString(uri, queryString)) + { + Headers = { Accept = { new MediaTypeWithQualityHeaderValue("application/json") } } + }; + + var response = await context.Backchannel.SendAsync(request, context.HttpContext.RequestAborted).ConfigureAwait(false); + + if (!response.IsSuccessStatusCode) + { + var content = await response.Content.ReadAsStringAsync().ConfigureAwait(false); + throw new Exception($"Failed to star repository: {response.StatusCode}, {content}"); + } + } + protected override void ConfigureClaims() + { + ClaimActions.MapJsonKey(ClaimConst.AvatarUrl, "avatar_url"); + ClaimActions.MapJsonKey(ClaimConst.Account, "name"); + + base.ConfigureClaims(); + } +} diff --git a/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthSettings.cs b/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthSettings.cs new file mode 100644 index 000000000..9ad01517d --- /dev/null +++ b/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthSettings.cs @@ -0,0 +1,7 @@ +namespace ThingsGateway.Admin.Application; + +public class GiteeOAuthSettings +{ + public string ClientId { get; set; } + public string ClientSecret { get; set; } +} diff --git a/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthUser.cs b/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthUser.cs new file mode 100644 index 000000000..a89448c6b --- /dev/null +++ b/src/Admin/ThingsGateway.Admin.Application/Gitee/GiteeOAuthUser.cs @@ -0,0 +1,12 @@ +namespace ThingsGateway.Admin.Application; + +public class GiteeOAuthUser +{ + public string Id { get; set; } + + public string Login { get; set; } + + public string Name { get; set; } + + public string Avatar_Url { get; set; } +} diff --git a/src/Admin/ThingsGateway.Admin.Application/Gitee/OAuthUserExtensions.cs b/src/Admin/ThingsGateway.Admin.Application/Gitee/OAuthUserExtensions.cs new file mode 100644 index 000000000..5cef82d25 --- /dev/null +++ b/src/Admin/ThingsGateway.Admin.Application/Gitee/OAuthUserExtensions.cs @@ -0,0 +1,22 @@ +using System.Text.Json; + +namespace ThingsGateway.Admin.Application; + +public static class OAuthUserExtensions +{ + public static GiteeOAuthUser ToAuthUser(this JsonElement element) + { + GiteeOAuthUser authUser = new GiteeOAuthUser(); + JsonElement.ObjectEnumerator target = element.EnumerateObject(); + authUser.Id = target.TryGetValue("id"); + authUser.Login = target.TryGetValue("login"); + authUser.Name = target.TryGetValue("name"); + authUser.Avatar_Url = target.TryGetValue("avatar_url"); + return authUser; + } + + public static string TryGetValue(this JsonElement.ObjectEnumerator target, string propertyName) + { + return target.FirstOrDefault((Func)(t => t.Name.Equals(propertyName, StringComparison.OrdinalIgnoreCase))).Value.ToString() ?? string.Empty; + } +} diff --git a/src/Admin/ThingsGateway.Admin.Application/Services/Auth/AuthService.cs b/src/Admin/ThingsGateway.Admin.Application/Services/Auth/AuthService.cs index 78f50ce5e..d86612e5a 100644 --- a/src/Admin/ThingsGateway.Admin.Application/Services/Auth/AuthService.cs +++ b/src/Admin/ThingsGateway.Admin.Application/Services/Auth/AuthService.cs @@ -12,8 +12,6 @@ using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Localization; -using SqlSugar; - using System.Security.Claims; using ThingsGateway.DataEncryption; @@ -64,6 +62,10 @@ public class AuthService : IAuthService { throw Oops.Bah(appConfig.WebsitePolicy.CloseTip); } + + + + string? password = input.Password; if (isCookie) //openApi登录不再需要解密 { @@ -237,25 +239,20 @@ public class AuthService : IAuthService var logingEvent = new LoginEvent { Ip = _appService.RemoteIpAddress, - Device = App.GetService().UserAgent?.Platform, + Device = _appService.UserAgent?.Platform, Expire = expire, SysUser = sysUser, VerificatId = verificatId }; await WriteTokenToCache(loginPolicy, logingEvent).ConfigureAwait(false);//写入verificat到cache await UpdateUser(logingEvent).ConfigureAwait(false); - if (sysUser.Account == RoleConst.SuperAdmin) - { - var modules = (await _sysResourceService.GetAllAsync().ConfigureAwait(false)).Where(a => a.Category == ResourceCategoryEnum.Module).OrderBy(a => a.SortCode);//获取模块列表 - sysUser.ModuleList = modules.ToList();//模块列表赋值给用户 - } + //返回结果 return new LoginOutput { VerificatId = verificatId, Account = sysUser.Account, Id = sysUser.Id, - ModuleList = sysUser.ModuleList, AccessToken = accessToken, RefreshToken = refreshToken }; diff --git a/src/Admin/ThingsGateway.Admin.Application/Services/User/SysUserService.cs b/src/Admin/ThingsGateway.Admin.Application/Services/User/SysUserService.cs index 7295605e8..1cf3f9573 100644 --- a/src/Admin/ThingsGateway.Admin.Application/Services/User/SysUserService.cs +++ b/src/Admin/ThingsGateway.Admin.Application/Services/User/SysUserService.cs @@ -466,7 +466,7 @@ internal sealed class SysUserService : BaseService, ISysUserService var exist = await GetUserByIdAsync(input.Id).ConfigureAwait(false);//获取用户信息 if (exist != null) { - var isSuperAdmin = exist.Account == RoleConst.SuperAdmin;//判断是否有超管 + var isSuperAdmin = exist.Id == RoleConst.SuperAdminId;//判断是否有超管 if (isSuperAdmin && !UserManager.SuperAdmin) throw Oops.Bah(Localizer["CanotEditAdminUser"]); @@ -540,7 +540,7 @@ internal sealed class SysUserService : BaseService, ISysUserService await CheckApiDataScopeAsync(sysUser.OrgId, sysUser.CreateUserId).ConfigureAwait(false); if (sysUser != null) { - var isSuperAdmin = (sysUser.Account == RoleConst.SuperAdmin || input.GrantInfoList.Any(a => a == RoleConst.SuperAdminRoleId)) && !UserManager.SuperAdmin;//判断是否有超管 + var isSuperAdmin = (sysUser.Id == RoleConst.SuperAdminId || input.GrantInfoList.Any(a => a == RoleConst.SuperAdminRoleId)) && !UserManager.SuperAdmin;//判断是否有超管 if (isSuperAdmin) throw Oops.Bah(Localizer["CanotGrantAdmin"]); @@ -660,7 +660,7 @@ internal sealed class SysUserService : BaseService, ISysUserService public async Task DeleteUserAsync(IEnumerable ids) { using var db = GetDB(); - var containsSuperAdmin = await db.Queryable().Where(it => it.Account == RoleConst.SuperAdmin && ids.Contains(it.Id)).AnyAsync().ConfigureAwait(false);//判断是否有超管 + var containsSuperAdmin = await db.Queryable().Where(it => it.Id == RoleConst.SuperAdminId && ids.Contains(it.Id)).AnyAsync().ConfigureAwait(false);//判断是否有超管 if (containsSuperAdmin) throw Oops.Bah(Localizer["CanotDeleteAdminUser"]); if (ids.Contains(UserManager.UserId)) @@ -899,7 +899,7 @@ internal sealed class SysUserService : BaseService, ISysUserService var tenantId = await _sysOrgService.GetTenantIdByOrgIdAsync(sysUser.OrgId, sysOrgList).ConfigureAwait(false); sysUser.TenantId = tenantId; - if (sysUser.Account == RoleConst.SuperAdmin) + if (sysUser.Id == RoleConst.SuperAdminId) { var modules = (await _sysResourceService.GetAllAsync().ConfigureAwait(false)).Where(a => a.Category == ResourceCategoryEnum.Module).OrderBy(a => a.SortCode); sysUser.ModuleList = modules.ToList();//模块列表赋值给用户 diff --git a/src/Admin/ThingsGateway.Admin.Razor/Context/BlazorAppContext.cs b/src/Admin/ThingsGateway.Admin.Razor/Context/BlazorAppContext.cs index bc68d0085..14ab0032f 100644 --- a/src/Admin/ThingsGateway.Admin.Razor/Context/BlazorAppContext.cs +++ b/src/Admin/ThingsGateway.Admin.Razor/Context/BlazorAppContext.cs @@ -40,6 +40,8 @@ public class BlazorAppContext /// public SysUser CurrentUser { get; private set; } + public string? Avatar => UserManager.AvatarUrl.IsNullOrEmpty() ? CurrentUser.Avatar : UserManager.AvatarUrl; + /// /// 用户个人菜单 /// diff --git a/src/Admin/ThingsGateway.Admin.Razor/Pages/UserCenter/UserCenterPage.razor.cs b/src/Admin/ThingsGateway.Admin.Razor/Pages/UserCenter/UserCenterPage.razor.cs index 2e99c7ec8..3cd297c5c 100644 --- a/src/Admin/ThingsGateway.Admin.Razor/Pages/UserCenter/UserCenterPage.razor.cs +++ b/src/Admin/ThingsGateway.Admin.Razor/Pages/UserCenter/UserCenterPage.razor.cs @@ -38,7 +38,7 @@ public partial class UserCenterPage protected override async Task OnParametersSetAsync() { SysUser = AppContext.CurrentUser.Adapt(); - SysUser.Avatar = AppContext.CurrentUser.Avatar; + SysUser.Avatar = AppContext.Avatar; WorkbenchInfo = (await UserCenterService.GetLoginWorkbenchAsync(SysUser.Id)).Adapt(); await base.OnParametersSetAsync(); diff --git a/src/Admin/ThingsGateway.AdminServer/Index/AdminIndex.razor.cs b/src/Admin/ThingsGateway.AdminServer/Index/AdminIndex.razor.cs index c6e681093..ff171560d 100644 --- a/src/Admin/ThingsGateway.AdminServer/Index/AdminIndex.razor.cs +++ b/src/Admin/ThingsGateway.AdminServer/Index/AdminIndex.razor.cs @@ -12,15 +12,11 @@ #pragma warning disable CA2007 // 考虑对等待的任务调用 ConfigureAwait -using BootstrapBlazor.Components; - using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Localization; -using ThingsGateway.Admin.Application; using ThingsGateway.Admin.Razor; -using ThingsGateway.Extension; namespace ThingsGateway.AdminServer; diff --git a/src/Admin/ThingsGateway.AdminServer/Layout/AccessDenied.razor.cs b/src/Admin/ThingsGateway.AdminServer/Layout/AccessDenied.razor.cs index bdc9139a0..da19bc8c2 100644 --- a/src/Admin/ThingsGateway.AdminServer/Layout/AccessDenied.razor.cs +++ b/src/Admin/ThingsGateway.AdminServer/Layout/AccessDenied.razor.cs @@ -13,8 +13,6 @@ using Microsoft.Extensions.Localization; using System.Diagnostics.CodeAnalysis; -using ThingsGateway.Admin.Application; - namespace ThingsGateway.AdminServer; public partial class AccessDenied diff --git a/src/Admin/ThingsGateway.AdminServer/Layout/Login.razor.cs b/src/Admin/ThingsGateway.AdminServer/Layout/Login.razor.cs index aa068234f..810f833b3 100644 --- a/src/Admin/ThingsGateway.AdminServer/Layout/Login.razor.cs +++ b/src/Admin/ThingsGateway.AdminServer/Layout/Login.razor.cs @@ -9,10 +9,6 @@ //------------------------------------------------------------------------------ #pragma warning disable CA2007 // 考虑对等待的任务调用 ConfigureAwait -using BootstrapBlazor.Components; - -using Mapster; - using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Microsoft.Extensions.Localization; @@ -20,11 +16,6 @@ using Microsoft.Extensions.Options; using System.Diagnostics.CodeAnalysis; -using ThingsGateway.Admin.Application; -using ThingsGateway.DataEncryption; -using ThingsGateway.NewLife.Extension; -using ThingsGateway.Razor; - namespace ThingsGateway.AdminServer; public partial class Login diff --git a/src/Admin/ThingsGateway.AdminServer/Layout/MainLayout.razor b/src/Admin/ThingsGateway.AdminServer/Layout/MainLayout.razor index f0d29b2a0..7b41db4c3 100644 --- a/src/Admin/ThingsGateway.AdminServer/Layout/MainLayout.razor +++ b/src/Admin/ThingsGateway.AdminServer/Layout/MainLayout.razor @@ -48,7 +48,7 @@ - + @Localizer["系统首页"] diff --git a/src/Admin/ThingsGateway.AdminServer/Layout/MainLayout.razor.cs b/src/Admin/ThingsGateway.AdminServer/Layout/MainLayout.razor.cs index f746f0dd1..280bf166f 100644 --- a/src/Admin/ThingsGateway.AdminServer/Layout/MainLayout.razor.cs +++ b/src/Admin/ThingsGateway.AdminServer/Layout/MainLayout.razor.cs @@ -9,17 +9,13 @@ //------------------------------------------------------------------------------ #pragma warning disable CA2007 // 考虑对等待的任务调用 ConfigureAwait -using BootstrapBlazor.Components; - using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; using System.Diagnostics.CodeAnalysis; -using ThingsGateway.Admin.Application; using ThingsGateway.Admin.Razor; -using ThingsGateway.Razor; namespace ThingsGateway.AdminServer; @@ -27,38 +23,6 @@ public partial class MainLayout : IDisposable { [Inject] IStringLocalizer RazorLocalizer { get; set; } - private Task OnRefresh(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - _tab.Refresh(tabItem); - } - return Task.CompletedTask; - } - - private async Task OnClose(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - await _tab.RemoveTab(tabItem); - } - } - - private Task OnCloseOther(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - _tab.ActiveTab(tabItem); - } - _tab.CloseOtherTabs(); - return Task.CompletedTask; - } - - private Task OnCloseAll(ContextMenuItem item, object? context) - { - _tab.CloseAllTabs(); - return Task.CompletedTask; - } #region 全局通知 diff --git a/src/Admin/ThingsGateway.AdminServer/Program/Program.cs b/src/Admin/ThingsGateway.AdminServer/Program/Program.cs index 7dfcd691d..342f4892e 100644 --- a/src/Admin/ThingsGateway.AdminServer/Program/Program.cs +++ b/src/Admin/ThingsGateway.AdminServer/Program/Program.cs @@ -13,8 +13,6 @@ using Microsoft.AspNetCore.ResponseCompression; using System.Runtime.InteropServices; using System.Text; -using ThingsGateway.NewLife.Log; - namespace ThingsGateway.AdminServer; public class Program diff --git a/src/Admin/ThingsGateway.AdminServer/Program/Startup.cs b/src/Admin/ThingsGateway.AdminServer/Program/Startup.cs index 88a1b1fcd..7bbd545e0 100644 --- a/src/Admin/ThingsGateway.AdminServer/Program/Startup.cs +++ b/src/Admin/ThingsGateway.AdminServer/Program/Startup.cs @@ -18,17 +18,12 @@ using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; -using Newtonsoft.Json; - using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.Encodings.Web; using System.Text.Unicode; -using ThingsGateway.Admin.Application; using ThingsGateway.Admin.Razor; -using ThingsGateway.Extension; -using ThingsGateway.NewLife.Caching; namespace ThingsGateway.AdminServer; @@ -369,12 +364,6 @@ public class Startup : AppStartup app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider }); app.UseStaticFiles(); - app.Use(async (context, next) => - { - context.Response.Headers.Append("ThingsGateway", "ThingsGateway"); - await next().ConfigureAwait(false); - }); - // 特定文件类型(文件后缀)处理 var contentTypeProvider = GetFileExtensionContentTypeProvider(); diff --git a/src/Admin/ThingsGateway.SqlSugar/Const/ClaimConst.cs b/src/Admin/ThingsGateway.SqlSugar/Const/ClaimConst.cs index a98fcd849..7b6db1c3c 100644 --- a/src/Admin/ThingsGateway.SqlSugar/Const/ClaimConst.cs +++ b/src/Admin/ThingsGateway.SqlSugar/Const/ClaimConst.cs @@ -31,6 +31,11 @@ public class ClaimConst /// public const string UserId = "UserId"; + /// + /// AvatarUrl + /// + public const string AvatarUrl = "AvatarUrl"; + /// /// 验证Id /// diff --git a/src/Admin/ThingsGateway.SqlSugar/Static/UserManager.cs b/src/Admin/ThingsGateway.SqlSugar/Static/UserManager.cs index 558fcd068..951d3da39 100644 --- a/src/Admin/ThingsGateway.SqlSugar/Static/UserManager.cs +++ b/src/Admin/ThingsGateway.SqlSugar/Static/UserManager.cs @@ -27,11 +27,17 @@ public static class UserManager /// public static bool SuperAdmin => (_claimsPrincipalService.User?.FindFirst(ClaimConst.SuperAdmin)?.Value).ToBoolean(false); + /// /// 当前用户账号 /// public static string UserAccount => _claimsPrincipalService.User?.FindFirst(ClaimConst.Account)?.Value; + /// + /// AvatarUrl + /// + public static string AvatarUrl => (_claimsPrincipalService.User?.FindFirst(ClaimConst.AvatarUrl)?.Value); + /// /// 当前用户Id /// diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 89588393c..d613d24f4 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -1,8 +1,8 @@ - 10.7.1 - 10.7.1 + 10.7.14 + 10.7.14 2.2.0 diff --git a/src/Plugin/ThingsGateway.Debug.Photino/MainLayout.razor.cs b/src/Plugin/ThingsGateway.Debug.Photino/MainLayout.razor.cs index 4f4bda430..8d8746571 100644 --- a/src/Plugin/ThingsGateway.Debug.Photino/MainLayout.razor.cs +++ b/src/Plugin/ThingsGateway.Debug.Photino/MainLayout.razor.cs @@ -25,39 +25,6 @@ public partial class MainLayout { [Inject] IStringLocalizer RazorLocalizer { get; set; } - private Task OnRefresh(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - _tab.Refresh(tabItem); - } - return Task.CompletedTask; - } - - private async Task OnClose(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - await _tab.RemoveTab(tabItem); - } - } - - private Task OnCloseOther(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - _tab.ActiveTab(tabItem); - } - _tab.CloseOtherTabs(); - return Task.CompletedTask; - } - - private Task OnCloseAll(ContextMenuItem item, object? context) - { - _tab.CloseAllTabs(); - return Task.CompletedTask; - } - private Tab _tab { get; set; } diff --git a/src/ThingsGateway.Photino/Startup.cs b/src/ThingsGateway.Photino/Startup.cs index 3eccf3484..21c00dbd3 100644 --- a/src/ThingsGateway.Photino/Startup.cs +++ b/src/ThingsGateway.Photino/Startup.cs @@ -15,7 +15,6 @@ using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption; using Microsoft.AspNetCore.DataProtection.AuthenticatedEncryption.ConfigurationModel; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.HttpOverrides; using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.DependencyInjection; @@ -352,12 +351,6 @@ public class Startup : AppStartup app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider }); app.UseStaticFiles(); - app.Use(async (context, next) => - { - context.Response.Headers.Append("ThingsGateway", "ThingsGateway"); - await next().ConfigureAwait(false); - }); - // 特定文件类型(文件后缀)处理 var contentTypeProvider = GetFileExtensionContentTypeProvider(); diff --git a/src/ThingsGateway.Server/Layout/Login.razor.cs b/src/ThingsGateway.Server/Layout/Login.razor.cs index 56ba32cf0..185b8e5ba 100644 --- a/src/ThingsGateway.Server/Layout/Login.razor.cs +++ b/src/ThingsGateway.Server/Layout/Login.razor.cs @@ -64,43 +64,51 @@ public partial class Login _versionString = $"v{VersionService.Version}"; return base.OnInitializedAsync(); } - + [Inject] + NavigationManager NavigationManager { get; set; } private async Task LoginAsync(EditContext context) { - var model = loginModel.Adapt(); - model.Password = DESEncryption.Encrypt(model.Password); - try + var websiteOptions = App.GetOptions()!; + if (websiteOptions.Demo) { + NavigationManager.NavigateTo("/api/auth/oauth-login", forceLoad: true); + } + else + { + var model = loginModel.Adapt(); + model.Password = DESEncryption.Encrypt(model.Password); - var ret = await AuthRazorService.LoginAsync(model); - - if (ret.Code != 200) + try { - await ToastService.Error(Localizer["LoginErrorh1"], $"{ret.Msg}"); - } - else - { - await ToastService.Information(Localizer["LoginSuccessh1"], Localizer["LoginSuccessc1"]); - await Task.Delay(1000); - if (ReturnUrl.IsNullOrWhiteSpace() || ReturnUrl == @"/") + var ret = await AuthRazorService.LoginAsync(model); + + if (ret.Code != 200) { - await AjaxService.Goto(ReturnUrl ?? "/"); + await ToastService.Error(Localizer["LoginErrorh1"], $"{ret.Msg}"); } else { - await AjaxService.Goto(ReturnUrl); + await ToastService.Information(Localizer["LoginSuccessh1"], Localizer["LoginSuccessc1"]); + await Task.Delay(1000); + + if (ReturnUrl.IsNullOrWhiteSpace() || ReturnUrl == @"/") + { + await AjaxService.Goto(ReturnUrl ?? "/"); + } + else + { + await AjaxService.Goto(ReturnUrl); + } } } - } - catch - { - await ToastService.Error(Localizer["LoginErrorh2"], Localizer["LoginErrorc2"]); + catch + { + await ToastService.Error(Localizer["LoginErrorh2"], Localizer["LoginErrorc2"]); + } } } - - } diff --git a/src/ThingsGateway.Server/Layout/MainLayout.razor b/src/ThingsGateway.Server/Layout/MainLayout.razor index 72433996a..2a835a194 100644 --- a/src/ThingsGateway.Server/Layout/MainLayout.razor +++ b/src/ThingsGateway.Server/Layout/MainLayout.razor @@ -47,7 +47,7 @@ - + @Localizer["系统首页"] diff --git a/src/ThingsGateway.Server/Layout/MainLayout.razor.cs b/src/ThingsGateway.Server/Layout/MainLayout.razor.cs index 3a06de637..db70bc087 100644 --- a/src/ThingsGateway.Server/Layout/MainLayout.razor.cs +++ b/src/ThingsGateway.Server/Layout/MainLayout.razor.cs @@ -28,39 +28,6 @@ public partial class MainLayout : IDisposable { [Inject] IStringLocalizer RazorLocalizer { get; set; } - private Task OnRefresh(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - _tab.Refresh(tabItem); - } - return Task.CompletedTask; - } - - private async Task OnClose(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - await _tab.RemoveTab(tabItem); - } - } - - private Task OnCloseOther(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - _tab.ActiveTab(tabItem); - } - _tab.CloseOtherTabs(); - return Task.CompletedTask; - } - - private Task OnCloseAll(ContextMenuItem item, object? context) - { - _tab.CloseAllTabs(); - return Task.CompletedTask; - } - #region 全局通知 diff --git a/src/ThingsGateway.Server/Program/Startup.cs b/src/ThingsGateway.Server/Program/Startup.cs index 3347fd860..fdca7cbfa 100644 --- a/src/ThingsGateway.Server/Program/Startup.cs +++ b/src/ThingsGateway.Server/Program/Startup.cs @@ -29,6 +29,7 @@ using ThingsGateway.Admin.Application; using ThingsGateway.Admin.Razor; using ThingsGateway.Extension; using ThingsGateway.NewLife.Caching; +using ThingsGateway.Razor; namespace ThingsGateway.Server; @@ -287,6 +288,18 @@ public class Startup : AppStartup a.LoginPath = "/Account/Login/"; }); + var websiteOptions = App.GetOptions()!; + if (websiteOptions.Demo) + { + authenticationBuilder.AddOAuth>("Gitee", "Gitee", options => + { + var data = App.GetConfig("GiteeOAuthSettings"); + options.ClientId = data.ClientId; + options.ClientSecret = data.ClientSecret; + + }); + } + // 添加jwt授权 authenticationBuilder.AddJwt(); @@ -371,13 +384,6 @@ public class Startup : AppStartup app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider }); app.UseStaticFiles(); - app.Use(async (context, next) => - { - context.Response.Headers.Append("ThingsGateway", "ThingsGateway"); - await next().ConfigureAwait(false); - }); - - // 特定文件类型(文件后缀)处理 var contentTypeProvider = GetFileExtensionContentTypeProvider(); // contentTypeProvider.Mappings[".文件后缀"] = "MIME 类型"; diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Controler/AutoUpdateControler.cs b/src/Upgrade/ThingsGateway.UpgradeServer/Controler/AutoUpdateControler.cs index cbfc47816..4128955d3 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Controler/AutoUpdateControler.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Controler/AutoUpdateControler.cs @@ -11,8 +11,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; -using ThingsGateway.Admin.Application; - namespace ThingsGateway.Upgrade; /// diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Index/AdminIndex.razor.cs b/src/Upgrade/ThingsGateway.UpgradeServer/Index/AdminIndex.razor.cs index 684970a96..02ac4ed5b 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Index/AdminIndex.razor.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Index/AdminIndex.razor.cs @@ -12,16 +12,10 @@ #pragma warning disable CA2007 // 考虑对等待的任务调用 ConfigureAwait -using BootstrapBlazor.Components; - using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Localization; -using ThingsGateway.Admin.Application; -using ThingsGateway.Admin.Razor; -using ThingsGateway.Extension; - namespace ThingsGateway.UpgradeServer; diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Layout/AccessDenied.razor.cs b/src/Upgrade/ThingsGateway.UpgradeServer/Layout/AccessDenied.razor.cs index 00241b2c6..373a405cc 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Layout/AccessDenied.razor.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Layout/AccessDenied.razor.cs @@ -13,8 +13,6 @@ using Microsoft.Extensions.Localization; using System.Diagnostics.CodeAnalysis; -using ThingsGateway.Admin.Application; - namespace ThingsGateway.UpgradeServer; public partial class AccessDenied diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Layout/Login.razor.cs b/src/Upgrade/ThingsGateway.UpgradeServer/Layout/Login.razor.cs index a9cc36c1d..e83b33d1e 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Layout/Login.razor.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Layout/Login.razor.cs @@ -9,10 +9,6 @@ //------------------------------------------------------------------------------ #pragma warning disable CA2007 // 考虑对等待的任务调用 ConfigureAwait -using BootstrapBlazor.Components; - -using Mapster; - using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; using Microsoft.Extensions.Localization; @@ -20,11 +16,6 @@ using Microsoft.Extensions.Options; using System.Diagnostics.CodeAnalysis; -using ThingsGateway.Admin.Application; -using ThingsGateway.DataEncryption; -using ThingsGateway.NewLife.Extension; -using ThingsGateway.Razor; - namespace ThingsGateway.UpgradeServer; public partial class Login diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Layout/MainLayout.razor b/src/Upgrade/ThingsGateway.UpgradeServer/Layout/MainLayout.razor index 70743144b..533096781 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Layout/MainLayout.razor +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Layout/MainLayout.razor @@ -48,7 +48,7 @@ - + @Localizer["系统首页"] diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Layout/MainLayout.razor.cs b/src/Upgrade/ThingsGateway.UpgradeServer/Layout/MainLayout.razor.cs index 1908b0cfa..01a80a3d7 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Layout/MainLayout.razor.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Layout/MainLayout.razor.cs @@ -9,57 +9,18 @@ //------------------------------------------------------------------------------ #pragma warning disable CA2007 // 考虑对等待的任务调用 ConfigureAwait -using BootstrapBlazor.Components; - using Microsoft.AspNetCore.Components; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; using System.Diagnostics.CodeAnalysis; -using ThingsGateway.Admin.Application; -using ThingsGateway.Admin.Razor; -using ThingsGateway.Razor; - namespace ThingsGateway.UpgradeServer; public partial class MainLayout : IDisposable { [Inject] IStringLocalizer RazorLocalizer { get; set; } - private Task OnRefresh(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - _tab.Refresh(tabItem); - } - return Task.CompletedTask; - } - - private async Task OnClose(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - await _tab.RemoveTab(tabItem); - } - } - - private Task OnCloseOther(ContextMenuItem item, object? context) - { - if (context is TabItem tabItem) - { - _tab.ActiveTab(tabItem); - } - _tab.CloseOtherTabs(); - return Task.CompletedTask; - } - - private Task OnCloseAll(ContextMenuItem item, object? context) - { - _tab.CloseAllTabs(); - return Task.CompletedTask; - } - #region 全局通知 diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Program/Program.cs b/src/Upgrade/ThingsGateway.UpgradeServer/Program/Program.cs index 93039adad..7de3613a4 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Program/Program.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Program/Program.cs @@ -13,8 +13,6 @@ using Microsoft.AspNetCore.ResponseCompression; using System.Runtime.InteropServices; using System.Text; -using ThingsGateway.NewLife.Log; - namespace ThingsGateway.UpgradeServer; diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Program/Startup.cs b/src/Upgrade/ThingsGateway.UpgradeServer/Program/Startup.cs index 7cfe7aeea..e46ca4a5f 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Program/Startup.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Program/Startup.cs @@ -18,17 +18,11 @@ using Microsoft.AspNetCore.StaticFiles; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Options; -using Newtonsoft.Json; - using System.Security.Cryptography.X509Certificates; using System.Text; using System.Text.Encodings.Web; using System.Text.Unicode; -using ThingsGateway.Admin.Application; -using ThingsGateway.Admin.Razor; -using ThingsGateway.Extension; - namespace ThingsGateway.UpgradeServer; [AppStartup(-99999)] @@ -366,12 +360,6 @@ public class Startup : AppStartup app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = provider }); app.UseStaticFiles(); - app.Use(async (context, next) => - { - context.Response.Headers.Append("ThingsGateway", "ThingsGateway"); - await next().ConfigureAwait(false); - }); - // 特定文件类型(文件后缀)处理 var contentTypeProvider = GetFileExtensionContentTypeProvider(); diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/Program/Startup1.cs b/src/Upgrade/ThingsGateway.UpgradeServer/Program/Startup1.cs index d3c5daec4..40f99cf22 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/Program/Startup1.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/Program/Startup1.cs @@ -10,8 +10,6 @@ using System.Reflection; -using ThingsGateway.Admin.Application; - namespace ThingsGateway.Upgrade; [AppStartup(100000000)] diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/SeedData/SysRelationSeedData.cs b/src/Upgrade/ThingsGateway.UpgradeServer/SeedData/SysRelationSeedData.cs index 424825630..3706d9c44 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/SeedData/SysRelationSeedData.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/SeedData/SysRelationSeedData.cs @@ -8,7 +8,6 @@ // QQ群:605534569 //------------------------------------------------------------------------------ -using ThingsGateway.Admin.Application; namespace ThingsGateway.Upgrade; /// diff --git a/src/Upgrade/ThingsGateway.UpgradeServer/SeedData/SysResourceSeedData.cs b/src/Upgrade/ThingsGateway.UpgradeServer/SeedData/SysResourceSeedData.cs index f03dfd9a4..216963156 100644 --- a/src/Upgrade/ThingsGateway.UpgradeServer/SeedData/SysResourceSeedData.cs +++ b/src/Upgrade/ThingsGateway.UpgradeServer/SeedData/SysResourceSeedData.cs @@ -8,8 +8,6 @@ // QQ群:605534569 //------------------------------------------------------------------------------ -using ThingsGateway.Admin.Application; - namespace ThingsGateway.Upgrade; /// diff --git a/src/Version.props b/src/Version.props index 59472debd..38d998a32 100644 --- a/src/Version.props +++ b/src/Version.props @@ -1,6 +1,6 @@ - 10.7.1 + 10.7.14