Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/hooks/taro/use-custom-event.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { useEffect, useRef } from 'react'
import isEqual from 'react-fast-compare'
import { Events, getCurrentInstance } from '@tarojs/taro'
import { eventCenter, getCurrentInstance } from '@tarojs/taro'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要在 h5 和小程序端验证一下

import { useForceUpdate } from '@/hooks/use-force-update'

export const customEvents = new Events()
// export const customEvents = new Events()
export const customEvents = eventCenter

export function useCustomEventsPath(selector?: string) {
selector = selector || ''
Expand Down
5 changes: 5 additions & 0 deletions src/packages/animatingnumbers/countup.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
.nut-countup {
&-list {
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
height: $countup-height;
overflow: hidden;
direction: ltr;
Expand Down
8 changes: 3 additions & 5 deletions src/packages/avatarcropper/avatarcropper.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
useMemo,
useCallback,
FunctionComponent,
useLayoutEffect,
} from 'react'
import Taro, { createSelectorQuery } from '@tarojs/taro'
import Taro, { useReady, createSelectorQuery } from '@tarojs/taro'
import classNames from 'classnames'
import { Canvas, CommonEventFunction, View } from '@tarojs/components'
import { getWindowInfo } from '@/utils/taro/get-system-info'
Expand Down Expand Up @@ -138,7 +137,7 @@
cropperCanvasContext: null,
})

useLayoutEffect(() => {
useReady(() => {
if (showAlipayCanvas2D) {
const { canvasId } = canvasAll
createSelectorQuery()
Expand All @@ -150,14 +149,14 @@
})
.exec()
}
}, [showAlipayCanvas2D, state.displayHeight, state.displayWidth])
})

useEffect(() => {
setCanvasAll({
...canvasAll,
cropperCanvasContext: Taro.createCanvasContext(canvasAll.canvasId),
})
}, [])

Check warning on line 159 in src/packages/avatarcropper/avatarcropper.taro.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useEffect has a missing dependency: 'canvasAll'. Either include it or remove the dependency array. You can also do a functional update 'setCanvasAll(c => ...)' if you only need 'canvasAll' in the 'setCanvasAll' call

const touch = useTouch()

Expand All @@ -169,7 +168,7 @@
height,
borderRadius: shape === 'round' ? '50%' : '',
}
}, [pixelRatio, state.cropperWidth])

Check warning on line 171 in src/packages/avatarcropper/avatarcropper.taro.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useMemo has a missing dependency: 'shape'. Either include it or remove the dependency array

// 是否是横向
const isAngle = useMemo(() => {
Expand Down Expand Up @@ -251,7 +250,7 @@
ctx.scale(scale, scale)
ctx.drawImage(src as HTMLImageElement, x, y, width, height)
},
[drawImage, state]

Check warning on line 253 in src/packages/avatarcropper/avatarcropper.taro.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useCallback has missing dependencies: 'pixelRatio' and 'space'. Either include them or remove the dependency array
)

// web绘制
Expand All @@ -268,7 +267,7 @@
canvas.height = state.displayHeight
const ctx = canvas.getContext('2d') as CanvasRenderingContext2D
canvas2dDraw(ctx)
}, [canvas2dDraw])

Check warning on line 270 in src/packages/avatarcropper/avatarcropper.taro.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useCallback has missing dependencies: 'canvasAll.canvasId', 'state.displayHeight', and 'state.displayWidth'. Either include them or remove the dependency array

