更改文件架构
This commit is contained in:
@@ -12,6 +12,10 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
namespace BITKit
|
||||
{
|
||||
public class AppIsNotPlayingException : Exception
|
||||
{
|
||||
public override string Message => "Application Is Not Playing";
|
||||
}
|
||||
public class BITApp
|
||||
{
|
||||
[System.Serializable]
|
||||
|
32
Packages/Core/Models/LogModel.cs
Normal file
32
Packages/Core/Models/LogModel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
#if UNITY
|
||||
#else
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
#endif
|
||||
using System;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
public interface ILog
|
||||
{
|
||||
int Id { get; }
|
||||
string EntityName { get; }
|
||||
public string Message { get; }
|
||||
public string StackTrace { get; }
|
||||
DateTime CreateTime { get; }
|
||||
string CreateUser { get; }
|
||||
}
|
||||
[System.Serializable]
|
||||
public record LogModel:ILog
|
||||
{
|
||||
#if UNITY
|
||||
#else
|
||||
[Key]
|
||||
#endif
|
||||
public int Id { get; set; }
|
||||
public string EntityName { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string StackTrace { get; set; }
|
||||
public DateTime CreateTime { get; set; }=DateTime.Now;
|
||||
public string CreateUser { get; set; } = nameof(BITKit);
|
||||
};
|
||||
}
|
3
Packages/Core/Models/LogModel.cs.meta
Normal file
3
Packages/Core/Models/LogModel.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbdc13ee7c5f4e6ea13f8a6786f74097
|
||||
timeCreated: 1686107848
|
34
Packages/Core/Models/WXPusher.cs
Normal file
34
Packages/Core/Models/WXPusher.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
namespace BITKit
|
||||
{
|
||||
[System.Serializable]
|
||||
public record WeChatMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// WXPusher接口Token
|
||||
/// </summary>
|
||||
public string appToken = "AT_93EEY2WYtU9AQzMULFVXCUIKieixCbBc";
|
||||
/// <summary>
|
||||
/// 推送内容
|
||||
/// </summary>
|
||||
public string content;
|
||||
/// <summary>
|
||||
/// 消息摘要",//消息摘要,显示在微信聊天页面或者模版消息卡片上,限制长度100,可以不传,不传默认截取content前面的内容。
|
||||
/// </summary>
|
||||
public string summary;
|
||||
/// <summary>
|
||||
/// 内容类型 1表示文字 2表示html(只发送body标签内部的数据即可,不包括body标签) 3表示markdown
|
||||
/// </summary>
|
||||
public int contentType = 1;
|
||||
/// <summary>
|
||||
/// 是否验证订阅时间,true表示只推送给付费订阅用户,false表示推送的时候,不验证付费,不验证用户订阅到期时间,用户订阅过期了,也能收到。
|
||||
/// </summary>
|
||||
public bool verifyPay = false;
|
||||
/// <summary>
|
||||
/// 推送用户的uid
|
||||
/// </summary>
|
||||
public string[] uids = new string[]
|
||||
{
|
||||
"UID_mjMsThbCofwk5YSDJvBegUv0X0jK",
|
||||
};
|
||||
}
|
||||
}
|
3
Packages/Core/Models/WXPusher.cs.meta
Normal file
3
Packages/Core/Models/WXPusher.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5cb892c46078490e904ad43dd6c7794c
|
||||
timeCreated: 1686121360
|
@@ -1,10 +1,13 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System.Threading;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BITKit.HttpNet
|
||||
{
|
||||
[System.Serializable]
|
||||
@@ -13,26 +16,24 @@ namespace BITKit.HttpNet
|
||||
System.Net.Http.HttpClient client = new();
|
||||
public override async UniTask<string> GetAsync(string url, CancellationToken cancellationToken = default)
|
||||
{
|
||||
using (var response = await client.GetAsync(url))
|
||||
{
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
using var response = await client.GetAsync(url, cancellationToken);
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
|
||||
public override async UniTask<string> PostAsync<T>(string url, T value, CancellationToken cancellationToken = default)
|
||||
{
|
||||
HttpContent content = null;
|
||||
switch (value)
|
||||
HttpContent content = value switch
|
||||
{
|
||||
case string _string:
|
||||
content = new StringContent(_string);
|
||||
break;
|
||||
default:
|
||||
//content = new ByteArrayContent(.WriteAsBytes(value));
|
||||
break;
|
||||
}
|
||||
string _string => new StringContent(_string,Encoding.Unicode,"application/json"),
|
||||
_ => new StringContent(JsonConvert.SerializeObject(value),Encoding.Unicode,"application/json")
|
||||
};
|
||||
using var response = await client.PostAsync(url, content, cancellationToken);
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
if (response.StatusCode is HttpStatusCode.OK)
|
||||
{
|
||||
return await response.Content.ReadAsStringAsync();
|
||||
}
|
||||
BIT4Log.Log<HttpClient>(response.StatusCode);
|
||||
return response.StatusCode.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -36,5 +36,10 @@ namespace BITKit
|
||||
Allow = false;
|
||||
value = default;
|
||||
}
|
||||
|
||||
public static implicit operator T(Optional<T> self)
|
||||
{
|
||||
return self.value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user