Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 鸿蒙 pxtransform 支持 radix #2460

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Changes from all commits
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: 2 additions & 3 deletions src/utils/px-transform.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { pxTransform as transform } from '@tarojs/taro'
import { harmony, rn } from './platform-taro'

export default function pxTransform(value: number) {
if (harmony()) return transform(value)
export default function pxTransform(value: number, radix: number) {
if (harmony()) return transform(value, radix || 375)
Comment on lines +3 to +4
Copy link

Choose a reason for hiding this comment

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

建议在函数参数中设置默认值。

为了确保清晰并避免潜在问题,建议在函数参数中设置 radix 的默认值。

- export default function pxTransform(value: number, radix: number) {
+ export default function pxTransform(value: number, radix: number = 375) {
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
export default function pxTransform(value: number, radix: number) {
if (harmony()) return transform(value, radix || 375)
export default function pxTransform(value: number, radix: number = 375) {
if (harmony()) return transform(value, radix || 375)

if (rn()) return value
return `${value}px`
}