const alipayDraw = useCallback(() => {
const ctx = canvasAll.cropperCanvas.getContext(
Expand Down Expand Up @@ -325,7 +324,7 @@
ctx.scale(scale, scale)
ctx.drawImage(src as string, x, y, width, height)
ctx.draw()
}, [drawImage, state.scale, state.angle, state.moveX, state.moveY])

Check warning on line 327 in src/packages/avatarcropper/avatarcropper.taro.tsx

View workflow job for this annotation

GitHub Actions / lint

React Hook useCallback has missing dependencies: 'alipayDraw', 'canvasAll', 'showAlipayCanvas2D', 'space', 'state', and 'webDraw'. Either include them or remove the dependency array

useEffect(() => {
if (Math.abs(state.moveX) > maxMoveX) {
Expand Down Expand Up @@ -694,5 +693,4 @@
</>
)
}

AvatarCropper.displayName = 'NutAvatarCropper'
10 changes: 10 additions & 0 deletions src/packages/badge/badge.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
.nut-badge {
position: relative;
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
vertical-align: middle;
box-sizing: content-box;
width: auto;
Expand Down Expand Up @@ -38,7 +43,12 @@
}

&-sup {
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
text-align: center;
min-width: $badge-min-width;
padding: $badge-padding;
Expand Down
3 changes: 3 additions & 0 deletions src/packages/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
transform: translate(-50%, -50%);
opacity: 0;
content: ' ';
/* #ifdef dynamic*/
pointer-events: none;
/* #endif */
}

&::after {
Expand Down
2 changes: 2 additions & 0 deletions src/packages/cascader/cascader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
}

.nut-tabs-titles-item {
/* #ifndef dynamic*/
flex: initial;
/* #endif */
min-width: auto;
width: auto;
padding: $cascader-tabs-item-padding;
Expand Down
5 changes: 5 additions & 0 deletions src/packages/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@

&-button {
position: relative;
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
align-items: center;
min-height: 32px;
padding: $checkbox-button-padding;
Expand Down
1 change: 1 addition & 0 deletions src/packages/checkbox/checkbox.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export const Checkbox: FC<
{
[`${classPrefix}-reverse`]: labelPosition === 'left',
'nut-checkbox-list-item': ctx?.list,
[`${classPrefix}-active`]: innerChecked,
},
className
)}
Expand Down
1 change: 1 addition & 0 deletions src/packages/checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ export const Checkbox: FunctionComponent<
{
[`${classPrefix}-reverse`]: labelPosition === 'left',
'nut-checkbox-list-item': ctx?.list,
[`${classPrefix}-active`]: innerChecked,
},
className
)}
Expand Down
5 changes: 5 additions & 0 deletions src/packages/checkboxgroup/checkboxgroup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
flex-wrap: wrap;

