From 1a789fcbc6da97b8b751dc974f413e599e78e03c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B0=B8=E5=87=AF?= Date: Wed, 25 Jun 2025 16:47:58 +0800 Subject: [PATCH] =?UTF-8?q?swiperinterval=E8=B4=9F=E6=95=B0=E6=97=A0?= =?UTF-8?q?=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 刘永凯 --- .../native/implementation/swiper_modifier.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frameworks/core/interfaces/native/implementation/swiper_modifier.cpp b/frameworks/core/interfaces/native/implementation/swiper_modifier.cpp index cef161e635e..2867607593d 100644 --- a/frameworks/core/interfaces/native/implementation/swiper_modifier.cpp +++ b/frameworks/core/interfaces/native/implementation/swiper_modifier.cpp @@ -29,7 +29,6 @@ namespace OHOS::Ace::NG { using ArrowStyleVariantType = std::variant; using DisplayCountVariantType = std::variant; -const static int32_t DEFAULT_INTERVAL = 3000; const static int32_t DEFAULT_DURATION = 400; const static int32_t DEFAULT_DISPLAY_COUNT = 1; const static int32_t DEFAULT_CACHED_COUNT = 1; @@ -248,6 +247,10 @@ void CheckSwiperDigitalParameters(SwiperDigitalParameters& p) using namespace OHOS::Ace::NG::SwiperAttributeModifierInternal; namespace OHOS::Ace::NG::GeneratedModifier { +constexpr uint32_t DEFAULT_INTERVAL_VALUE = 3000; +constexpr int32_t INVALID_VALUE = 0; +constexpr int32_t DEFAULT_VALUE = 6; + namespace SwiperModifier { Ark_NativePointer ConstructImpl(Ark_Int32 id, Ark_Int32 flags) @@ -328,12 +331,17 @@ void IntervalImpl(Ark_NativePointer node, { auto frameNode = reinterpret_cast(node); CHECK_NULL_VOID(frameNode); - auto convValue = Converter::OptConvert(*value); - if (!convValue) { - SwiperModelStatic::SetAutoPlayInterval(frameNode, DEFAULT_INTERVAL); + CHECK_NULL_VOID(value); + if (value->tag == InteropTag::INTEROP_TAG_UNDEFINED) { + SwiperModelStatic::SetAutoPlayInterval(frameNode, DEFAULT_INTERVAL_VALUE); + return; + } + auto convValue = Converter::Convert(value->value); + if (convValue < INVALID_VALUE) { + SwiperModelStatic::SetAutoPlayInterval(frameNode, DEFAULT_INTERVAL_VALUE); return; } - SwiperModelStatic::SetAutoPlayInterval(frameNode, *convValue); + SwiperModelStatic::SetAutoPlayInterval(frameNode, convValue); } namespace { void SetIndicator(FrameNode* frameNode, const Ark_DigitIndicator& src) -- Gitee