AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-19003861

PhilM's questions

Martin Hope
PhilM
Asked: 2025-02-27 23:04:53 +0800 CST

MAUI / .NET 8 - QR 码扫描仪(ZXing)无法检测代码

  • 6

我正在运行于 .NET 8 的 MAUI 应用程序中实现二维码扫描器。

该应用程序目前适用于Android,随后将移植到IOS。

因此,我决定使用ZXing.Net.Maui并遵循此处的文档:https://github.com/Redth/ZXing.Net.Maui#barcode-scanning

我的问题是,二维码仍然无法被检测到,并且BarcodesDetected()如果使用断点测试,也无法访问它。

我是否遗漏了什么?

我确实找到了这篇文章(ZXing for MAUI (MobileBarcodeScanner)),它似乎正在实施与我相同的过程,但我这边没有成功。

MauiProgram.cs

public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();

    builder
            .UseMauiApp<App>()
            )
            .UseMauiCommunityToolkit()
            .UseFFImageLoading()
            .UseBarcodeReader()

    var app = builder.Build();

    return app;
}

AndroidManifest.xaml:

<uses-permission android:name="android.permission.CAMERA"/>

View.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI.Controls"
             x:Class="Project.Views.View">
    <Grid>
        <zxing:CameraBarcodeReaderView
                x:Name="cameraBarcodeReaderView"
                BarcodesDetected="BarcodesDetected"
                IsDetecting="True"
                CameraLocation="Rear"
                IsEnabled="True"/>
    </Grid>
</ContentPage>

view.xaml.cs:

public partial class View : ContentPage
{
    public View()
    {
        InitializeComponent();
        CheckCameraPermission();

        cameraBarcodeReaderView.Options = new BarcodeReaderOptions
        {
            Formats = BarcodeFormats.OneDimensional,
            AutoRotate = true,
            Multiple = true
        };
    }

    private void BarcodesDetected(object sender, BarcodeDetectionEventArgs e)
    {
        foreach (var barcode in e.Results)
            Console.WriteLine($"Barcodes: {barcode.Format} -> {barcode.Value}");
    }
}
c#
  • 1 个回答
  • 34 Views
Martin Hope
PhilM
Asked: 2025-01-17 21:18:20 +0800 CST

MAUI - 类型或命名空间名称“平台”在命名空间中不存在

  • 6

尝试将我的导航栏移动到 MAUI 屏幕底部,但这并不像我想象的那么简单。

我正在按照这篇文章的解决方案:这里

然而,我得到了The type or namespace name 'Platforms' does not exist in the namespace 'Project' (are you missing an assembly reference?)。

此错误与此行有关 handlers.AddHandler<Shell, ShellHandler>();

我发现了几个有同样问题的帖子,但似乎没有一个提供解决方案。

有什么建议吗?

应用程序.xaml.cs

using Project._ViewModels.SharedViewModel;
using Microsoft.Maui.Hosting;
using Microsoft.Maui.Controls.Hosting;
using CommunityToolkit.Maui;
using Project.Helpers;
using Project.Platforms; ///this is where the error is


namespace Project
{
    /// <summary>
    /// Represents the main application class.
    /// </summary>
    public partial class App : Application
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="App"/> class.
        /// </summary>
        public App()
        {
            InitializeComponent();
            MainPage = new AppShell();
        }

        public static MauiApp CreateMauiApp()
        {
            var builder = MauiApp.CreateBuilder();
            builder
                 .UseMauiApp<App>()
                 .UseMauiCommunityToolkit()
                 .ConfigureMauiHandlers(handlers =>
                 {
                     handlers.AddHandler<Shell, ShellHandler>();                      });

            return builder.Build();
        }
    }
}

ShellHandler.cs(路径:Project\Platforms\Android\ShellHandler.cs)

using Android.Content;
using AndroidX.CoordinatorLayout.Widget;
using Google.Android.Material.BottomNavigation;
using Microsoft.Maui.Controls.Handlers.Compatibility;
using Microsoft.Maui.Controls.Platform.Compatibility;
using Microsoft.Maui.Controls.PlatformConfiguration.AndroidSpecific;
using Svg;
using System;

namespace Project.Platforms.Android
{
    public partial class ShellHandler : ShellRenderer
    {
        public ShellHandler(Context context) : base(context) { }

        protected override IShellBottomNavViewAppearanceTracker CreateBottomNavViewAppearanceTracker(Microsoft.Maui.Controls.ShellItem shellItem)
        {
            return new ShellBottomNavViewAppearanceTracker(this, shellItem.CurrentItem);
        }

        public class ShellBottomNavViewAppearanceTrackerEx : ShellBottomNavViewAppearanceTracker
        {
            public ShellBottomNavViewAppearanceTrackerEx(IShellContext shellContext, Microsoft.Maui.Controls.ShellItem shellItem)
                : base(shellContext, shellItem) { }

            public override void SetAppearance(BottomNavigationView bottomView, IShellAppearanceElement appearance)
            {
                base.SetAppearance(bottomView, appearance);

            }
        }
    }
}
c#
  • 1 个回答
  • 48 Views
Martin Hope
PhilM
Asked: 2024-12-06 06:59:44 +0800 CST

Django/Stripe-未找到 Webhook

  • 5

我正在尝试建立一个带有条纹的 webhook。(第一次)

