😎优化代码
This commit is contained in:
parent
7aa71cf95f
commit
dc558bee04
@ -1,31 +0,0 @@
|
||||
// // Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||
// //
|
||||
// // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||
// //
|
||||
// // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
//
|
||||
// using System.Net;
|
||||
//
|
||||
// namespace Admin.NET.Core;
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 代理管理器接口
|
||||
// /// </summary>
|
||||
// public interface IProxyManager
|
||||
// {
|
||||
// /// <summary>
|
||||
// /// 获取当前代理
|
||||
// /// </summary>
|
||||
// WebProxy GetCurrentProxy();
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 刷新代理
|
||||
// /// </summary>
|
||||
// Task RefreshProxiesAsync();
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 获取所有代理
|
||||
// /// </summary>
|
||||
// /// <returns></returns>
|
||||
// List<WebProxy> GetAllProxies();
|
||||
// }
|
||||
@ -1,106 +0,0 @@
|
||||
// // Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||
// //
|
||||
// // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||
// //
|
||||
// // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任!
|
||||
//
|
||||
// using System.Net;
|
||||
//
|
||||
// namespace Admin.NET.Core;
|
||||
//
|
||||
// /// <summary>
|
||||
// /// 代理管理器
|
||||
// /// </summary>
|
||||
// public class ProxyManager : IProxyManager, IDisposable, ITransient
|
||||
// {
|
||||
// private List<WebProxy> _proxies = new();
|
||||
//
|
||||
// private readonly HttpRemotesOptions _options;
|
||||
// private readonly object _lock = new();
|
||||
// private readonly Timer _refreshTimer;
|
||||
// private int _currentIndex = 0;
|
||||
//
|
||||
// public ProxyManager(IOptions<HttpRemotesOptions> options)
|
||||
// {
|
||||
// _options = options.Value;
|
||||
//
|
||||
// // 启动后立即加载一次
|
||||
// RefreshProxiesAsync().Wait();
|
||||
//
|
||||
// // 每 24 小时刷新一次(可改为每天固定时间)
|
||||
// _refreshTimer = new Timer(async _ => await RefreshProxiesAsync(),
|
||||
// null, TimeSpan.FromHours(24), TimeSpan.FromHours(24));
|
||||
// }
|
||||
//
|
||||
// public async Task RefreshProxiesAsync()
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var newProxies = await FetchProxiesFromRemoteAsync();
|
||||
// if (newProxies != null && newProxies.Any())
|
||||
// {
|
||||
// lock (_lock)
|
||||
// {
|
||||
// _proxies = newProxies
|
||||
// .Select(p => new WebProxy(_options.Proxy.Address)
|
||||
// {
|
||||
// Credentials = !string.IsNullOrEmpty(_options.Proxy.Account)
|
||||
// ? new NetworkCredential(_options.Proxy.Account, _options.Proxy.Password)
|
||||
// : null
|
||||
// })
|
||||
// .ToList();
|
||||
// _currentIndex = 0; // 重置索引
|
||||
// }
|
||||
// Console.WriteLine($"✅ 代理列表已刷新,共 {_proxies.Count} 个代理");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine($"❌ 刷新代理列表失败: {ex.Message}");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private async Task<List<ProxyConfig>> FetchProxiesFromRemoteAsync()
|
||||
// {
|
||||
// // 示例:从远程 API 获取代理
|
||||
// using var client = new HttpClient();
|
||||
// var response = await client.GetAsync("https://your-proxy-api.com/daily");
|
||||
// if (response.IsSuccessStatusCode)
|
||||
// {
|
||||
// var json = await response.Content.ReadAsStringAsync();
|
||||
// return JsonSerializer.Deserialize<List<ProxyConfig>>(json,
|
||||
// new JsonSerializerOptions { PropertyNameCaseInsensitive = true });
|
||||
// }
|
||||
//
|
||||
// // 可替换为数据库、文件、Redis 等来源
|
||||
// return new List<ProxyConfig>
|
||||
// {
|
||||
// new() { Address = "http://proxy1:8080", Username = "user", Password = "pass" },
|
||||
// new() { Address = "http://proxy2:8080" },
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// public WebProxy GetCurrentProxy()
|
||||
// {
|
||||
// lock (_lock)
|
||||
// {
|
||||
// if (!_proxies.Any()) return null;
|
||||
// var proxy = _proxies[_currentIndex % _proxies.Count];
|
||||
// _currentIndex = (_currentIndex + 1) % _proxies.Count;
|
||||
// return proxy;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public List<WebProxy> GetAllProxies()
|
||||
// {
|
||||
// lock (_lock)
|
||||
// {
|
||||
// return new List<WebProxy>(_proxies);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void Dispose()
|
||||
// {
|
||||
// _refreshTimer?.Dispose();
|
||||
// }
|
||||
// }
|
||||
@ -179,7 +179,7 @@ public class SysCommonService : IDynamicApiController, ITransient
|
||||
{
|
||||
if (item.Children is { Count: > 0 }) queue.EnqueueRange(item.Children);
|
||||
else apiList.Add(item.Route);
|
||||
item = queue.Count > 0 ? queue.Dequeue() : null;
|
||||
item = queue.Count > 0 ? queue.Dequeue() : null;
|
||||
}
|
||||
return apiList;
|
||||
}
|
||||
|
||||
@ -395,7 +395,6 @@ public class SysRoleService : IDynamicApiController, ITransient
|
||||
//return roleApis.Union(roleButtons).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户接口集合
|
||||
/// </summary>
|
||||
@ -415,7 +414,7 @@ public class SysRoleService : IDynamicApiController, ITransient
|
||||
{
|
||||
if (item.Children is { Count: > 0 }) queue.EnqueueRange(item.Children);
|
||||
else apiList.Add(item.Route);
|
||||
item = queue.Count > 0 ? queue.Dequeue() : null;
|
||||
item = queue.Count > 0 ? queue.Dequeue() : null;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||
// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。
|
||||
//
|
||||
// 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。
|
||||
//
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
|
||||
using Admin.NET.Core;
|
||||
using Admin.NET.Core.Service;
|
||||
using Furion;
|
||||
using Furion.Authorization;
|
||||
using Furion.DataEncryption;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "admin.net.pro",
|
||||
"type": "module",
|
||||
"version": "2.4.33",
|
||||
"lastBuildTime": "2025.08.31",
|
||||
"lastBuildTime": "2025.09.01",
|
||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||
"author": "zuohuaijun",
|
||||
"license": "MIT",
|
||||
@ -81,8 +81,8 @@
|
||||
"vue-router": "^4.5.1",
|
||||
"vue-signature-pad": "^3.0.2",
|
||||
"vue3-tree-org": "^4.2.2",
|
||||
"vxe-pc-ui": "^4.9.10",
|
||||
"vxe-table": "^4.16.2",
|
||||
"vxe-pc-ui": "^4.9.11",
|
||||
"vxe-table": "^4.16.3",
|
||||
"xe-utils": "^3.7.8",
|
||||
"xlsx-js-style": "^1.2.0"
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user