From 8f2d4e07ee7b0bfec58c5823c8c86a7cf7dc1d56 Mon Sep 17 00:00:00 2001 From: oh_ci Date: Tue, 2 Sep 2025 07:49:46 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!70787?= =?UTF-8?q?=20:=20=E5=AE=89=E5=85=A8=E5=91=8A=E8=AD=A6=E5=A4=84=E7=90=86'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../declarative_frontend/jsview/js_gauge.cpp | 15 +++------------ .../declarative_frontend/jsview/js_progress.cpp | 10 +++------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/frameworks/bridge/declarative_frontend/jsview/js_gauge.cpp b/frameworks/bridge/declarative_frontend/jsview/js_gauge.cpp index 8b39c96f8d7..5b58c0cfa46 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_gauge.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_gauge.cpp @@ -164,14 +164,8 @@ void JSGauge::SetColors(const JSCallbackInfo& info) return; } JSRef tempColors = jsColor->GetValueAt(i); - double value = 0.0; - if (tempColors->GetValueAt(1)->IsNumber()) { - value = tempColors->GetValueAt(1)->ToNumber(); - } - float weight = 0.0; - if (tempColors->GetValueAt(1)->IsNumber()) { - weight = tempColors->GetValueAt(1)->ToNumber(); - } + double value = tempColors->GetValueAt(1)->ToNumber(); + float weight = tempColors->GetValueAt(1)->ToNumber(); Color selectedColor; if (!ParseJsColor(tempColors->GetValueAt(0), selectedColor)) { selectedColor = ERROR_COLOR; @@ -227,10 +221,7 @@ void JSGauge::SetGradientColors(const JSCallbackInfo& info) } auto tempColors = JSRef::Cast(jsValue); // Get weight - float weight = 0.0; - if (tempColors->GetValueAt(1)->IsNumber()) { - weight = tempColors->GetValueAt(1)->ToNumber(); - } + float weight = tempColors->GetValueAt(1)->ToNumber(); if (NonPositive(weight)) { continue; } diff --git a/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp b/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp index c1fe63adccc..bc1ce10db85 100644 --- a/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp +++ b/frameworks/bridge/declarative_frontend/jsview/js_progress.cpp @@ -79,10 +79,7 @@ void JSProgress::Create(const JSCallbackInfo& info) jsStyle = paramObject->GetProperty("style"); } - auto progressStyle = ProgressStyle::Ring; - if (jsStyle->IsNumber()) { - progressStyle = static_cast(jsStyle->ToNumber()); - } + auto progressStyle = static_cast(jsStyle->ToNumber()); if (progressStyle == ProgressStyle::Eclipse) { g_progressType = ProgressType::MOON; } else if (progressStyle == ProgressStyle::Ring) { @@ -213,7 +210,7 @@ void JSProgress::JsSetProgressStyleOptions(const JSCallbackInfo& info) RefPtr strokeWidthResObj; auto jsStrokeWidth = paramObject->GetProperty(attrsProgressStrokeWidth); if (!CheckLength( - jsStrokeWidth, strokeWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressStrokeWidth, strokeWidthResObj)) { + jsStrokeWidth, strokeWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressStrokeWidth, strokeWidthResObj)) { strokeWidthDimension = theme->GetTrackThickness(); } @@ -237,8 +234,7 @@ void JSProgress::JsSetProgressStyleOptions(const JSCallbackInfo& info) CalcDimension scaleWidthDimension; RefPtr scaleWidthResObj; auto jsScaleWidth = paramObject->GetProperty(attrsProgressScaleWidth); - if (!CheckLength( - jsScaleWidth, scaleWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressScaleWidth, scaleWidthResObj)) { + if (!CheckLength(jsScaleWidth, scaleWidthDimension, V2::PROGRESS_ETS_TAG, attrsProgressScaleWidth, scaleWidthResObj)) { scaleWidthDimension = theme->GetScaleWidth(); } -- Gitee