QR-Scanner: Kamera-Fallbacks und Foto-Upload; weitere Aenderungen
This commit is contained in:
1 parent
7a0406eaa2
commit
e2aef67099
13 files changed
+965
-58
No files matched your search
@@ -32,6 +32,11 @@
|
||||
<div class="qr-status">QR-Code des Reports vor die Kamera halten</div>
|
||||
}
|
||||
|
||||
<div class="qr-manual">
|
||||
<label for="@_fileInputId" class="btn btn-secondary w-100">📷 Foto aufnehmen / Bild wählen</label>
|
||||
<input id="@_fileInputId" type="file" accept="image/*" capture="environment" style="display:none" @onchange="OnFileSelected" />
|
||||
</div>
|
||||
|
||||
<div class="qr-manual">
|
||||
<label for="qr-manual-input">Oder Link / Nummer einfügen</label>
|
||||
<div class="qr-manual-row">
|
||||
@@ -53,6 +58,7 @@
|
||||
[Parameter] public EventCallback<string> OnScanned { get; set; }
|
||||
|
||||
private readonly string _elementId = $"qr-reader-{Guid.NewGuid():N}";
|
||||
private readonly string _fileInputId = $"qr-file-{Guid.NewGuid():N}";
|
||||
private DotNetObjectReference<QrScannerModal>? _selfRef;
|
||||
private bool _scannerActive;
|
||||
private bool _wasOpen;
|
||||
@@ -127,6 +133,26 @@
|
||||
await OnScanned.InvokeAsync(text.Trim());
|
||||
}
|
||||
|
||||
private async Task OnFileSelected(ChangeEventArgs e)
|
||||
{
|
||||
cameraError = null;
|
||||
_scannerActive = false;
|
||||
try
|
||||
{
|
||||
var text = await JS.InvokeAsync<string?>("qrScanner.scanFile", _elementId, _fileInputId);
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
await OnQrScanned(text);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (JSException ex)
|
||||
{
|
||||
cameraError = ExtractMessage(ex.Message);
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task SubmitManual()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(manualText)) return;
|
||||
|
||||
Reference in new issue
Block a user