上传版本号添加测试工具,同步appkey

main
liuchunguang 2026-03-19 18:48:56 +08:00
parent 2f853ec85a
commit 5b9cadb62e
3 changed files with 124 additions and 12 deletions

View File

@ -498,6 +498,126 @@ internal class BatchBuild
throw;
}
}
/// <summary>
/// 从指定渠道目录读取 ChannelSetting.yaml返回 ChannelConfig
/// </summary>
private static ChannelConfig LoadChannelConfig(string channelName)
{
// 路径ProjectNLD/../Tool/Channels/{channelName}/ChannelSetting.yaml
string projectRoot = Directory.GetParent(Application.dataPath)?.Parent?.FullName;
string yamlPath = Path.Combine(projectRoot, "Tool", "Channels", channelName, "ChannelSetting.yaml");
Debug.Log($"[LoadChannelConfig] dataPath={Application.dataPath}");
Debug.Log($"[LoadChannelConfig] projectRoot={projectRoot}");
Debug.Log($"[LoadChannelConfig] yamlPath={yamlPath}");
if (!File.Exists(yamlPath))
throw new FileNotFoundException($"[LoadChannelConfig] 找不到渠道配置文件: {yamlPath}");
var deserializer = new DeserializerBuilder().IgnoreUnmatchedProperties().Build();
string yamlContent = File.ReadAllText(yamlPath);
var config = deserializer.Deserialize<ChannelConfig>(yamlContent);
Debug.Log($"[LoadChannelConfig] 已加载渠道={channelName}, AppAccessKey={config.AppAccessKey}, Version={config.Version}");
return config;
}
[UnityEditor.MenuItem("Test/Build/测试 SendVersion (MarketTest_Official)")]
public static void TestPostSendVersion_MarketTestOfficial()
{
var config = LoadChannelConfig("MarketTest_Official");
string testVersion = config.Version;
string accessKey = config.AppAccessKey;
string secretKey = config.AppKey;
string tag = HashUtils.MD5(testVersion);
string timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
Dictionary<string, string> signParams = new Dictionary<string, string>
{
{ "plaintext", testVersion },
{ "platform", "0" },
{ "tag", tag },
{ "timestamp", timestamp }
};
var sortedKeys = signParams.Keys.OrderBy(k => k).ToList();
string signRaw = string.Join("&", sortedKeys.Select(k => $"{k}={signParams[k]}"));
Debug.Log($"[TestSendVersion_Official] version={testVersion}, tag(MD5)={tag}");
Debug.Log($"[TestSendVersion_Official] AppAccessKey={accessKey}, AppKey={secretKey}");
Debug.Log($"[TestSendVersion_Official] 签名原文: {signRaw}");
Dictionary<string, string> headData = PostHeader.PostHeaderInfo(signParams, secretKey, accessKey);
Debug.Log($"[TestSendVersion_Official] signature: {headData["signature"]}");
SendVersionBody body = new()
{
plaintext = testVersion,
tag = tag,
platform = "0"
};
Debug.Log($"[TestSendVersion_Official] 请求 Body: {JsonUtility.ToJson(body)}");
string url = $"{Dev_PostUrl}sendVersion";
try
{
Debug.Log($"[TestSendVersion_Official] URL: {url}");
HttpHelper.PostAsync(url, body, headData).Forget();
}
catch (Exception e)
{
Debug.LogError($"[TestSendVersion_Official Exception]:{e.Message} \r\n {e.StackTrace}");
throw;
}
}
[UnityEditor.MenuItem("Test/Build/测试 Version (MarketTest_Official)")]
public static void TestPostVersion_MarketTestOfficial()
{
var config = LoadChannelConfig("MarketTest_Official");
string testVersion = config.Version;
string accessKey = config.AppAccessKey;
string secretKey = config.AppKey;
string tag = HashUtils.MD5(testVersion);
string timestamp = DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString();
// /version 接口:签名参数 platform="" (与 /sendVersion 的 "0" 不同)
Dictionary<string, string> signParams = new Dictionary<string, string>
{
{ "plaintext", testVersion },
{ "platform", "" },
{ "tag", tag },
{ "timestamp", timestamp }
};
var sortedKeys = signParams.Keys.OrderBy(k => k).ToList();
string signRaw = string.Join("&", sortedKeys.Select(k => $"{k}={signParams[k]}"));
Debug.Log($"[TestVersion_Official] version={testVersion}, tag(MD5)={tag}");
Debug.Log($"[TestVersion_Official] AppAccessKey={accessKey}, AppKey={secretKey}");
Debug.Log($"[TestVersion_Official] 签名原文: {signRaw}");
Dictionary<string, string> headData = PostHeader.PostHeaderInfo(signParams, secretKey, accessKey);
Debug.Log($"[TestVersion_Official] signature: {headData["signature"]}");
// /version Body 不含 platform 字段
LoginKeyData body = new()
{
plaintext = testVersion,
tag = tag,
};
Debug.Log($"[TestVersion_Official] 请求 Body: {JsonUtility.ToJson(body)}");
try
{
string url = $"{Dev_PostUrl}version";
Debug.Log($"[TestVersion_Official] URL: {url}");
HttpHelper.PostAsync(url, body, headData).Forget();
}
catch (Exception e)
{
Debug.LogError($"[TestVersion_Official Exception]:{e.Message} \r\n {e.StackTrace}");
throw;
}
}
#endif
[System.Serializable]
@ -549,6 +669,8 @@ internal class BatchBuild
public string AppAccessKey { get; set; }
public string AppKey { get; set; }
public string Version { get; set; }
public string PhxhBiAccessKeyId { get; set; }

View File

@ -1,10 +0,0 @@
Define_list:"OFFICIAL","SDK_CRASHSIGHT"
PackageName:"com.phxh.nlddev"
Language:"Lan_Default"
Version:"0.1.0"
CrashSight_Android: 03cdda7816, ffeaeb80-b215-4e27-b647-0ff8c6aac5e1
CrashSight_iOS: 6c1aacfcbc, 6deffc19-40ea-4549-b043-7152c538a563

View File

@ -28,8 +28,8 @@ ConfigBucketName: "nld-dev-yhpxkqgzatnrmbws"
ConfigURL: "http://yhpxkqgzatnrmbws.kedrgame.com"
# http请求配置
AppAccessKey: "0SoE48O9sayjkG8J"
AppKey: "uUi_UI1oMKWo0VOSN1zme17Z70-FlAv3Lcx2mNhoYe4="
AppAccessKey: "dH305cX1K4muqcbK"
AppKey: "PmZ9QznKLrqiXA06LapsaRMMsIhZrZFWstAalJRk9-w="
# BI服务器配置
PhxhBiAccessKeyId: "yd9kWI798IWyyq1t" # BI AccessKeyId