兼容win7版应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

122 lines
3.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AIK.Models.SystemSettings
{
public class ApiSettings
{
// [修改] 私有字段存储原始配置
private string _baseUrl = string.Empty;
// [修改] 公开属性
public string BaseUrl
{
get => _baseUrl;
set
{
#if CN
//适应域名更改逻辑
if (value == "https://key.aik518.com")
{
_baseUrl = "https://key.aikkey.cn";
}
else
{
_baseUrl = value;
}
#else
_baseUrl = value; // 非CN环境保持原样
#endif
}
}
//public string BaseUrl { get; set; } = string.Empty;
//public string FileUrl { get; set; } = string.Empty;
//public string QRCodeUrl { get; set; } = string.Empty;
//public string WSUrl { get; set; } = string.Empty;
// --- FileUrl (新增逻辑) ---
private string _fileUrl = string.Empty;
public string FileUrl
{
get => _fileUrl;
set
{
#if CN
// 假设文件服务也在同一个新域名下,如果是不同域名请修改判断条件
if (value.Contains("key.aik518.com"))
_fileUrl = value.Replace("key.aik518.com", "key.aikkey.cn");
else
_fileUrl = value;
#else
_fileUrl = value;
#endif
}
}
// --- QRCodeUrl (新增逻辑) ---
private string _qrCodeUrl = string.Empty;
public string QRCodeUrl
{
get => _qrCodeUrl;
set
{
#if CN
if (value.Contains("key.aik518.com"))
_qrCodeUrl = value.Replace("key.aik518.com", "key.aikkey.cn");
else
_qrCodeUrl = value;
#else
_qrCodeUrl = value;
#endif
}
}
// --- WSUrl (新增逻辑) ---
private string _wsUrl = string.Empty;
public string WSUrl
{
get => _wsUrl;
set
{
#if CN
if (value.Contains("key.aik518.com"))
_wsUrl = value.Replace("key.aik518.com", "key.aikkey.cn");
else
_wsUrl = value;
#else
_wsUrl = value;
#endif
}
}
public int Timeout { get; set; } = 30;
public int RetryCount { get; set; } = 3;
public ApiEndpoints Endpoints { get; set; } = new();
public string Language { get; set; } = string.Empty;
/// <summary>
/// AI 客服 Web 聊天页 URL(JSBridge 方式加载)
/// </summary>
public string AiWebChatUrl { get; set; } = "http://localhost:1001/chat";
}
public class ApiEndpoints
{
public string GetCarData { get; set; } = string.Empty;
public string GetCarModels { get; set; } = string.Empty;
public string GetCarImages { get; set; } = string.Empty;
public string Authentication { get; set; } = string.Empty;
}
public class CacheSettings
{
public int DataCacheExpiryHours { get; set; } = 3;
public int ImageCacheExpiryDays { get; set; } = 7;
public int MaxCacheSizeMB { get; set; } = 100;
public TimeSpan DataCacheExpiry => TimeSpan.FromHours(DataCacheExpiryHours);
public TimeSpan ImageCacheExpiry => TimeSpan.FromDays(ImageCacheExpiryDays);
public long MaxCacheSizeBytes => MaxCacheSizeMB * 1024L * 1024L;
}
}