消息通知逻辑

This commit is contained in:
CaiYanPeng 2022-01-26 10:32:21 +08:00
parent 28487b295b
commit 5edd784080
5 changed files with 37 additions and 10 deletions

View File

@ -63,6 +63,8 @@ public static class App
//全局用 输入框或者下拉框修改标志位 //全局用 输入框或者下拉框修改标志位
public static bool isChanged { get; set; } public static bool isChanged { get; set; }
public static string notifyContent { get; internal set; } public static string notifyContent { get; internal set; }
//全局用,如果弹多条消息用这个队列
public static Queue<string> multiNotifyContent;
public static RideSetting RideSetting = new RideSetting(); public static RideSetting RideSetting = new RideSetting();
public static string pageName { get; set; } public static string pageName { get; set; }
@ -229,6 +231,7 @@ public static class App
} }
//App.ChangeLanguage("en"); //App.ChangeLanguage("en");
globalMessageQueue = new Queue<LinkedMessageEvent>(); globalMessageQueue = new Queue<LinkedMessageEvent>();
multiNotifyContent = new Queue<string>();
Screen.sleepTimeout = SleepTimeout.NeverSleep; Screen.sleepTimeout = SleepTimeout.NeverSleep;
} }
} }

View File

@ -622,12 +622,21 @@ public class LoginController : BaseScene
//#endif //#endif
App.notifyContent = r.data.Value<string>("Content"); App.notifyContent = r.data.Value<string>("Content");
if (r.data.Value<int>("Id") != notifyId && r.data.Value<int>("Id") != 0)//r.data.Value<int>("Id") != notifyId if (r.data.Value<int>("Id") > 1)//r.data.Value<int>("Id") != notifyId
{ {
UIManager.ShowNewsModal(); UIManager.ShowNewsModal();
PlayerPrefs.SetInt("notifyId", r.data.Value<int>("Id")); PlayerPrefs.SetInt("notifyId", r.data.Value<int>("Id"));
} }
#else #else
if (r.data.Value<int>("Id") > 1)
{
App.notifyContent = r.data.Value<string>("Content");
UIManager.ShowNewsModal();
}
else
{
App.notifyContent = null;
}
var rr = await ConfigHelper.userApi.GetVersions(); var rr = await ConfigHelper.userApi.GetVersions();
if (rr.result) if (rr.result)
{ {
@ -643,18 +652,24 @@ public class LoginController : BaseScene
if (ver.UpdateLog.Count + 1 != notifyId) //ver.UpdateLog.Count != notifyId if (ver.UpdateLog.Count + 1 != notifyId) //ver.UpdateLog.Count != notifyId
{ {
var log = ver.UpdateLog.FirstOrDefault(); var log = ver.UpdateLog.FirstOrDefault();
if (log != null) if (App.notifyContent == null)
{ {
App.notifyContent = log.Desc; if (log != null)
{
App.notifyContent = log.Desc;
}
else
{
App.notifyContent = r.data.Value<string>("Content");
}
UIManager.ShowNewsModal();
} }
else else
{ {
App.notifyContent = r.data.Value<string>("Content"); App.multiNotifyContent.Enqueue(log != null ? log.Desc : r.data.Value<string>("Content"));
} }
PlayerPrefs.SetInt("notifyId", ver.UpdateLog.Count + 1); PlayerPrefs.SetInt("notifyId", ver.UpdateLog.Count + 1);
UIManager.ShowNewsModal();
} }
#endif #endif
} }
GetRotateImage(); GetRotateImage();

View File

@ -17,10 +17,19 @@ public class NewsController : PFUIPanel
UIManager.AddEvent(exit.gameObject, EventTriggerType.PointerClick, (b) => UIManager.AddEvent(exit.gameObject, EventTriggerType.PointerClick, (b) =>
{ {
Close(); Close();
if (App.multiNotifyContent.Count > 0)
{
transform.Find("Main").Find("Inner").Find("Content").GetComponent<Text>().text = App.multiNotifyContent.Dequeue();
Invoke("Open", 0.3f);
}
}); });
} }
Get(); Get();
} }
void Open()
{
gameObject.SetActive(true);
}
Transform content,exit; Transform content,exit;
void Get() void Get()
{ {

View File

@ -326,7 +326,7 @@ public class MapListController : PFUIPanel
mc.GetComponent<CanvasGroup>().alpha = 0; mc.GetComponent<CanvasGroup>().alpha = 0;
mc.GetComponent<CanvasGroup>().DOFade(1, 0.3f); mc.GetComponent<CanvasGroup>().DOFade(1, 0.3f);
#else #else
var topRect = topContainer; var topRect = transform.Find("Panel/Top/Container");
#endif #endif
if (isFocusSearch) if (isFocusSearch)
{ {

View File

@ -6,8 +6,8 @@ EditorBuildSettings:
serializedVersion: 2 serializedVersion: 2
m_Scenes: m_Scenes:
- enabled: 1 - enabled: 1
path: Assets/Scenes/Login-Mobile.unity path: Assets/Scenes/Login.unity
guid: 4be878da00cf764499988cf403faf94d guid: 6dce3e17997730b4492f91dd8fede429
- enabled: 1 - enabled: 1
path: Assets/Scenes/MainScene.unity path: Assets/Scenes/MainScene.unity
guid: ab586a3c1bacd4a48a55178eb06fe0cc guid: ab586a3c1bacd4a48a55178eb06fe0cc