[feat] IPModule中没有IP时取本机IP;UserModule中没有当前用户时,取当前计算机名;close: https://github.com/NewLifeX/NewLife.XCode/issues/32

This commit is contained in:
智能大石头 2025-04-01 13:42:01 +08:00
parent 9c5ac245b2
commit 6d8becc490
2 changed files with 2 additions and 1 deletions

View File

@ -1,5 +1,4 @@
using System.Collections.Concurrent;
using NewLife;
using XCode.Configuration;
using XCode.Membership;
@ -53,6 +52,7 @@ public class IPModule : EntityModule
var fs = GetFields(entity.GetType());
var ip = ManageProvider.UserHost;
ip ??= NetHelper.MyIP()?.ToString();
if (!ip.IsNullOrEmpty())
{
// 如果不是IPv6去掉后面端口

View File

@ -83,6 +83,7 @@ public class UserModule : EntityModule
// 当前登录用户
var prv = Provider ?? ManageProvider.Provider;
var user = prv?.Current;
user ??= new User { Name = Environment.UserName };
if (user != null)
{
switch (method)