修改导表授权
parent
8d5a395d92
commit
4afc5d5227
|
|
@ -94,16 +94,19 @@ public static class ConfigTools
|
|||
|
||||
if (!File.Exists(combiePath))
|
||||
{
|
||||
DownloadConfig();
|
||||
var sid = EditorPrefs.GetString("ConfSid");
|
||||
var cookies = EditorPrefs.GetString("ConfCookie");
|
||||
DownloadConfig(cookies);
|
||||
}
|
||||
|
||||
ConfigWindow.ShowWindow();
|
||||
}
|
||||
|
||||
public static async void DownloadConfig()
|
||||
public static async void DownloadConfig(string cookies)
|
||||
{
|
||||
EditorUtility.DisplayProgressBar("配置工具", $"正在下ConfigList....", 0);
|
||||
var downLoader = new WPExcelDownloader("AConfigList.xlsx", "e3_AQIA8QbmAKEFwoGRFPhT9uizRsOaA");
|
||||
var downLoader = new WPExcelDownloader("AConfigList.xlsx",
|
||||
"e3_AQIA8QbmAKEFwoGRFPhT9uizRsOaA", cookies);
|
||||
|
||||
var dir = new DirectoryInfo(CONFIG_DIR);
|
||||
AutoConfig.DownloadConfig.SAVE_PATH = dir.FullName + "Datas/";
|
||||
|
|
|
|||
|
|
@ -4,7 +4,9 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using System;
|
||||
using AutoConfig;
|
||||
using Luban.Editor;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
public class ConfigInfo
|
||||
{
|
||||
|
|
@ -30,41 +32,44 @@ public class ConfigWindow : EditorWindow
|
|||
|
||||
private Vector2 scrollPosition = Vector2.zero;
|
||||
|
||||
private string sid;
|
||||
private string cookie;
|
||||
const string DATA_TABLE_ASSEMBLY_REFERENCE_PATH = "Assets/Code/Scripts/Gameplay/DataTable/FrameWork.asmref";
|
||||
const string DATA_TABLE_OUTSIDE_ASSEMBLY_REFERENCE_PATH = "Assets/Code/Scripts/Gameplay/FrameWork.asmref";
|
||||
|
||||
/// <summary>
|
||||
/// 0 未知
|
||||
/// 1 checking
|
||||
/// 2 ok
|
||||
/// 3 failed
|
||||
/// </summary>
|
||||
private int _authState = 0;
|
||||
|
||||
public static void ShowWindow()
|
||||
{
|
||||
try
|
||||
{
|
||||
ConfigWindow window = GetWindow(typeof(ConfigWindow)) as ConfigWindow;
|
||||
window.titleContent = new GUIContent("自动化配置工具");
|
||||
window.maximized = false;
|
||||
window.minSize = new Vector2(300, 300);
|
||||
|
||||
int width = 600;
|
||||
int height = 400;
|
||||
var x = (Screen.currentResolution.width - width) / 2;
|
||||
var y = (Screen.currentResolution.height - height) / 2;
|
||||
Rect centerRect = new Rect(x, y, width, height);
|
||||
window.position = centerRect;
|
||||
var window = GetWindow<ConfigWindow>();
|
||||
window.titleContent = new GUIContent("自动化配置工具");
|
||||
window.maximized = false;
|
||||
window.minSize = new Vector2(300, 300);
|
||||
|
||||
window.InitData();
|
||||
window.Show();
|
||||
int width = 600;
|
||||
int height = 400;
|
||||
var x = (Screen.currentResolution.width - width) / 2;
|
||||
var y = (Screen.currentResolution.height - height) / 2;
|
||||
Rect centerRect = new Rect(x, y, width, height);
|
||||
window.position = centerRect;
|
||||
window._authState = 0;
|
||||
window.InitData();
|
||||
window.Show();
|
||||
window.Focus();
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogError("ShowWindow catch exception, msg=" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitData()
|
||||
{
|
||||
var dir = new DirectoryInfo(ConfigTools.CONFIG_DIR);
|
||||
var combiePath = dir.FullName + "Datas/AConfigList.xlsx";
|
||||
|
||||
|
||||
// var configPath = ConfigTools.CONFIG_DIR + "/config_list.txt";
|
||||
// var lines = File.ReadAllLines(configPath);
|
||||
|
||||
|
|
@ -88,53 +93,126 @@ public class ConfigWindow : EditorWindow
|
|||
m_Configs.Add(ci);
|
||||
}
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
Debug.LogError($"配置文件不存在,path={combiePath}");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ExportClient = true;
|
||||
ExportServer = false;
|
||||
|
||||
NeedDownload = true;
|
||||
|
||||
sid = PlayerPrefs.GetString("ConfSid", "");
|
||||
cookie = PlayerPrefs.GetString("ConfCookie", "");
|
||||
cookie = EditorPrefs.GetString("ConfCookie", "");
|
||||
}
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
try {
|
||||
OnGUIContent();
|
||||
}
|
||||
catch
|
||||
OnGUIContent();
|
||||
}
|
||||
|
||||
private async void _StartChecking()
|
||||
{
|
||||
if (string.IsNullOrEmpty(cookie)) return;
|
||||
_authState = 1;
|
||||
|
||||
var downLoader = new WPExcelDownloader("AConfigList.xlsx",
|
||||
"e3_AQIA8QbmAKEFwoGRFPhT9uizRsOaA",cookie);
|
||||
Debug.Log("开始检查授权");
|
||||
|
||||
var checkResult = await downLoader.OnlyCheck();
|
||||
if (checkResult)
|
||||
{
|
||||
EditorGUILayout.LabelField("请关闭窗口重新打开");
|
||||
Debug.Log("授权成功");
|
||||
_authState = 2;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Debug.LogError("授权失败");
|
||||
_authState = 3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void _ShowSIDConfig()
|
||||
{
|
||||
cookie = EditorGUILayout.TextField("Cookie:", cookie);
|
||||
GUILayout.BeginHorizontal();
|
||||
if (GUILayout.Button("重新检查授权"))
|
||||
{
|
||||
_StartChecking();
|
||||
}
|
||||
if (GUILayout.Button("打开授权网页"))
|
||||
{
|
||||
_OpenAuthWindow();
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void _OpenAuthWindow()
|
||||
{
|
||||
var url = "https://doc.weixin.qq.com/sheet/e3_Ab4A8gbmAKEPGX4tMzIRYCedjxh0O?scode=ADIAuQeZAGMDe7Ww2ZAb4A8gbmAKE&tab=BB08J2";
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
|
||||
void OnGUIContent()
|
||||
{
|
||||
|
||||
GUILayout.Space(10);
|
||||
switch (_authState)
|
||||
{
|
||||
case 0:
|
||||
// 未知
|
||||
if (string.IsNullOrEmpty(cookie))
|
||||
{
|
||||
// 未配置
|
||||
EditorGUILayout.HelpBox("请先配置sid和cookie", MessageType.Error);
|
||||
|
||||
sid = EditorGUILayout.TextField("SID:", sid);
|
||||
cookie = EditorGUILayout.TextField("Cookie:", cookie);
|
||||
_ShowSIDConfig();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 已配置
|
||||
_ShowSIDConfig();
|
||||
|
||||
_StartChecking();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
EditorGUILayout.HelpBox("检查授权中", MessageType.Warning);
|
||||
|
||||
_ShowSIDConfig();
|
||||
break;
|
||||
case 2:
|
||||
EditorGUILayout.HelpBox("授权成功", MessageType.Info);
|
||||
|
||||
_ShowSIDConfig();
|
||||
break;
|
||||
|
||||
case 3:
|
||||
EditorGUILayout.HelpBox("授权失败", MessageType.Error);
|
||||
|
||||
_ShowSIDConfig();
|
||||
break;
|
||||
}
|
||||
|
||||
if (GUILayout.Button("刷新Config List"))
|
||||
{
|
||||
PlayerPrefs.SetString("ConfSid", sid);
|
||||
PlayerPrefs.SetString("ConfCookie", cookie);
|
||||
|
||||
EditorPrefs.SetString("ConfCookie", cookie);
|
||||
|
||||
ConfigTools.DownloadConfig();
|
||||
ConfigTools.DownloadConfig( cookie);
|
||||
InitData();
|
||||
}
|
||||
|
||||
GUILayout.Space(10);
|
||||
|
||||
GUILayout.Label("配置列表:", EditorStyles.boldLabel);
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.Label("配置列表:", EditorStyles.boldLabel);
|
||||
GUILayout.Label("共计:" + m_Configs.Count);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
|
||||
for (int i = 0; i < m_Configs.Count; i++)
|
||||
{
|
||||
|
|
@ -218,12 +296,12 @@ public class ConfigWindow : EditorWindow
|
|||
|
||||
if (GUILayout.Button(buttonName))
|
||||
{
|
||||
if (string.IsNullOrEmpty(sid) || string.IsNullOrEmpty(cookie)) {
|
||||
if (string.IsNullOrEmpty(cookie))
|
||||
{
|
||||
EditorUtility.DisplayDialog("配置工具", "请先配置sid和cookie", "OK");
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerPrefs.SetString("ConfSid", sid);
|
||||
|
||||
PlayerPrefs.SetString("ConfCookie", cookie);
|
||||
|
||||
_AsyncAction();
|
||||
|
|
@ -231,6 +309,7 @@ public class ConfigWindow : EditorWindow
|
|||
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
|
||||
private void MoveDataTableAssemblyReference(bool isOut)
|
||||
{
|
||||
if (isOut)
|
||||
|
|
@ -238,44 +317,38 @@ public class ConfigWindow : EditorWindow
|
|||
else
|
||||
AssetDatabase.MoveAsset(DATA_TABLE_OUTSIDE_ASSEMBLY_REFERENCE_PATH, DATA_TABLE_ASSEMBLY_REFERENCE_PATH);
|
||||
}
|
||||
|
||||
private async void _AsyncAction()
|
||||
{
|
||||
// MoveDataTableAssemblyReference(true);
|
||||
try
|
||||
bool needDownload = false;
|
||||
for (int i = 0; i < m_Configs.Count; i++)
|
||||
{
|
||||
bool needDownload = false;
|
||||
for (int i = 0; i < m_Configs.Count; i++)
|
||||
{
|
||||
m_Configs[i].IsDownloadOK = false;
|
||||
m_Configs[i].IsDownloadOK = false;
|
||||
|
||||
if (m_Configs[i].Check)
|
||||
needDownload = true;
|
||||
}
|
||||
|
||||
if (needDownload && NeedDownload)
|
||||
{
|
||||
await AutoConfig.DownloadConfig.AutoProcessConfig(m_Configs);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("当前没有需要下载的配置,已跳过");
|
||||
}
|
||||
|
||||
await UniTask.Delay(100);
|
||||
|
||||
if (ExportClient)
|
||||
{
|
||||
var lubanAsset = AssetDatabase.LoadAssetAtPath<LubanExportConfig>("Assets/Editor/Tools/Luban_Client.asset");
|
||||
lubanAsset.Gen();
|
||||
}
|
||||
|
||||
if (ExportServer)
|
||||
ConfigTools.ConfigExportServer();
|
||||
if (m_Configs[i].Check)
|
||||
needDownload = true;
|
||||
}
|
||||
finally
|
||||
|
||||
if (needDownload && NeedDownload)
|
||||
{
|
||||
// MoveDataTableAssemblyReference(false);
|
||||
await AutoConfig.DownloadConfig.AutoProcessConfig(m_Configs, cookie);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("当前没有需要下载的配置,已跳过");
|
||||
}
|
||||
|
||||
await UniTask.Delay(100);
|
||||
|
||||
if (ExportClient)
|
||||
{
|
||||
var lubanAsset = AssetDatabase.LoadAssetAtPath<LubanExportConfig>("Assets/Editor/Tools/Luban_Client.asset");
|
||||
lubanAsset.Gen();
|
||||
}
|
||||
|
||||
if (ExportServer)
|
||||
ConfigTools.ConfigExportServer();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -20,22 +20,8 @@ namespace AutoConfig
|
|||
|
||||
private static int _totalDownloadCount;
|
||||
private static int _DownloadCount;
|
||||
|
||||
// [MenuItem("LTGame/Test")]
|
||||
public static async void TestFunc()
|
||||
{
|
||||
//download_single_file("AConfigList.xlsx", "e3_AQIA8QbmAKEFwoGRFPhT9uizRsOaA")
|
||||
var downLoader = new WPExcelDownloader("AConfigList.xlsx", "e3_AQIA8QbmAKEFwoGRFPhT9uizRsOaA");
|
||||
var result = await downLoader.StartDownload();
|
||||
if (result)
|
||||
{
|
||||
var combiePath = SAVE_PATH + "AConfigList.xlsx";
|
||||
var list = ReadExcelList.ReadList(combiePath);
|
||||
Debug.Log("读取成功:" + list.Count);
|
||||
}
|
||||
}
|
||||
|
||||
public static async UniTask AutoProcessConfig(List<ConfigInfo> m_Configs)
|
||||
|
||||
public static async UniTask AutoProcessConfig(List<ConfigInfo> m_Configs, string cookie)
|
||||
{
|
||||
var dir = new DirectoryInfo(ConfigTools.CONFIG_DIR);
|
||||
SAVE_PATH = dir.FullName + "Datas/";
|
||||
|
|
@ -49,7 +35,7 @@ namespace AutoConfig
|
|||
{
|
||||
if (m_Configs[i].Check)
|
||||
{
|
||||
StartDownload(m_Configs[i]);
|
||||
StartDownload(m_Configs[i], cookie);
|
||||
_totalDownloadCount++;
|
||||
}
|
||||
|
||||
|
|
@ -103,9 +89,9 @@ namespace AutoConfig
|
|||
|
||||
}
|
||||
|
||||
public static async void StartDownload(ConfigInfo ci)
|
||||
public static async void StartDownload(ConfigInfo ci, string cookie)
|
||||
{
|
||||
var downloader = new WPExcelDownloader(ci.Name, ci.DocID);
|
||||
var downloader = new WPExcelDownloader(ci.Name, ci.DocID, cookie);
|
||||
var result = await downloader.StartDownload();
|
||||
|
||||
if (result)
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ using System.Text;
|
|||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
namespace AutoConfig
|
||||
{
|
||||
|
|
@ -19,7 +20,7 @@ namespace AutoConfig
|
|||
//{"Cookie","wedoc_openid=wozbKqDgAAYt6fSGwDXda25jv2p5OP0w; wedoc_sid=1kBsM4ycejYuLERYAMRFUQAA; wedoc_sids=13102701888889220&1oQwT4xhZXMur2NhAINNSgAA|13102702970838080&1kBsM4ycejYuLERYAMRFUQAA; wedoc_skey=13102701888889220&ac00476fed4403712cae26060dfb39b6||13102702970838080&b89214c23c46059d0221af76cb528adb; wedoc_ticket=13102701888889220&CAESIG807y5KZMJpoC13g7JnkNY7pdaXE4n_sycBDYT9KEnH|13102702970838080&CAESIAhdu0oATYX8_OokDtb82-QP6zCNIe-ecFzDi53s5For;" }
|
||||
};
|
||||
|
||||
public string sid;
|
||||
public string cookies;
|
||||
public string docId;
|
||||
public string docName;
|
||||
|
||||
|
|
@ -27,20 +28,21 @@ namespace AutoConfig
|
|||
private int _progress;
|
||||
private string _downloadUrl;
|
||||
|
||||
public WPExcelDownloader(string docName, string docId)
|
||||
public WPExcelDownloader(string docName, string docId, string cookies)
|
||||
{
|
||||
this.docName = docName;
|
||||
this.docId = docId;
|
||||
_progress = 0;
|
||||
|
||||
this.cookies = cookies;
|
||||
|
||||
sid = PlayerPrefs.GetString("ConfSid");
|
||||
_headers["Cookie"] = PlayerPrefs.GetString("ConfCookie");
|
||||
|
||||
Debug.Log("开始下载:" + docName);
|
||||
_headers["Cookie"] = this.cookies;
|
||||
}
|
||||
|
||||
public async UniTask<bool> StartDownload()
|
||||
{
|
||||
Debug.Log("开始下载:" + docName);
|
||||
|
||||
var result = await _RequestOperationId();
|
||||
if (!result)
|
||||
{
|
||||
|
|
@ -59,6 +61,12 @@ namespace AutoConfig
|
|||
return r3;
|
||||
}
|
||||
|
||||
public async UniTask<bool> OnlyCheck()
|
||||
{
|
||||
var result = await _RequestOperationId();
|
||||
return result;
|
||||
}
|
||||
|
||||
private async UniTask<bool> _StartDownload()
|
||||
{
|
||||
var url = _downloadUrl;
|
||||
|
|
@ -140,6 +148,7 @@ namespace AutoConfig
|
|||
|
||||
private async UniTask<bool> _RequestOperationId()
|
||||
{
|
||||
var sid = Random.Range(1000, 10000) + "";
|
||||
var url = $"https://doc.weixin.qq.com/v1/export/export_office?sid={sid}&wedoc_xsrf=1&docId={docId}&version=2";
|
||||
var request = UnityWebRequest.PostWwwForm(url, "");
|
||||
foreach (var data in _headers)
|
||||
|
|
|
|||
Loading…
Reference in New Issue