😎同步升级及代码优化

This commit is contained in:
zuohuaijun 2024-06-27 01:16:01 +08:00
parent 3001840e6e
commit ca55fb82cf
10 changed files with 61 additions and 47 deletions

View File

@ -34,7 +34,7 @@
<PackageReference Include="SixLabors.ImageSharp.Web" Version="3.1.2" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.Api" Version="3.3.0" />
<PackageReference Include="SKIT.FlurlHttpClient.Wechat.TenpayV3" Version="3.5.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.159" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.160" />
<PackageReference Include="SSH.NET" Version="2024.0.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.2" />
<PackageReference Include="TencentCloudSDK.Sms" Version="3.0.1034" />

View File

@ -4,8 +4,6 @@
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using IPTools.Core;
namespace Admin.NET.Core;
/// <summary>
@ -79,7 +77,7 @@ public class DatabaseLoggingWriter : IDatabaseLoggingWriter, IDisposable
if (string.IsNullOrEmpty(remoteIPv4))
remoteIPv4 = loggingMonitor.remoteIPv4;
(string ipLocation, double? longitude, double? latitude) = GetIpAddress(remoteIPv4);
(string ipLocation, double? longitude, double? latitude) = CommonUtil.GetIpAddress(remoteIPv4);
var browser = "";
var os = "";
@ -201,26 +199,6 @@ public class DatabaseLoggingWriter : IDatabaseLoggingWriter, IDisposable
}
}
/// <summary>
/// 解析IP地址
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
internal static (string ipLocation, double? longitude, double? latitude) GetIpAddress(string ip)
{
try
{
var ipInfo = IpTool.SearchWithI18N(ip); // 国际化查询,默认中文 中文zh-CN、英文en
var addressList = new List<string>() { ipInfo.Country, ipInfo.Province, ipInfo.City, ipInfo.NetworkOperator };
return (string.Join(" ", addressList.Where(u => u != "0" && !string.IsNullOrWhiteSpace(u)).ToList()), ipInfo.Longitude, ipInfo.Latitude); // 去掉0及空并用空格连接
}
catch
{
// 不做处理
}
return ("未知", 0, 0);
}
/// <summary>
/// 释放服务作用域
/// </summary>

View File

@ -57,7 +57,7 @@ public class ElasticSearchLoggingWriter : IDatabaseLoggingWriter, IDisposable
}
string remoteIPv4 = loggingMonitor.remoteIPv4;
(string ipLocation, double? longitude, double? latitude) = DatabaseLoggingWriter.GetIpAddress(remoteIPv4);
(string ipLocation, double? longitude, double? latitude) = CommonUtil.GetIpAddress(remoteIPv4);
var sysLogOp = new SysLogOp
{

View File

@ -208,7 +208,7 @@ public class SysAuthService : IDynamicApiController, ITransient
/// <param name="user"></param>
/// <returns></returns>
[NonAction]
public virtual async Task<LoginOutput> CreateToken(SysUser user)
internal async Task<LoginOutput> CreateToken(SysUser user)
{
// 单用户登录
await _sysOnlineUserService.SingleLogin(user.Id);
@ -238,16 +238,16 @@ public class SysAuthService : IDynamicApiController, ITransient
// ke.global.setAllHeader('Authorization', 'Bearer ' + ke.response.headers['access-token']);
// 更新用户登录信息
string remoteIPv4 = App.HttpContext.GetRemoteIpAddressToIPv4();
(string ipLocation, double? longitude, double? latitude) = DatabaseLoggingWriter.GetIpAddress(remoteIPv4);
user.LastLoginIp = remoteIPv4;
user.LastLoginAddress = ipLocation;
user.LastLoginIp = _httpContextAccessor.HttpContext.GetRemoteIp();
(user.LastLoginAddress, double? longitude, double? latitude) = CommonUtil.GetIpAddress(user.LastLoginIp);
user.LastLoginTime = DateTime.Now;
await _sysUserRep.AsUpdateable(user).UpdateColumns(it => new
user.LastLoginDevice = CommonUtil.GetClientDeviceInfo(_httpContextAccessor.HttpContext?.Request?.Headers?.UserAgent);
await _sysUserRep.AsUpdateable(user).UpdateColumns(u => new
{
it.LastLoginIp,
it.LastLoginAddress,
it.LastLoginTime,
u.LastLoginIp,
u.LastLoginAddress,
u.LastLoginTime,
u.LastLoginDevice,
}).ExecuteCommandAsync();
return new LoginOutput

View File

@ -14,18 +14,12 @@ public class SysConfigService : IDynamicApiController, ITransient
{
private readonly SysCacheService _sysCacheService;
private readonly SqlSugarRepository<SysConfig> _sysConfigRep;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly UserManager _userManager;
public SysConfigService(SysCacheService sysCacheService,
SqlSugarRepository<SysConfig> sysConfigRep,
IHttpContextAccessor httpContextAccessor,
UserManager userManager)
SqlSugarRepository<SysConfig> sysConfigRep)
{
_sysCacheService = sysCacheService;
_sysConfigRep = sysConfigRep;
_httpContextAccessor = httpContextAccessor;
_userManager = userManager;
}
/// <summary>

View File

@ -21,7 +21,7 @@ public class SysFileService : IDynamicApiController, ITransient
private readonly OSSProviderOptions _OSSProviderOptions;
private readonly UploadOptions _uploadOptions;
private readonly IOSSService _OSSService;
private readonly string _imageType = ".jpg.png.bmp.gif.tif";
private readonly string _imageType = ".jpeg.jpg.png.bmp.gif.tif";
public SysFileService(UserManager userManager,
SqlSugarRepository<SysFile> sysFileRep,

View File

@ -4,6 +4,7 @@
//
// 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
using IPTools.Core;
using Magicodes.ExporterAndImporter.Core.Models;
using System.Xml;
using System.Xml.Linq;
@ -369,4 +370,47 @@ public static class CommonUtil
return propMappings;
}
/// <summary>
/// 解析IP地址
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public static (string ipLocation, double? longitude, double? latitude) GetIpAddress(string ip)
{
try
{
var ipInfo = IpTool.SearchWithI18N(ip); // 国际化查询,默认中文 中文zh-CN、英文en
var addressList = new List<string>() { ipInfo.Country, ipInfo.Province, ipInfo.City, ipInfo.NetworkOperator };
return (string.Join(" ", addressList.Where(u => u != "0" && !string.IsNullOrWhiteSpace(u)).ToList()), ipInfo.Longitude, ipInfo.Latitude); // 去掉0及空并用空格连接
}
catch
{
// 不做处理
}
return ("未知", 0, 0);
}
/// <summary>
/// 获取客户端设备信息(操作系统+浏览器)
/// </summary>
/// <param name="userAgent"></param>
/// <returns></returns>
public static string GetClientDeviceInfo(string userAgent)
{
try
{
if (userAgent != null)
{
var client = Parser.GetDefault().Parse(userAgent);
if (client.Device.IsSpider)
return "爬虫";
return $"{client.OS.Family} {client.OS.Major} {client.OS.Minor}" +
$"|{client.UA.Family} {client.UA.Major}.{client.UA.Minor} / {client.Device.Family}";
}
}
catch
{ }
return "未知";
}
}

View File

@ -18,6 +18,7 @@ using Microsoft.AspNetCore.Http;
}
}
namespace @Model.NameSpace;
/// <summary>
/// @(@Model.BusName)服务
/// </summary>