.nut-checkbox {
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
flex: 1;
margin-right: 20px;

Expand Down
4 changes: 4 additions & 0 deletions src/packages/configprovider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@ export type NutCSSVariables =
| 'nutuiFontSizeS'
| 'nutuiFontSizeBase'
| 'nutuiFontSizeL'
| 'nutuiFontSizeIcon'
| 'nutuiFontSizeXl'
| 'nutuiFontSizeXxl'
| 'nutuiFontSize10'
| 'nutuiFontSize11'
| 'nutuiFontWeightLight'
| 'nutuiFontWeight'
| 'nutuiFontWeightMedium'
| 'nutuiFontWeightBold'
| 'nutuiLineHeightBase'
| 'nutuiSpacingXxxs'
Expand Down Expand Up @@ -459,10 +461,12 @@ export type NutCSSVariables =
| 'nutuiDialogMinHeight'
| 'nutuiDialogBorderRadius'
| 'nutuiDialogBackground'
| 'nutuiDialogTitleMarginBottom'
| 'nutuiDialogContentMargin'
| 'nutuiDialogContentMaxHeight'
| 'nutuiDialogContentLineHeight'
| 'nutuiDialogContentTextAlign'
| 'nutuiDialogFooterButtonBorder'
| 'nutuiDialogFooterButtonMinWidth'
| 'nutuiDialogFooterCancelMarginRight'
| 'nutuiDialogFooterCancelBg'
Expand Down
4 changes: 4 additions & 0 deletions src/packages/dialog/demos/taro/demo6.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ const Demo6 = () => {
cancelText="决策2"
onConfirm={() => setVisible2(false)}
onCancel={() => setVisible2(false)}
onClose={() => {
setVisible2(false)
console.log('关闭底部icon 3')
}}
Comment on lines +43 to +46
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

请移除调试日志,并考虑与第一个对话框保持一致性

添加 onClose 处理器来响应关闭图标的点击是合理的,但存在以下问题:

  1. 调试代码残留:第 45 行的 console.log('关闭底部icon 3') 看起来像是调试代码,不应该保留在演示代码中
  2. 不一致性:第一个对话框(第 15-28 行)同样设置了 closeIcon,但没有 onClose 处理器。请确认这种差异是否是有意为之,用于演示不同的用法

应用此修改以移除调试日志:

 onClose={() => {
   setVisible2(false)
-  console.log('关闭底部icon 3')
 }}

如果希望保持两个对话框的一致性,可以考虑为第一个对话框也添加 onClose 处理器:

<Dialog
  className="test-dialog"
  title="顶部带关闭按钮"
  visible={visible1}
  closeIcon
  closeIconPosition="top-right"
  style={{
    '--nutui-dialog-close-color': '#888B94',
  }}
  onConfirm={() => setVisible1(false)}
  onCancel={() => setVisible1(false)}
+ onClose={() => setVisible1(false)}
>
  支持函数调用和组件调用两种方式。
</Dialog>

🏁 Script executed:

#!/bin/bash
# 查看完整的演示文件内容,特别是两个 Dialog 组件的定义
cat src/packages/dialog/demos/taro/demo6.tsx

Length of output: 1263


🏁 Script executed:

#!/bin/bash
# 检查项目中是否有类似的 console.log 用法模式
rg "console\.log\(" src/packages/dialog/demos/ -n -B2 -A2 | head -50

Length of output: 1998


🏁 Script executed:

#!/bin/bash
# 检查文件中是否有其他中文日志,用于判断是否是有意的演示代码
rg "console\.(log|warn|error)" src/packages/dialog/demos/taro/ -n

Length of output: 159


移除调试日志,并建议与第一个对话框保持一致

通过验证完整文件内容确认:

  1. 调试代码需要删除:第45行的 console.log('关闭底部icon 3') 是中文调试信息,不应保留在演示代码中。相比之下,项目中其他demo文件使用的console.log(如'stop close'或'onClose')都是英文功能描述,而此处的中文信息明显是内部调试遗留。

  2. 两个Dialog的不一致性

    • 第一个Dialog(第15-28行):有 closeIcon 但无 onClose 处理器
    • 第二个Dialog(第35-50行):既有 closeIcon 又有 onClose 处理器

    建议保持一致,为两个Dialog都添加 onClose 处理器,使演示代码更清晰完整。

建议修改

移除第45行的调试日志:

 onClose={() => {
   setVisible2(false)
-  console.log('关闭底部icon 3')
 }}

同时为第一个Dialog添加 onClose 处理器以保持一致:

 <Dialog
   className="test-dialog"
   title="顶部带关闭按钮"
   visible={visible1}
   closeIcon
   closeIconPosition="top-right"
   style={{
     '--nutui-dialog-close-color': '#888B94',
   }}
   onConfirm={() => setVisible1(false)}
   onCancel={() => setVisible1(false)}
+  onClose={() => setVisible1(false)}
 >
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
onClose={() => {
setVisible2(false)
console.log('关闭底部icon 3')
}}
onClose={() => {
setVisible2(false)
}}
🤖 Prompt for AI Agents
In src/packages/dialog/demos/taro/demo6.tsx around lines 43-46 (and also note
the first Dialog at lines 15-28), remove the debugging statement
console.log('关闭底部icon 3') and add an onClose handler to the first Dialog so both
Dialogs are consistent; the onClose handlers should mirror each other (set the
corresponding visible state to false) and avoid any debug-only console output.

closeIcon
>
支持函数调用和组件调用两种方式。
Expand Down
10 changes: 8 additions & 2 deletions src/packages/dialog/dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
position: fixed;
max-height: 100%;
background-color: $dialog-background;
/* #ifndef dynamic*/
transition:
transform 0.2s,
-webkit-transform 0.2s;
/* #endif */
-webkit-overflow-scrolling: touch;
top: 50%;
left: 50%;
Expand Down Expand Up @@ -83,6 +85,7 @@
font-size: $dialog-header-font-size;
font-weight: $dialog-header-font-weight;
color: $color-title;
margin-bottom: $dialog-title-margin-bottom;
@include oneline-ellipsis();
}

Expand Down Expand Up @@ -125,22 +128,25 @@

.nut-button {
min-width: $dialog-footer-button-min-width;
border-radius: $dialog-footer-button-border;
padding: var(--nutui-button-large-padding, 0 12px);
}

&-cancel.nut-dialog-footer-cancel {
margin-right: $dialog-footer-cancel-margin-right;
background: $dialog-footer-cancel-bg;
color: $button-default-color;
border-color: var(--nutui-button-default-border-color, transparent);
.nut-button-children {
color: $button-default-color;
}
}

&-ok {
max-width: $dialog-footer-ok-max-width;
font-weight: $font-weight-bold;
font-weight: $font-weight-medium;
.nut-button-children {
font-weight: $font-weight-bold;
font-weight: $font-weight-medium;
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/packages/divider/divider.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@
}

&-vertical {
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
width: 0px;
height: $divider-vertical-height;
border-left: 1px solid $divider-border-color;
Expand Down
5 changes: 5 additions & 0 deletions src/packages/drag/drag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
user-select: none;
font-size: 0;
&-inner {
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
width: fit-content;
height: fit-content;
touch-action: none;
Expand Down
7 changes: 7 additions & 0 deletions src/packages/elevator/elevator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
min-height: 100%;
width: 100%;
background-color: $elevator-list-bg-color;
/* #ifndef dynamic*/
overflow: auto;
/* #endif */
}

&-item {
Expand Down Expand Up @@ -96,7 +98,12 @@
display: flex;
flex-direction: column;
&-item {
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
align-items: center;
justify-content: center;
height: 16px;
Expand Down
1 change: 0 additions & 1 deletion src/packages/input/input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
flex: 1;
color: $color-title;
font-size: $input-font-size;
line-height: $input-lineheight;
padding: 0;
border: 0;
outline: 0 none;
Expand Down
17 changes: 15 additions & 2 deletions src/packages/input/input.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,27 @@ import React, {
} from 'react'
import { Input as TaroInput, View } from '@tarojs/components'
import { MaskClose } from '@nutui/icons-react-taro'
import Taro, { ENV_TYPE, getEnv } from '@tarojs/taro'
import Taro, { getEnv } from '@tarojs/taro'
import { BaseEventOrig } from '@tarojs/components/types/common'
import { formatNumber } from './utils'
import { useConfig, useRtl } from '@/packages/configprovider/index.taro'
import { ComponentDefaults } from '@/utils/typings'
import { usePropsValue } from '@/hooks/use-props-value'
import { InputFormatTrigger, TaroInputProps } from '@/types'

const ENV_TYPE = {
WEAPP: 'WEAPP',
SWAN: 'SWAN',
ALIPAY: 'ALIPAY',
TT: 'TT',
QQ: 'QQ',
JD: 'JD',
WEB: 'WEB',
RN: 'RN',
HARMONY: 'HARMONY',
QUICKAPP: 'QUICKAPP',
}

const defaultProps = {
...ComponentDefaults,
type: 'text',
Expand Down Expand Up @@ -195,7 +208,7 @@ export const Input = forwardRef((props: Partial<TaroInputProps>, ref) => {
placeholder === undefined ? locale.placeholder : placeholder
}
placeholderClass={`${classPrefix}-placeholder`}
disabled={disabled || readOnly}
disabled={disabled}
value={value}
focus={autoFocus || focus}
confirmType={confirmType}
Expand Down
8 changes: 7 additions & 1 deletion src/packages/inputnumber/inputnumber.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
.nut-inputnumber {
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
width: calc(
2 * #{$inputnumber-input-margin} + 2 * #{$inputnumber-button-width} + #{$inputnumber-input-width}
2 * #{$inputnumber-input-margin} + 2 * #{$inputnumber-button-width} +
#{$inputnumber-input-width}
);
flex-direction: row;
align-items: center;
Expand Down
5 changes: 5 additions & 0 deletions src/packages/loading/loading.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
.nut-loading {
/* #ifndef dynamic*/
display: inline-flex;
/* #endif */
/* #ifdef dynamic*/
display: flex;
/* #endif */
flex-direction: row;
align-items: center;
justify-content: center;
Expand Down
Loading
Loading