From 3329762d93d1183047095574a5d688974ed4335e Mon Sep 17 00:00:00 2001 From: songchenglin3 <353833373@qq.com> Date: Mon, 8 Jun 2026 16:00:43 +0800 Subject: [PATCH 1/5] =?UTF-8?q?fix:=20=E7=A7=BB=E9=99=A4jmfe=E6=A1=A5?= =?UTF-8?q?=E6=8E=A5=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/scale-f.ts | 67 ++++++-------------------------------------- 1 file changed, 8 insertions(+), 59 deletions(-) diff --git a/src/utils/scale-f.ts b/src/utils/scale-f.ts index c05cfc4ee6..cd5ded36df 100644 --- a/src/utils/scale-f.ts +++ b/src/utils/scale-f.ts @@ -1,36 +1,11 @@ /** - * 响应式缩放系数(--nut-scale-f):结合京东站内原生桥与站外视口规则, + * 响应式缩放系数(--nut-scale-f):按视口宽度计算, * 写入根节点 CSS 变量(--nut-scale-f / --nut-scale-font / --nut-scale-icon), * 供布局/字号/icon 等按比例换算(见 calcByProfile)。H5 与 Taro WebView 共用此实现。 */ import { canUseDom } from './can-use-dom' -/** 原生 DongScreenAdapterPlugin.getScale 的典型返回结构 */ -type NativeScaleResponse = { - status?: string - data?: { - scale?: number | string - } -} - -/** jmfe 通用 callNative 签名 */ -type NativeCaller = ( - plugin: string, - method: string, - params: string, - extra: string -) => Promise - -/** 站内容器的 jmfe 桥接方法(可选) */ -declare global { - interface Window { - jmfe?: { - callNative?: NativeCaller - } - } -} - -/** 当前基准缩放(来自原生或视口计算) */ +/** 当前基准缩放(来自视口计算) */ let scale = 1 /** 字体档位:标准、大字、老年 */ @@ -113,7 +88,7 @@ function roundByScaleRule( return Math.round(value) } -/** 无原生桥时按屏宽推算 scale(含平板与 375 基准窄屏区间) */ +/** 按屏宽推算 scale(含平板与 375 基准窄屏区间) */ function getScaleByViewport() { if (!canUseDom) return 1 const deviceWidth = window.innerWidth @@ -132,34 +107,8 @@ function getScaleByViewport() { return 1 } -/** 通过 jmfe.callNative 拉取 DongScreenAdapterPlugin;失败返回 null */ -async function getScaleByNative() { - if (!canUseDom || !window.jmfe?.callNative) return null - - try { - const res = await window.jmfe.callNative( - 'DongScreenAdapterPlugin', - 'getScale', - JSON.stringify({}), - '' - ) - if (res?.status === '0' && res.data?.scale !== undefined) { - const parsed = Number(res.data.scale) - if (Number.isFinite(parsed) && parsed > 0) { - return parsed - } - } - } catch { - /* 原生异常时由 getScaleF 回退到视口规则 */ - } - - return null -} - -/** 统一获取缩放:站内原生优先,失败则用视口规则 */ -async function getScaleF() { - const nativeScale = await getScaleByNative() - if (nativeScale) return nativeScale +/** 统一获取缩放:按视口规则计算 */ +function getScaleF() { return getScaleByViewport() } @@ -171,12 +120,12 @@ function setScaleF(nextScale: number) { return scale } -/** 重新拉取缩放;可选同时切换 profile,避免与当前值相同时重复写 DOM */ -async function refreshScaleF(nextProfile?: ScaleProfile) { +/** 重新计算缩放;可选同时切换 profile,避免与当前值相同时重复写 DOM */ +function refreshScaleF(nextProfile?: ScaleProfile) { if (nextProfile) { setScaleProfile(nextProfile) } - const nextScale = await getScaleF() + const nextScale = getScaleF() if (!scale || nextScale !== scale) { setScaleF(nextScale) } From da24c2c04b53a61ffc9be4324eea53ea55ef03e2 Mon Sep 17 00:00:00 2001 From: songchenglin3 <353833373@qq.com> Date: Thu, 11 Jun 2026 20:40:10 +0800 Subject: [PATCH 2/5] =?UTF-8?q?feat(switch):=20=E9=80=82=E9=85=8D=20v16?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/switch/doc.en-US.md | 17 +++++++++-------- src/packages/switch/doc.md | 17 +++++++++-------- src/packages/switch/doc.taro.md | 17 +++++++++-------- src/packages/switch/doc.zh-TW.md | 17 +++++++++-------- src/packages/switch/switch.scss | 28 ++++++++++++++-------------- src/styles/theme-dark.scss | 2 +- src/styles/theme-default.scss | 2 +- src/styles/variables.scss | 31 +++++++++++-------------------- 8 files changed, 63 insertions(+), 68 deletions(-) diff --git a/src/packages/switch/doc.en-US.md b/src/packages/switch/doc.en-US.md index 3495efdb10..cb66e27fa0 100644 --- a/src/packages/switch/doc.en-US.md +++ b/src/packages/switch/doc.en-US.md @@ -101,17 +101,18 @@ The component provides the following CSS variables, which can be used to customi | \--nutui-switch-active-background-color | Switch on status background color | `$color-primary` | | \--nutui-switch-inactive-background-color | Switch off status background color | `$color-text-disabled` | | \--nutui-switch-active-disabled-background-color | Switch toggle on the background color disabled | `$color-primary-disabled-special` | -| \--nutui-switch-inactive-disabled-background-color | Turn off the background color disabled | `$color-background` | -| \--nutui-switch-inactive-line-bg-color | Switch Off Internal Button Line Color | `#ffffff` | -| \--nutui-switch-width | Switch Width | `46px` | -| \--nutui-switch-height | Switch height | `28px` | -| \--nutui-switch-line-height | Switch line height | `28px` | +| \--nutui-switch-inactive-disabled-background-color | Turn off the background color disabled | `var(--nutui-color-background-component)` | +| \--nutui-switch-inactive-line-background-color | Switch Off Internal Button Line Color | `$color-primary-text` | +| \--nutui-switch-width | Switch Width | `56px` | +| \--nutui-switch-height | Switch height | `24px` | +| \--nutui-switch-inside-width | Switch internal button width | `32px` | +| \--nutui-switch-inside-height | Switch internal button height | `20px` | | \--nutui-switch-border-radius | Switch rounded corner size | `$radius-circle` | | \--nutui-switch-border-width | Switch border width | `2px` | -| \--nutui-switch-inside-border-radius | Switch internal button rounded corner size | `$radius-full` | -| \--nutui-switch-inside-box-shadow | Switch Internal Button Shadow | `0px 2px 6px 0px rgba(0, 0, 0, 0.4)` | +| \--nutui-switch-inside-border-radius | Switch internal button rounded corner size | `$radius-circle` | +| \--nutui-switch-inside-box-shadow | Switch Internal Button Shadow | `0px 4px 8px 0px rgba(0, 0, 0, 0.12)` | | \--nutui-switch-label-text-color | Switch internal text color | `$color-primary-text` | -| \--nutui-switch-label-font-size | Switch internal text size | `$font-size-s` | +| \--nutui-switch-label-font-size | Switch internal text size | `$font-size-xs` | | \--nutui-switch-inactive-disabled-label-text-color | Turn off and disable internal text color | `$color-text-disabled` | diff --git a/src/packages/switch/doc.md b/src/packages/switch/doc.md index 3a9e7b2afc..5bb44a9b91 100644 --- a/src/packages/switch/doc.md +++ b/src/packages/switch/doc.md @@ -101,17 +101,18 @@ import { Switch } from '@nutui/nutui-react' | \--nutui-switch-active-background-color | 开关打开状态背景颜色 | `$color-primary` | | \--nutui-switch-inactive-background-color | 开关关闭状态背景颜色 | `$color-text-disabled` | | \--nutui-switch-active-disabled-background-color | 开关打开状态禁用的背景颜色 | `$color-primary-disabled-special` | -| \--nutui-switch-inactive-disabled-background-color | 开关关闭状态禁用的背景颜色 | `$color-background` | -| \--nutui-switch-inactive-line-bg-color | 开关关闭状态内部按钮线条颜色 | `#ffffff` | -| \--nutui-switch-width | 开关宽度 | `46px` | -| \--nutui-switch-height | 开关高度 | `28px` | -| \--nutui-switch-line-height | 开关行高 | `28px` | +| \--nutui-switch-inactive-disabled-background-color | 开关关闭状态禁用的背景颜色 | `var(--nutui-color-background-component)` | +| \--nutui-switch-inactive-line-background-color | 开关关闭状态内部按钮线条颜色 | `$color-primary-text` | +| \--nutui-switch-width | 开关宽度 | `56px` | +| \--nutui-switch-height | 开关高度 | `24px` | +| \--nutui-switch-inside-width | 开关内部按钮宽度 | `32px` | +| \--nutui-switch-inside-height | 开关内部按钮高度 | `20px` | | \--nutui-switch-border-radius | 开关圆角大小 | `$radius-circle` | | \--nutui-switch-border-width | 开关边框宽度 | `2px` | -| \--nutui-switch-inside-border-radius | 开关内部按钮圆角大小 | `$radius-full` | -| \--nutui-switch-inside-box-shadow | 开关内部按钮阴影 | `0px 2px 6px 0px rgba(0, 0, 0, 0.4)` | +| \--nutui-switch-inside-border-radius | 开关内部按钮圆角大小 | `$radius-circle` | +| \--nutui-switch-inside-box-shadow | 开关内部按钮阴影 | `0px 4px 8px 0px rgba(0, 0, 0, 0.12)` | | \--nutui-switch-label-text-color | 开关内部文字颜色 | `$color-primary-text` | -| \--nutui-switch-label-font-size | 开关内部文字大小 | `$font-size-s` | +| \--nutui-switch-label-font-size | 开关内部文字大小 | `$font-size-xs` | | \--nutui-switch-inactive-disabled-label-text-color | 开关关闭禁用内部文字颜色 | `$color-text-disabled` | diff --git a/src/packages/switch/doc.taro.md b/src/packages/switch/doc.taro.md index c11f5a5581..2a701b6bc9 100644 --- a/src/packages/switch/doc.taro.md +++ b/src/packages/switch/doc.taro.md @@ -101,17 +101,18 @@ import { Switch } from '@nutui/nutui-react-taro' | \--nutui-switch-active-background-color | 开关打开状态背景颜色 | `$color-primary` | | \--nutui-switch-inactive-background-color | 开关关闭状态背景颜色 | `$color-text-disabled` | | \--nutui-switch-active-disabled-background-color | 开关打开状态禁用的背景颜色 | `$color-primary-disabled-special` | -| \--nutui-switch-inactive-disabled-background-color | 开关关闭状态禁用的背景颜色 | `$color-background` | -| \--nutui-switch-inactive-line-bg-color | 开关关闭状态内部按钮线条颜色 | `#ffffff` | -| \--nutui-switch-width | 开关宽度 | `46px` | -| \--nutui-switch-height | 开关高度 | `28px` | -| \--nutui-switch-line-height | 开关行高 | `28px` | +| \--nutui-switch-inactive-disabled-background-color | 开关关闭状态禁用的背景颜色 | `var(--nutui-color-background-component)` | +| \--nutui-switch-inactive-line-background-color | 开关关闭状态内部按钮线条颜色 | `$color-primary-text` | +| \--nutui-switch-width | 开关宽度 | `56px` | +| \--nutui-switch-height | 开关高度 | `24px` | +| \--nutui-switch-inside-width | 开关内部按钮宽度 | `32px` | +| \--nutui-switch-inside-height | 开关内部按钮高度 | `20px` | | \--nutui-switch-border-radius | 开关圆角大小 | `$radius-circle` | | \--nutui-switch-border-width | 开关边框宽度 | `2px` | -| \--nutui-switch-inside-border-radius | 开关内部按钮圆角大小 | `$radius-full` | -| \--nutui-switch-inside-box-shadow | 开关内部按钮阴影 | `0px 2px 6px 0px rgba(0, 0, 0, 0.4)` | +| \--nutui-switch-inside-border-radius | 开关内部按钮圆角大小 | `$radius-circle` | +| \--nutui-switch-inside-box-shadow | 开关内部按钮阴影 | `0px 4px 8px 0px rgba(0, 0, 0, 0.12)` | | \--nutui-switch-label-text-color | 开关内部文字颜色 | `$color-primary-text` | -| \--nutui-switch-label-font-size | 开关内部文字大小 | `$font-size-s` | +| \--nutui-switch-label-font-size | 开关内部文字大小 | `$font-size-xs` | | \--nutui-switch-inactive-disabled-label-text-color | 开关关闭禁用内部文字颜色 | `$color-text-disabled` | diff --git a/src/packages/switch/doc.zh-TW.md b/src/packages/switch/doc.zh-TW.md index e392e58924..0ef7446960 100644 --- a/src/packages/switch/doc.zh-TW.md +++ b/src/packages/switch/doc.zh-TW.md @@ -101,17 +101,18 @@ import { Switch } from '@nutui/nutui-react' | \--nutui-switch-active-background-color | 開關打開狀態背景顏色 | `$color-primary` | | \--nutui-switch-inactive-background-color | 開關關閉狀態背景顏色 | `$color-text-disabled` | | \--nutui-switch-active-disabled-background-color | 開關打開狀態禁用的背景顏色 | `$color-primary-disabled-special` | -| \--nutui-switch-inactive-disabled-background-color | 開關關閉狀態禁用的背景顏色 | `$color-background` | -| \--nutui-switch-inactive-line-bg-color | 開關關閉狀態內部按鈕線條顏色 | `#ffffff` | -| \--nutui-switch-width | 開關寬度 | `46px` | -| \--nutui-switch-height | 開關高度 | `28px` | -| \--nutui-switch-line-height | 開關行高 | `28px` | +| \--nutui-switch-inactive-disabled-background-color | 開關關閉狀態禁用的背景顏色 | `var(--nutui-color-background-component)` | +| \--nutui-switch-inactive-line-background-color | 開關關閉狀態內部按鈕線條顏色 | `$color-primary-text` | +| \--nutui-switch-width | 開關寬度 | `56px` | +| \--nutui-switch-height | 開關高度 | `24px` | +| \--nutui-switch-inside-width | 開關內部按鈕寬度 | `32px` | +| \--nutui-switch-inside-height | 開關內部按鈕高度 | `20px` | | \--nutui-switch-border-radius | 開關圓角大小 | `$radius-circle` | | \--nutui-switch-border-width | 開關邊框寬度 | `2px` | -| \--nutui-switch-inside-border-radius | 開關內部按鈕圓角大小 | `$radius-full` | -| \--nutui-switch-inside-box-shadow | 開關內部按鈕陰影 | `0px 2px 6px 0px rgba(0, 0, 0, 0.4)` | +| \--nutui-switch-inside-border-radius | 開關內部按鈕圓角大小 | `$radius-circle` | +| \--nutui-switch-inside-box-shadow | 開關內部按鈕陰影 | `0px 4px 8px 0px rgba(0, 0, 0, 0.12)` | | \--nutui-switch-label-text-color | 開關內部文字顏色 | `$color-primary-text` | -| \--nutui-switch-label-font-size | 開關內部文字大小 | `$font-size-s` | +| \--nutui-switch-label-font-size | 開關內部文字大小 | `$font-size-xs` | | \--nutui-switch-inactive-disabled-label-text-color | 開關關閉禁用內部文字顏色 | `$color-text-disabled` | diff --git a/src/packages/switch/switch.scss b/src/packages/switch/switch.scss index 089f6688ca..885f5a00d9 100644 --- a/src/packages/switch/switch.scss +++ b/src/packages/switch/switch.scss @@ -11,7 +11,6 @@ align-items: center; min-width: $switch-width; height: $switch-height; - line-height: $switch-line-height; background-color: $switch-active-background-color; border-radius: $switch-border-radius; background-size: 100% 100%; @@ -27,14 +26,14 @@ flex-direction: row; align-items: center; justify-content: center; - height: calc($switch-height - $switch-border-width * 2); - width: calc($switch-height - $switch-border-width * 2); + height: $switch-inside-height; + width: $switch-inside-width; border-radius: $switch-inside-border-radius; background: $color-primary-text; transition: left 0.3s linear; box-shadow: $switch-inside-box-shadow; &-open { - left: calc(100% - $switch-height + $switch-border-width); + left: calc(100% - $switch-inside-width - $switch-border-width); &-rtl { left: $switch-border-width; } @@ -42,14 +41,9 @@ &-close { left: $switch-border-width; &-rtl { - left: calc(100% - $switch-height + $switch-border-width); + left: calc(100% - $switch-inside-width - $switch-border-width); } } - .nut-icon { - width: calc(($switch-height - $switch-border-width * 2) / 2); - height: calc(($switch-height - $switch-border-width * 2) / 2); - color: $switch-active-disabled-background-color; - } } &-close { @@ -62,6 +56,12 @@ } } + .nut-icon { + width: calc($switch-height / 2); + height: calc($switch-height / 2); + color: $switch-active-disabled-background-color; + } + &-label { /* #ifdef dynamic*/ display: flex; @@ -78,16 +78,16 @@ color: $switch-label-text-color; } &-open { - margin: 0 calc($switch-height - $switch-border-width + 3px) 0 7px; + margin: 0 calc($switch-inside-width + $switch-border-width + 3px) 0 7px; &-rtl { - margin: 0 7px 0 calc($switch-height - $switch-border-width + 3px); + margin: 0 7px 0 calc($switch-inside-width + $switch-border-width + 3px); } } &-close { - margin: 0 7px 0 calc($switch-height - $switch-border-width + 3px); + margin: 0 7px 0 calc($switch-inside-width + $switch-border-width + 3px); &-rtl { - margin: 0 calc($switch-height - $switch-border-width + 3px) 0 7px; + margin: 0 calc($switch-inside-width + $switch-border-width + 3px) 0 7px; } } diff --git a/src/styles/theme-dark.scss b/src/styles/theme-dark.scss index 8e0d9928e2..21e8b5a315 100644 --- a/src/styles/theme-dark.scss +++ b/src/styles/theme-dark.scss @@ -133,7 +133,7 @@ page, // 品牌渐变色右端 --nutui-color-primary-stop-2: var(--nutui-brand-stop-2); // 品牌主色调或其他深色背景下的文字 - --nutui-color-primary-text: var(--nutui-gray-1); + --nutui-color-primary-text: var(--nutui-white-13); // 品牌主色调点击态,背景、边框、镂空状态下的文字 --nutui-color-primary-pressed: var(--nutui-red-7); // 品牌主色调禁用态,背景、边框、镂空状态下的文字 diff --git a/src/styles/theme-default.scss b/src/styles/theme-default.scss index 4445e08a24..f3d86d9ef4 100644 --- a/src/styles/theme-default.scss +++ b/src/styles/theme-default.scss @@ -132,7 +132,7 @@ page { // 品牌渐变色右端 --nutui-color-primary-stop-2: var(--nutui-brand-stop-2); // TODO 删掉 // 品牌主色调或其他深色背景下的文字 - --nutui-color-primary-text: var(--nutui-gray-1);// TODO white + --nutui-color-primary-text: var(--nutui-white-13); // 品牌主色调点击态,背景、边框、镂空状态下的文字 --nutui-color-primary-pressed: var(--nutui-red-7); // 品牌主色调禁用态,背景、边框、镂空状态下的文字 diff --git a/src/styles/variables.scss b/src/styles/variables.scss index dcb34659c2..49359af1f8 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -151,7 +151,7 @@ $color-border-disabled: var(--nutui-color-border-disabled, #c2c4cc) !default; $color-title: var(--nutui-color-title, #1a1a1a) !default; $color-text: var(--nutui-color-text, #505259) !default; $color-text-help: var(--nutui-color-text-help, #888b94) !default; -$color-text-disabled: var(--nutui-color-text-disabled, #c2c4cc) !default; +$color-text-disabled: var(--nutui-color-text-disabled, #b4b8bf) !default; $color-text-dark: var( --nutui-color-text-dark, rgba(255, 255, 255, 0.9) @@ -159,7 +159,7 @@ $color-text-dark: var( $color-text-link: var(--nutui-color-text-link, #0c82f7) !default; // 与品牌色一起使用,默认为白色,不区分暗黑与明亮模式。 -$color-primary-text: #ffffff !default; +$color-primary-text: var(--nutui-color-primary-text, #ffffff) !default; $white: #ffffff !default; $black: #000000 !default; @@ -1040,15 +1040,16 @@ $switch-active-disabled-background-color: var( ) !default; $switch-inactive-disabled-background-color: var( --nutui-switch-inactive-disabled-background-color, - $color-background + var(--nutui-color-background-component) ) !default; $switch-inactive-line-background-color: var( --nutui-switch-inactive-line-background-color, - #ffffff + $color-primary-text ) !default; -$switch-width: var(--nutui-switch-width, scale-px(46px)) !default; -$switch-height: var(--nutui-switch-height, scale-px(28px)) !default; -$switch-line-height: var(--nutui-switch-line-height, scale-px(28px)) !default; +$switch-width: var(--nutui-switch-width, scale-px(56px)) !default; +$switch-height: var(--nutui-switch-height, scale-px(24px)) !default; +$switch-inside-width: var(--nutui-switch-inside-width, scale-px(32px)) !default; +$switch-inside-height: var(--nutui-switch-inside-height, scale-px(20px)) !default; $switch-border-radius: var( --nutui-switch-border-radius, $radius-circle @@ -1056,29 +1057,19 @@ $switch-border-radius: var( $switch-border-width: var(--nutui-switch-border-width, scale-px(2px)) !default; $switch-inside-border-radius: var( --nutui-switch-inside-border-radius, - $radius-full -) !default; -/* #ifdef harmony */ -$switch-inside-box-shadow: var( - --nutui-switch-inside-box-shadow, - 0px scale-px(2px) scale-px(6px) 0px rgba(0, 0, 0, 0.1) + $radius-circle ) !default; -/* #endif */ -/* #ifndef harmony */ $switch-inside-box-shadow: var( --nutui-switch-inside-box-shadow, - 0px scale-px(2px) scale-px(1px) 0px rgba(0, 0, 0, 0.06), - 0px scale-px(2px) scale-px(6px) 0px rgba(0, 0, 0, 0.1), - 0px 0px 0px scale-px(1px) rgba(0, 0, 0, 0.02) + 0px scale-px(4px) scale-px(8px) 0px rgba(0, 0, 0, 0.12) ) !default; -/* #endif */ $switch-label-text-color: var( --nutui-switch-label-text-color, $color-primary-text ) !default; $switch-label-font-size: var( --nutui-switch-label-font-size, - $font-size-s + $font-size-xs ) !default; $switch-inactive-disabled-label-text-color: var( --nutui-switch-inactive-disabled-label-text-color, From 033f713d82c3ec83b1a5b8b0203199565d5678ef Mon Sep 17 00:00:00 2001 From: songchenglin3 <353833373@qq.com> Date: Fri, 12 Jun 2026 10:51:53 +0800 Subject: [PATCH 3/5] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96wcsc=20=E5=AF=B9?= =?UTF-8?q?=E5=B5=8C=E5=A5=97=20calc=20+=20var=20=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E6=88=90=E6=9C=AC=E9=AB=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/switch/switch.scss | 37 ++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/src/packages/switch/switch.scss b/src/packages/switch/switch.scss index 885f5a00d9..5ebd9e6b1d 100644 --- a/src/packages/switch/switch.scss +++ b/src/packages/switch/switch.scss @@ -1,4 +1,11 @@ .nut-switch { + --nut-switch-height: #{$switch-height}; + --nut-switch-inside-width: #{$switch-inside-width}; + --nut-switch-border-width: #{$switch-border-width}; + --nut-switch-label-margin-offset: calc( + var(--nut-switch-inside-width) + var(--nut-switch-border-width) + 3px + ); + cursor: pointer; position: relative; /* #ifdef dynamic*/ @@ -16,7 +23,7 @@ background-size: 100% 100%; background-repeat: no-repeat; background-position: center center; - flex: 0 0 auto; // 防止被压缩 + flex: 0 0 auto; &-button { position: absolute; @@ -33,15 +40,19 @@ transition: left 0.3s linear; box-shadow: $switch-inside-box-shadow; &-open { - left: calc(100% - $switch-inside-width - $switch-border-width); + left: calc( + 100% - var(--nut-switch-inside-width) - var(--nut-switch-border-width) + ); &-rtl { - left: $switch-border-width; + left: var(--nut-switch-border-width); } } &-close { - left: $switch-border-width; + left: var(--nut-switch-border-width); &-rtl { - left: calc(100% - $switch-inside-width - $switch-border-width); + left: calc( + 100% - var(--nut-switch-inside-width) - var(--nut-switch-border-width) + ); } } } @@ -49,7 +60,9 @@ &-close { background-color: $switch-inactive-background-color; &-line { - width: calc(($switch-height - $switch-border-width * 2) / 2); + width: calc( + (var(--nut-switch-height) - var(--nut-switch-border-width) * 2) * 0.5 + ); height: 2px; background: $switch-inactive-line-background-color; border-radius: 2px; @@ -57,8 +70,8 @@ } .nut-icon { - width: calc($switch-height / 2); - height: calc($switch-height / 2); + width: calc(var(--nut-switch-height) * 0.5); + height: calc(var(--nut-switch-height) * 0.5); color: $switch-active-disabled-background-color; } @@ -78,16 +91,16 @@ color: $switch-label-text-color; } &-open { - margin: 0 calc($switch-inside-width + $switch-border-width + 3px) 0 7px; + margin: 0 var(--nut-switch-label-margin-offset) 0 7px; &-rtl { - margin: 0 7px 0 calc($switch-inside-width + $switch-border-width + 3px); + margin: 0 7px 0 var(--nut-switch-label-margin-offset); } } &-close { - margin: 0 7px 0 calc($switch-inside-width + $switch-border-width + 3px); + margin: 0 7px 0 var(--nut-switch-label-margin-offset); &-rtl { - margin: 0 calc($switch-inside-width + $switch-border-width + 3px) 0 7px; + margin: 0 var(--nut-switch-label-margin-offset) 0 7px; } } From e893795b18e11bf68013d097a74024dc7cdc5788 Mon Sep 17 00:00:00 2001 From: songchenglin3 <353833373@qq.com> Date: Fri, 12 Jun 2026 14:43:28 +0800 Subject: [PATCH 4/5] =?UTF-8?q?style:=20=E6=9B=B4=E6=96=B0=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8F=98=E9=87=8F=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/configprovider/types.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/packages/configprovider/types.ts b/src/packages/configprovider/types.ts index baa2d926a6..26cfe9850b 100644 --- a/src/packages/configprovider/types.ts +++ b/src/packages/configprovider/types.ts @@ -56,6 +56,7 @@ export type NutCSSVariables = | 'nutuiColorTextDisabled' | 'nutuiColorTextDark' | 'nutuiColorTextLink' + | 'nutuiColorPrimaryText' | 'nutuiFontSizeXxxs' | 'nutuiFontSizeXxs' | 'nutuiFontSizeXs' @@ -360,7 +361,8 @@ export type NutCSSVariables = | 'nutuiSwitchInactiveLineBackgroundColor' | 'nutuiSwitchWidth' | 'nutuiSwitchHeight' - | 'nutuiSwitchLineHeight' + | 'nutuiSwitchInsideWidth' + | 'nutuiSwitchInsideHeight' | 'nutuiSwitchBorderRadius' | 'nutuiSwitchBorderWidth' | 'nutuiSwitchInsideBorderRadius' From 127014512c306b2596c0489880518fb83eb5ed81 Mon Sep 17 00:00:00 2001 From: songchenglin3 <353833373@qq.com> Date: Fri, 12 Jun 2026 15:12:45 +0800 Subject: [PATCH 5/5] =?UTF-8?q?style:=20theme-dark=20=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/styles/theme-dark.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/styles/theme-dark.scss b/src/styles/theme-dark.scss index 57b25d02b0..df66b6eb15 100644 --- a/src/styles/theme-dark.scss +++ b/src/styles/theme-dark.scss @@ -123,7 +123,7 @@ page, // --nutui-white-10: rgba(255, 255, 255, 0.7); // --nutui-white-11: rgba(255, 255, 255, 0.8); --nutui-white-12: rgba(31, 31, 31, 0.9); - // --nutui-white-13: rgba(255, 255, 255, 1); + --nutui-white-13: rgba(255, 255, 255, 1); // 品牌颜色语义化 // 品牌主色调默认态,主要功能控件的背景、边框、镂空状态下的文字等