但是,似乎没有找到 webhook 的路径。

希望有人能用全新的视角告诉我我做错了什么。

在我的 urls.py 中(项目级别)

urlpatterns = [

    path('my_app/', include('my_app.urls')),
    ...
]

在 urls.py 应用程序级别:

urlpatterns = [
    ..
    path('stripe_webhook/', views.stripe_webhook, name='stripe_webhook')
]

在我的views.py(my_app级别)中:

@csrf_exempt
def stripe_webhook(request):
    print("enter webhook")
    stripe.api_key = settings.STRIPE_SECRET_KEY_TEST
   
    payload = request.body
    signature_header = request.META.get('HTTP_STRIPE_SIGNATURE')
    webhook_secret = settings.STRIPE_WEBHOOK_SECRET_TEST
    ...

在条纹中,在本地听众中我已经注册:

localhost:8000/stripe_webhook/

如果我运行stripe trigger customer.created. 我会得到以下返回结果:

A newer version of the Stripe CLI is available, please update to: v1.22.0
Setting up fixture for: customer
Running fixture for: customer
Trigger succeeded! Check dashboard for event details.

但是,同时运行时stripe listen --forward-to localhost:8000/stripe_webhook/,我还收到以下日志:

> Ready! You are using Stripe API Version [2024-09-30.acacia]. Your webhook signing secret is XXXXX (^C to quit)
2024-12-05 22:27:54   --> customer.created [xxx]
2024-12-05 22:27:54  <--  [404] POST http://localhost:8000/stripe_webhook/ [xx]

并且我的服务器日志也会返回(无论是在生产中还是本地)Not Found: /stripe_webhook/:。

这让我认为我的 webhook 路径配置不正确,但我看不到任何可能遗漏的内容。我是否忘记了 Stripe 平台上的某些内容?

注意:我的 .env 文件中的所有键(STRIPE_PUBLIC_KEY_TEST、STRIPE_SECRET_KEY_TEST和STRIPE_WEBHOOK_SECRET_TEST)都与 Stripe 平台上提供的键匹配。

有什么想法吗?

django
  • 1 个回答
  • 23 Views
Martin Hope
PhilM
Asked: 2024-06-10 18:36:59 +0800 CST

Android Studio 上缺少面板(水平在父级中)

  • 5

正在学习 Android 课程。我不确定我是否错过了扩展,但我无法访问下面的面板。

特别是我希望访问“Horizo​​ntally in Parent”按钮。

你知道如何在面板上显示它吗?

我当前的面板 在此处输入图片描述

所需面板 在此处输入图片描述

android-studio
  • 1 个回答
  • 12 Views
Martin Hope
PhilM
Asked: 2024-04-20 00:43:50 +0800 CST

从子元素访问父div

  • 5

我有 2 个单选按钮。每个单选按钮都连接到一个图像。一开始这些图像是黑白的 ( filter:grayscale(1))。当选择这些按钮之一时,我希望与该按钮相关的图像变为 ( filter:grayscale(0))。过滤grayscale器属性在元素中指定<img>。每个单选按钮都包装在一个单独的 div 中,并带有各自的<img>.

第一步(我认为)是收集与所选单选按钮相关的输入名称。这有效。我相信从这个输入名称中,我需要搜索父 div,然后查找<img>与其相关的元素。

我承认,写这篇文章感觉有点复杂。但我想不出更好的办法。

我的问题

我现在挣扎的地方是根据检查的输入名称获取父 div。我找到了一些使用任一文档.parentElement(),.parent()但parent.Node()这些都不起作用。或者可能是我没有正确使用它们。然后,一旦确定了父 div,我就可以查找子<img>元素了。

我的问题

  1. 如何从子元素 id 访问父 div?
  2. 有没有更好的方法/更简单的方法来实现这一目标?

$(document).ready(function() {
  /*Manages Radio buttons & images rendering when clicked*/
  $('input[name="hero-avatar"]').change(function() {
    // Check if the radio button is checked
    if ($(this).is(':checked')) {
      // captures id of button that is checked
      let checkButton = $(this).attr('id');
      // Log checked radio button id
      console.log(checkButton);

      //test to find parent div class
      console.log($(`#${checkButton}`).parent().attr('class'));

      //this works but doesnt reach the parent div class which contains grayscale property
      $(`#${checkButton}`.parentNode).css('filter', 'grayscale(0)')

    }
  });

  //if radio button is checked
  //change colour of image attached to it
});
.avatar-img-select {
  height: 52px;
  filter: grayscale(1);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
<div class="row first-screen-row-avatar">
  <div class="col select-avatar-col">
    <label for="avatar1">
        <img src="assets/images/avatars/hero-avatar-1.jpg" class="avatar-img-select" alt="Avatar 1">
        <input type="radio" id="avatar1" name="hero-avatar" value="assets/images/avatars/hero-avatar-1.jpg" required>
    </label>
  </div>
  <div class="col select-avatar-col">
    <label for="avatar2">
        <img src="assets/images/avatars/hero-avatar-2.webp" class="avatar-img-select" alt="Avatar 2">
        <input type="radio" id="avatar2" name="hero-avatar" value="assets/images/avatars/hero-avatar-2.webp" required>
    </label>
  </div>
</div>

javascript
  • 1 个回答
  • 36 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve