Browse Source

添加数据管理通讯

“hujiajun” 1 month ago
parent
commit
1ef1ee0f49

+ 48 - 0
Assets/DataManager.cs

@@ -12,6 +12,7 @@ using Random = System.Random;
 
 
 public class DataManager : MonoBehaviour
 public class DataManager : MonoBehaviour
 {
 {
+    public static int admin=0;
     public static string acc="";
     public static string acc="";
     public static string email="";
     public static string email="";
     public static string token="";
     public static string token="";
@@ -22,6 +23,53 @@ public class DataManager : MonoBehaviour
         Instance = this;
         Instance = this;
           // StartCoroutine(wx_demo("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx9a280bbd81c64f56&secret=aeb6e5818800f8196fcac007e992dae0"));
           // StartCoroutine(wx_demo("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx9a280bbd81c64f56&secret=aeb6e5818800f8196fcac007e992dae0"));
     }
     }
+    public IEnumerator SetdonghuanSetting(int a,int b,int c,Action<string> callback)
+    {   
+
+        JsonData d = new JsonData();
+        d["current_data_source"] = a;
+        d["backup_data_switch_type"] = b;
+        d["data_recover_type"] = c;
+        yield return StartCoroutine(Post_Demo("/admin/donghuanSetting", d.ToJson(), (string msg) => {
+            callback.Invoke(msg);
+        }));
+        
+    }
+
+    public IEnumerator SetzongjiSetting(int a,int b,int c,Action<string> callback)
+    {   
+
+        JsonData d = new JsonData();
+        d["current_data_source"] = a;
+        d["backup_data_switch_type"] = b;
+        d["data_recover_type"] = c;
+        yield return StartCoroutine(Post_Demo("/admin/zongjiSetting", d.ToJson(), (string msg) => {
+            callback.Invoke(msg);
+        }));
+        
+    }
+    public IEnumerator SetyunnengSetting(int a,int b,int c,Action<string> callback)
+    {   
+
+        JsonData d = new JsonData();
+        d["current_data_source"] = a;
+        d["backup_data_switch_type"] = b;
+        d["data_recover_type"] = c;
+        yield return StartCoroutine(Post_Demo("/admin/yunnengSetting", d.ToJson(), (string msg) => {
+            callback.Invoke(msg);
+        }));
+        
+    }
+
+    public IEnumerator SetgeneralSetting(bool b,Action<string> callback)
+    {
+        JsonData d = new JsonData();
+        d["update_time_display_switch"] = b;
+        yield return StartCoroutine(Post_Demo("/admin/generalSetting", d.ToJson(), (string msg) => {
+            callback.Invoke(msg);
+        }));
+        
+    }
 
 
     public IEnumerator GetUserList(Action<string> callback)
     public IEnumerator GetUserList(Action<string> callback)
     {
     {

+ 1 - 0
Assets/LoginManager.cs

@@ -130,6 +130,7 @@ public class LoginManager : MonoBehaviour
                         {
                         {
 
 
                             DataManager.Instance.getuserinfo((msg) => {
                             DataManager.Instance.getuserinfo((msg) => {
+                                    DataManager.admin = msg.admin;
                                     if(msg.admin==1)
                                     if(msg.admin==1)
                                     {
                                     {
                                         for (int i = 0;i<list.Count;i++)
                                         for (int i = 0;i<list.Count;i++)

+ 19 - 0
Assets/MainLeftManager.cs

@@ -34,4 +34,23 @@ public class MainLeftManager : MonoBehaviour
     public void choose(string index)
     public void choose(string index)
     {
     {
     }
     }
+    public List<GameObject> list;
+    private void OnEnable() {
+        
+        if(DataManager.admin==1)
+        {
+            for (int i = 0;i<list.Count;i++)
+            {
+                list[i].SetActive(true);
+            }
+        }
+        else
+        {
+            for (int i = 0;i<list.Count;i++)
+            {
+                list[i].SetActive(false);
+            }
+
+        }
+    }
 }
 }

File diff suppressed because it is too large
+ 2 - 44
Assets/Scenes/Main.unity


+ 48 - 1
Assets/ShuJuYuanGuanLi.cs

@@ -26,11 +26,14 @@ public class ShuJuYuanGuanLi : MonoBehaviour
     public GameObject go;
     public GameObject go;
 
 
     public List<GameObject> golist;
     public List<GameObject> golist;
+
+    int index = 0;
     private void Awake()
     private void Awake()
     {
     {
         yt.onValueChanged.AddListener((b) => {
         yt.onValueChanged.AddListener((b) => {
             if(b&& ainfo!=null)
             if(b&& ainfo!=null)
             {
             {
+                index=0;
                 refinfo(ainfo.yunneng_option);
                 refinfo(ainfo.yunneng_option);
             }
             }
 
 
@@ -38,6 +41,7 @@ public class ShuJuYuanGuanLi : MonoBehaviour
         zt.onValueChanged.AddListener((b) => {
         zt.onValueChanged.AddListener((b) => {
             if (b && ainfo != null)
             if (b && ainfo != null)
             {
             {
+                index=1;
                 refinfo(ainfo.zongji_ption);
                 refinfo(ainfo.zongji_ption);
 
 
             }
             }
@@ -45,6 +49,7 @@ public class ShuJuYuanGuanLi : MonoBehaviour
         dt.onValueChanged.AddListener((b) => {
         dt.onValueChanged.AddListener((b) => {
             if (b && ainfo != null)
             if (b && ainfo != null)
             {
             {
+                index=2;
                 refinfo(ainfo.donghuan_option);
                 refinfo(ainfo.donghuan_option);
 
 
             }
             }
@@ -58,9 +63,10 @@ public class ShuJuYuanGuanLi : MonoBehaviour
         zt.onValueChanged.RemoveAllListeners();
         zt.onValueChanged.RemoveAllListeners();
         dt.onValueChanged.RemoveAllListeners();
         dt.onValueChanged.RemoveAllListeners();
     }
     }
-
+    Toption nt;
     public void refinfo(Toption t)
     public void refinfo(Toption t)
     {
     {
+        nt=t;
         for (int i = 0; i < golist.Count; i++)
         for (int i = 0; i < golist.Count; i++)
         {
         {
             Destroy(golist[i]);
             Destroy(golist[i]);
@@ -107,4 +113,45 @@ public class ShuJuYuanGuanLi : MonoBehaviour
             });
             });
         }
         }
     }
     }
+
+    public void setty(bool b)
+    {
+        ainfo.general_option.update_time_display_switch= b;
+       StartCoroutine( DataManager.Instance.SetgeneralSetting(b,(msg)=>{}));
+    }
+
+    public void setbackup(bool b)
+    {
+        nt.backup_data_switch_type = b?1:0;
+        switch(index)
+        {
+            case 0:
+           StartCoroutine(DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
+            break;
+            case 1:
+            StartCoroutine(DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
+            break;
+            case 2:
+           StartCoroutine( DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
+            break;
+        }
+    }
+
+    public void setrecover(bool b)
+    {
+        nt.data_recover_type = b?1:0;
+        switch(index)
+        {
+            case 0:
+           StartCoroutine( DataManager.Instance.SetyunnengSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
+            break;
+            case 1:
+           StartCoroutine( DataManager.Instance.SetzongjiSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
+            break;
+            case 2:
+          StartCoroutine(  DataManager.Instance.SetdonghuanSetting(nt.current_data_source,nt.backup_data_switch_type,nt.data_recover_type,(msg)=>{}));
+            break;
+        }
+    }
+
 }
 }

+ 1 - 1
Assets/StreamingAssets/1.txt

@@ -1 +1 @@
-http://192.168.50.14:8888/feature-tester/v1
+https://api-fat2.ghz-tech.com/feature-tester/v1

BIN
Assets/StreamingAssets/Main/exit_bt.png


+ 7 - 0
Assets/StreamingAssets/Main/exit_bt.png.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 965ccee8653994af99d91361a400d7fe
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 36 - 34
Assets/zhanghaomanager.cs

@@ -34,6 +34,7 @@ public class zhanghaomanager : MonoBehaviour
     }
     }
     int choose =-1;
     int choose =-1;
     private void Awake() {
     private void Awake() {
+                list.Add(go);
         t1.onValueChanged.AddListener((b)=>{
         t1.onValueChanged.AddListener((b)=>{
 
 
             if(b)
             if(b)
@@ -81,7 +82,7 @@ public class zhanghaomanager : MonoBehaviour
         }
         }
     }
     }
     List<JsonData> datamsg =new List<JsonData>();
     List<JsonData> datamsg =new List<JsonData>();
-   int MaxLiebiao=11;
+    int MaxLiebiao=11;
     public void RemoveAll()
     public void RemoveAll()
     {
     {
         datamsg=new List<JsonData>();
         datamsg=new List<JsonData>();
@@ -91,30 +92,7 @@ public class zhanghaomanager : MonoBehaviour
     {
     {
         RemoveAll();
         RemoveAll();
         startinit=false;
         startinit=false;
-        for (int i = 0; i < list.Count; i++)
-        {
-            list[i].SetActive(false);
-        }  
-        List<JsonData> ndatamsg =new List<JsonData>();
-        for (int i = 0;i<datamsg.Count;i++)
-        {
-            if(datamsg[i]["name"].ToString().Contains(searchstr.text)||datamsg[i]["account"].ToString().Contains(searchstr.text))
-            {
-                if(ndatamsg.Count<MaxLiebiao)
-                {
-                    list[i].GetComponent<UserInfoItem>().init(datamsg[i]);   
-                    list[i].SetActive(true);
-                }
-                ndatamsg.Add(datamsg[i]);
-            }
-            else
-            {
-               list[i].SetActive(false);
-
-            }
-        }
-        Debug.Log("搜索到:"+ndatamsg.Count);
-        uiScroll.InitList(0, ndatamsg.Count);
+        StartCoroutine(getreplist());
     }
     }
     public Text searchstr;
     public Text searchstr;
     public  IEnumerator getreplist()
     public  IEnumerator getreplist()
@@ -135,11 +113,18 @@ public class zhanghaomanager : MonoBehaviour
 
 
                         if(jd["data"]["list"].ToString()!="[]"&&jd["data"]["list"].Count> i)
                         if(jd["data"]["list"].ToString()!="[]"&&jd["data"]["list"].Count> i)
                         {
                         {
-                            if(choose==-1||choose.ToString()==jd["data"]["list"][i]["admin"].ToString())
+                            if(jd["data"]["list"][i]["name"].ToString().Contains(searchstr.text)||jd["data"]["list"][i]["account"].ToString().Contains(searchstr.text))
                             {
                             {
-                                list[i].GetComponent<UserInfoItem>().init(jd["data"]["list"][i]);   
-                                list[i].SetActive(true);
-                                datamsg.Add(jd["data"]["list"][i]);
+                                if(choose==-1||choose.ToString()==jd["data"]["list"][i]["admin"].ToString())
+                                {
+                                    list[i].GetComponent<UserInfoItem>().init(jd["data"]["list"][i]);   
+                                    //list[i].SetActive(true);
+                                    datamsg.Add(jd["data"]["list"][i]);
+                                }
+                                else
+                                {
+                                    list[i].SetActive(false);
+                                }
                             }
                             }
                             else
                             else
                             {
                             {
@@ -153,14 +138,18 @@ public class zhanghaomanager : MonoBehaviour
                     }
                     }
                     for (int i = datamsg.Count;i<jd["data"]["list"].Count;i++)
                     for (int i = datamsg.Count;i<jd["data"]["list"].Count;i++)
                     {
                     {
-                        if(choose==-1||choose.ToString()==jd["data"]["list"][i]["admin"].ToString())
+                        if(jd["data"]["list"][i]["name"].ToString().Contains(searchstr.text)||jd["data"]["list"][i]["account"].ToString().Contains(searchstr.text))
                         {
                         {
-                            if(i<list.Count)
+                            if(choose==-1||choose.ToString()==jd["data"]["list"][i]["admin"].ToString())
                             {
                             {
-                                list[i].GetComponent<UserInfoItem>().init(jd["data"]["list"][i]);   
-                                list[i].SetActive(true);
+                                if(i<list.Count)
+                                {
+                                    list[i].GetComponent<UserInfoItem>().init(jd["data"]["list"][i]);   
+                                   // list[i].SetActive(true);
+                                }
+                                if(i>=MaxLiebiao)
+                                    datamsg.Add(jd["data"]["list"][i]);
                             }
                             }
-                            datamsg.Add(jd["data"]["list"][i]);
                         }
                         }
                     }
                     }
                 } 
                 } 
@@ -172,7 +161,20 @@ public class zhanghaomanager : MonoBehaviour
                     }  
                     }  
 
 
                 } 
                 } 
+                if(datamsg.Count!=0)
+                {
+                    Debug.Log("datamsg===>"+datamsg.Count);
                 uiScroll.InitList(0, datamsg.Count);
                 uiScroll.InitList(0, datamsg.Count);
+
+                }
+                else
+                {
+                    for (int i = 0; i < list.Count; i++)
+                    {
+                        list[i].SetActive(false);
+                    }  
+
+                } 
                 startinit=true;
                 startinit=true;
                      
                      
         }));
         }));

BIN
test2/test/Build/test.data.unityweb


BIN
test2/test/Build/test.framework.js.unityweb


BIN
test2/test/Build/test.symbols.json.unityweb


BIN
test2/test/Build/test.wasm.unityweb


+ 1 - 1
test2/test/StreamingAssets/1.txt

@@ -1 +1 @@
-http://192.168.50.14:8888/feature-tester/v1
+http://192.168.10.6:8888/feature-tester/v1

BIN
test2/test/StreamingAssets/Main/exit_bt.png


BIN
test2/test/临港大屏20241030-1.zip


Some files were not shown because too many files changed in this diff