Skip to content

Commit 15f2b1c

Browse files
authored
fix(countdown): taro不区分四端实现方式 (jdf2e#2396)
* fix: demo增加header * fix: rn copy脚本修改 * fix(countdown): taro不区分四端实现方式
1 parent 2c62aff commit 15f2b1c

File tree

2 files changed

+15
-35
lines changed

2 files changed

+15
-35
lines changed

scripts/rn/copy-file.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,20 @@ const copyFile = async (from, to, success, isSingle = false) => {
5454
'griditem',
5555
'hoverbuttonitem',
5656
'avatargroup',
57+
'icon',
5758
].includes(item)
5859
) {
5960
modify(
6061
`${targetBaseUrl}/packages/${item}/demo.taro.tsx`,
6162
`import '../../../styles/demo.scss';\n`
6263
)
6364
}
64-
modify(
65-
`${targetBaseUrl}/packages/${item}/${item}.taro.tsx`,
66-
`import "./${item}.harmony.css";\n`
67-
)
65+
if (!['icon'].includes(item)) {
66+
modify(
67+
`${targetBaseUrl}/packages/${item}/${item}.taro.tsx`,
68+
`import "./${item}.harmony.css";\n`
69+
)
70+
}
6871
}
6972
})
7073
})

src/packages/countdown/countdown.taro.tsx

+8-31
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React, {
99
import { View } from '@tarojs/components'
1010
import { BasicComponent, ComponentDefaults } from '@/utils/typings'
1111
import { padZero } from '@/utils/pad-zero'
12-
import { harmonyAndRn, web } from '@/utils/platform-taro'
12+
import { web } from '@/utils/platform-taro'
1313

1414
export interface CountDownTimeProps {
1515
d: number
@@ -201,12 +201,6 @@ const InternalCountDown: ForwardRefRenderFunction<
201201
formatCache = formatCache.replace('SS', msC.slice(0, 1))
202202
}
203203
}
204-
formatCache = formatCache.replace(
205-
/(\d+)/g,
206-
type === 'primary'
207-
? `<View class="nut-countdown-number-primary">$1</View>`
208-
: `<View class="nut-countdown-number">$1</View>`
209-
)
210204

211205
return formatCache
212206
}
@@ -293,10 +287,6 @@ const InternalCountDown: ForwardRefRenderFunction<
293287
destroy && cancelAnimationFrame(stateRef.current.timer)
294288
}
295289

296-
const renderTime = (() => {
297-
return formatRemainTime(stateRef.current.restTime)
298-
})()
299-
300290
const getUnit = (unit: string) => {
301291
const formatArr = format.split(/(DD|HH|mm|ss|S)/)
302292
const index = formatArr.indexOf(unit)
@@ -356,26 +346,13 @@ const InternalCountDown: ForwardRefRenderFunction<
356346
return (
357347
<>
358348
{children || (
359-
<>
360-
{!harmonyAndRn() ? (
361-
<View
362-
className={`${classPrefix} ${className}`}
363-
style={{ ...style }}
364-
{...rest}
365-
dangerouslySetInnerHTML={{
366-
__html: `${renderTime}`,
367-
}}
368-
/>
369-
) : (
370-
<View
371-
className={`${classPrefix} ${className}`}
372-
style={{ ...style }}
373-
{...rest}
374-
>
375-
{renderTaroTime()}
376-
</View>
377-
)}
378-
</>
349+
<View
350+
className={`${classPrefix} ${className}`}
351+
style={{ ...style }}
352+
{...rest}
353+
>
354+
{renderTaroTime()}
355+
</View>
379356
)}
380357
</>
381358
)

0 commit comments

Comments
 (0)