fix(scanqr,homepagecharts): 修复并优化多处代码逻辑
1. 移除iOS端多余的对焦维护协程,简化相机对焦逻辑 2. 为首页图表初始化添加异常捕获,避免崩溃 3. 修复图表数据越界访问问题,修正switch分支缩进错误
This commit is contained in:
parent
432b80dfa3
commit
736fb1af04
@ -225,9 +225,8 @@ namespace Kill.UI.Pages
|
|||||||
|
|
||||||
#if UNITY_IOS && !UNITY_EDITOR
|
#if UNITY_IOS && !UNITY_EDITOR
|
||||||
// iOS: 通过原生插件开启连续自动对焦(autoFocusPoint 在 iOS 无效)
|
// iOS: 通过原生插件开启连续自动对焦(autoFocusPoint 在 iOS 无效)
|
||||||
|
// iOS 系统会自动维持对焦状态,无需周期触发
|
||||||
_EnableContinuousAutoFocus();
|
_EnableContinuousAutoFocus();
|
||||||
// 周期维护对焦:每 3s 触发一次点对焦(无黑屏),让镜头持续对焦
|
|
||||||
StartCoroutine(IOsFocusMaintainCoroutine());
|
|
||||||
#elif UNITY_ANDROID && !UNITY_EDITOR
|
#elif UNITY_ANDROID && !UNITY_EDITOR
|
||||||
// Android:WebCamTexture 默认不会自动对焦,需主动通过 Camera API 触发
|
// Android:WebCamTexture 默认不会自动对焦,需主动通过 Camera API 触发
|
||||||
EnableAndroidContinuousAutoFocus();
|
EnableAndroidContinuousAutoFocus();
|
||||||
@ -328,25 +327,6 @@ namespace Kill.UI.Pages
|
|||||||
Debug.Log($"[ScanQRcode] 预览调整 - 相机: {cameraWidth}x{cameraHeight}, 预览: {previewWidth}x{previewHeight}");
|
Debug.Log($"[ScanQRcode] 预览调整 - 相机: {cameraWidth}x{cameraHeight}, 预览: {previewWidth}x{previewHeight}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if UNITY_IOS && !UNITY_EDITOR
|
|
||||||
/// <summary>
|
|
||||||
/// iOS 对焦维护协程 — 每 3s 触发一次点对焦(无黑屏),让镜头持续重新对焦
|
|
||||||
/// 与 Android softTrigger 策略保持一致
|
|
||||||
/// </summary>
|
|
||||||
private IEnumerator IOsFocusMaintainCoroutine()
|
|
||||||
{
|
|
||||||
// 首次等待 3s 让初始对焦完成
|
|
||||||
yield return new WaitForSeconds(3f);
|
|
||||||
|
|
||||||
while (isScanning)
|
|
||||||
{
|
|
||||||
// 触发一次点对焦(无黑屏),1.5s 后原生会自动恢复连续对焦
|
|
||||||
_TriggerContinuousRefocus();
|
|
||||||
yield return new WaitForSeconds(3f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if UNITY_ANDROID && !UNITY_EDITOR
|
#if UNITY_ANDROID && !UNITY_EDITOR
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用 Android 自动对焦。
|
/// 启用 Android 自动对焦。
|
||||||
|
|||||||
@ -26,9 +26,19 @@ namespace Kill.UI.Pages
|
|||||||
public async Task Init()
|
public async Task Init()
|
||||||
{
|
{
|
||||||
LoadingUI.Show();
|
LoadingUI.Show();
|
||||||
await GetKillCount();
|
try
|
||||||
await GetKillRecords();
|
{
|
||||||
LoadingUI.Hide();
|
await GetKillCount();
|
||||||
|
await GetKillRecords();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.LogError($"[HomePageChartsCtrl] Init 异常: {e}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
LoadingUI.Hide();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public Text totalText;
|
public Text totalText;
|
||||||
|
|
||||||
@ -49,7 +59,7 @@ namespace Kill.UI.Pages
|
|||||||
List<int> daily = new List<int>();
|
List<int> daily = new List<int>();
|
||||||
for (int i = 0; i <24; i++)
|
for (int i = 0; i <24; i++)
|
||||||
{
|
{
|
||||||
if(data.data.stats.Count>0)
|
if(i < data.data.stats.Count)
|
||||||
daily.Add(data.data.stats[i].count);
|
daily.Add(data.data.stats[i].count);
|
||||||
else
|
else
|
||||||
daily.Add(0);
|
daily.Add(0);
|
||||||
@ -60,7 +70,7 @@ namespace Kill.UI.Pages
|
|||||||
List<int> weekly = new List<int>();
|
List<int> weekly = new List<int>();
|
||||||
for (int i = 0; i <7; i++)
|
for (int i = 0; i <7; i++)
|
||||||
{
|
{
|
||||||
if(data.data.stats.Count>0)
|
if(i < data.data.stats.Count)
|
||||||
weekly.Add(data.data.stats[i].count);
|
weekly.Add(data.data.stats[i].count);
|
||||||
else
|
else
|
||||||
weekly.Add(0);
|
weekly.Add(0);
|
||||||
@ -71,18 +81,18 @@ namespace Kill.UI.Pages
|
|||||||
List<int> monthly = new List<int>();
|
List<int> monthly = new List<int>();
|
||||||
for (int i = 0; i <31; i++)
|
for (int i = 0; i <31; i++)
|
||||||
{
|
{
|
||||||
if(data.data.stats.Count>0)
|
if(i < data.data.stats.Count)
|
||||||
monthly.Add(data.data.stats[i].count);
|
monthly.Add(data.data.stats[i].count);
|
||||||
else
|
else
|
||||||
monthly.Add(0);
|
monthly.Add(0);
|
||||||
}
|
}
|
||||||
barcharts[2].Init(monthly);
|
barcharts[2].Init(monthly);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
List<int> annual = new List<int>();
|
List<int> annual = new List<int>();
|
||||||
for (int i = 0; i <12; i++)
|
for (int i = 0; i <12; i++)
|
||||||
{
|
{
|
||||||
if(data.data.stats.Count>0)
|
if(i < data.data.stats.Count)
|
||||||
annual.Add(data.data.stats[i].count);
|
annual.Add(data.data.stats[i].count);
|
||||||
else
|
else
|
||||||
annual.Add(0);
|
annual.Add(0);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user