43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using Newtonsoft.Json;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using Unity.VisualScripting.Antlr3.Runtime;
|
||
using UnityEditor.PackageManager;
|
||
using UnityEngine;
|
||
|
||
public class getTemplateList : MonoBehaviour
|
||
{
|
||
|
||
// 创建请求头,使用最新的 token
|
||
public Dictionary<string, string> CreateHeaders()
|
||
{
|
||
|
||
|
||
if (string.IsNullOrEmpty(Global.global.loginResponse.data.access_token))
|
||
{
|
||
Debug.LogWarning("尝试创建请求头时,token 未设置。");
|
||
return new Dictionary<string, string>();
|
||
}
|
||
|
||
return new Dictionary<string, string>
|
||
{
|
||
{ "Authorization","Bearer "+Global.global.loginResponse.data.access_token },
|
||
{"clientId", "e5cd7e4891bf95d1d19206ce24a7b32e" }
|
||
};
|
||
}
|
||
//获取模板列表
|
||
public async void TemplaRst()
|
||
{
|
||
string response = await web.SendRequest(web.URL + "/game/gameTemplate/list", "GET", "", CreateHeaders());
|
||
Debug.Log("获取模板列表" + response);
|
||
//解析服务器返回的数据
|
||
TemplateListData templateListData = JsonConvert.DeserializeObject<TemplateListData>(response);
|
||
Debug.Log("================" + templateListData.msg);
|
||
}
|
||
}
|
||
//=======================================================================================================
|
||
public class TemplateListData : Response
|
||
{
|
||
public string[] data;
|
||
}
|
||
//================= |