View File

@ -24,7 +24,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Rezero.Api" Version="1.7.5" />
<PackageReference Include="Rezero.Api" Version="1.7.6" />
</ItemGroup>
<ItemGroup>

View File

@ -34,7 +34,7 @@
</div>
<el-scrollbar>
<div ref="toolSetRef" class="tool-sortable">
<div class="tool-sortable-item" v-for="v in columns" :key="v.prop" v-show="!v.hideCheck && !v.fixed" :data-key="v.prop">
<div class="tool-sortable-item" v-for="v in columns" :key="v.prop" v-show="!v.hideCheck" :data-key="v.prop">
<i class="fa fa-arrows-alt handle cursor-pointer"></i>
<el-checkbox v-model="v.isCheck" size="default" class="ml12 mr8" :label="v.label" @change="onCheckChange" />
</div>
@ -71,7 +71,6 @@
</template>
<template v-else-if="!item.children" v-slot="scope">
<formatter v-if="item.formatter" :fn="item.formatter(scope.row, scope.column, scope.cellValue, scope.index)"> </formatter>
<!-- <span v-if="item.formatter">{{ item.formatter(scope.row,scope.column,scope.cellValue,scope.index) }}</span> -->
<template v-else-if="item.type === 'image'">
<el-image
:style="{ width: `${item.width}px`, height: `${item.height}px` }"
@ -90,12 +89,10 @@
<!-- 自定义列插槽插槽名为columns属性的prop -->
<template #default="scope" v-if="$slots[childrenItem.prop]">
<formatter v-if="childrenItem.formatter" :fn="childrenItem.formatter(scope.row, scope.column, scope.cellValue, scope.index)"> </formatter>
<!-- <span v-if="childrenItem.formatter">{{ childrenItem.formatter(scope.row,scope.column,scope.cellValue,scope.index) }}</span> -->
<slot v-else :name="childrenItem.prop" v-bind="scope"></slot>
</template>
<template v-else v-slot="scope">
<formatter v-if="childrenItem.formatter" :fn="childrenItem.formatter(scope.row, scope.column, scope.cellValue, scope.index)"> </formatter>
<!-- <span v-if="childrenItem.formatter">{{ childrenItem.formatter(scope.row,scope.column,scope.cellValue,scope.index) }}</span> -->
<template v-else-if="childrenItem.type === 'image'">
<el-image
:style="{ width: `${childrenItem.width}px`, height: `${childrenItem.height}px` }"