1
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 请求 - 管理器
|
||||
/// </summary>
|
||||
public class ManagerRequest : ModuleSingle<ManagerRequest> {
|
||||
|
||||
/// <summary> 域名 </summary>
|
||||
public static string Address => "http://localhost:5086";
|
||||
|
||||
protected override void Awake() => NoReplace(false);
|
||||
|
||||
#region 用户
|
||||
/// <summary> 登录 </summary>
|
||||
public void Login(string username, string password, Action<string> callback) {
|
||||
string url = Address + "/api/user/login";
|
||||
DataLoginRequest login = new DataLoginRequest { username = username, password = password };
|
||||
PostForm(url, login, callback);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 请求类型
|
||||
public void PostForm<T>(string url, T data, Action<string> callback) {
|
||||
string json = JsonTool.ToJson(data);
|
||||
Debug.Log(json);
|
||||
DataRequestPost request = new DataRequestPost(url, json);
|
||||
request.OnError = (json) => { ErrorHandle(url, json); };
|
||||
request.OnCallback = callback;
|
||||
NetworkRequestAsync.Execute(request);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 结果处理
|
||||
/// <summary> 错误处理 </summary>
|
||||
private void ErrorHandle(string url, string json) {
|
||||
Debug.LogError($"{url} \n {json}");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2b4112fa4a2bfe84984b0472be3af46c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 全局管理器
|
||||
/// </summary>
|
||||
public class SingleManager : ModuleSingle<SingleManager> {
|
||||
protected override void Awake() => NoReplace();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50f6b4ec374a86846b626668e0b5627e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user