添加添加数据库服务器表

修改扫码连接修复扫码闪退问题
This commit is contained in:
sc authored and sc committed 2026-05-02 12:47:17 +08:00
1 parent 6c0af56ea9
commit 0801e4875c
64 files changed
+3265

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
using CommunityToolkit.Mvvm.Messaging;
using SunlightAggregationTerminal.View;
using ZXing.Multi;
using ZXing.Net.Maui;
using ZXing.QrCode.Internal;
namespace SunlightAggregationTerminal;
public partial class ScanPage : ContentPage
{
private int mode;
public ScanPage(int i)
{
InitializeComponent();
mode = i;
}
private async void OnBarcodesDetected(object sender, BarcodeDetectionEventArgs e)
{
var firstResult = e.Results?.FirstOrDefault();
if (firstResult is not null)
{
barcodeReader.IsDetecting = false;
// 触发回调
if (mode == 0)
{
MainThread.BeginInvokeOnMainThread(() =>
{
// 震动
try { Vibration.Default.Vibrate(TimeSpan.FromMilliseconds(100)); } catch { }
// 传入信息
WeakReferenceMessenger.Default.Send(firstResult.Value);
// 等待 1.5 秒(非阻塞,界面不会卡死)
Task.Delay(1500);
// 关闭页面
Navigation.PopAsync();
});
}
if (mode == 3)
{
MainThread.BeginInvokeOnMainThread(() =>
{
try { Vibration.Default.Vibrate(TimeSpan.FromMilliseconds(100)); } catch { }
WeakReferenceMessenger.Default.Send(firstResult.Value);
Task.Delay(1500);
// 关闭页面
Navigation.PopModalAsync();
});
}
}
}
}