Skip to content

feat: configprovider #3180

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

Open
wants to merge 4 commits into
base: feat_v3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
141 changes: 0 additions & 141 deletions src/locales/base.ts

This file was deleted.

4 changes: 2 additions & 2 deletions src/locales/en-US.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseLang } from './base'
import { Locales } from '@/types'

const enUS: BaseLang = {
const enUS: Locales = {
save: 'Save',
confirm: 'Confirm',
cancel: 'Cancel',
Expand Down
4 changes: 2 additions & 2 deletions src/locales/id-ID.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseLang } from './base'
import { Locales } from '@/types'

const idID: BaseLang = {
const idID: Locales = {
save: 'Simpan',
confirm: 'Konfirmasi',
cancel: 'Batal',
Expand Down
4 changes: 2 additions & 2 deletions src/locales/tr-TR.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseLang } from './base'
import { Locales } from '@/types'

const trTR: BaseLang = {
const trTR: Locales = {
save: 'Kaydet',
confirm: 'Onayla',
cancel: 'İptal',
Expand Down
4 changes: 2 additions & 2 deletions src/locales/zh-CN.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseLang } from './base'
import { Locales } from '@/types'

const zhCN: BaseLang = {
const zhCN: Locales = {
save: '保存',
confirm: '确认',
cancel: '取消',
Expand Down
4 changes: 2 additions & 2 deletions src/locales/zh-TW.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseLang } from './base'
import { Locales } from '@/types'

const zhCN: BaseLang = {
const zhCN: Locales = {
save: '保存',
confirm: '確認',
cancel: '取消',
Expand Down
4 changes: 2 additions & 2 deletions src/locales/zh-UG.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseLang } from './base'
import { Locales } from '@/types'

const zhUG: BaseLang = {
const zhUG: Locales = {
save: 'ساقلاش',
confirm: 'ھەئە',
cancel: 'ياق',
Expand Down
4 changes: 2 additions & 2 deletions src/packages/address/address.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const InternalAddress: ForwardRefRenderFunction<
<CustomRender
visible={innerVisible}
closeable
title={title || locale.address.selectRegion}
title={title || locale.address?.selectRegion}
left={renderLeftOnCustomSwitch()}
defaultValue={defaultValue}
closeIcon={closeIcon}
Expand All @@ -152,7 +152,7 @@ const InternalAddress: ForwardRefRenderFunction<
round
closeable
closeIcon={closeIcon}
title={title || locale.address.selectRegion}
title={title || locale.address?.selectRegion}
onClose={handleClose}
>
<View
Expand Down
4 changes: 2 additions & 2 deletions src/packages/address/address.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export const InternalAddress: ForwardRefRenderFunction<
<CustomRender
visible={innerVisible}
closeable
title={title || locale.address.selectRegion}
title={title || locale.address?.selectRegion}
left={renderLeftOnCustomSwitch()}
defaultValue={defaultValue}
closeIcon={closeIcon}
Expand All @@ -150,7 +150,7 @@ export const InternalAddress: ForwardRefRenderFunction<
round
closeable
closeIcon={closeIcon}
title={title || locale.address.selectRegion}
title={title || locale.address?.selectRegion}
onClose={handleClose}
>
<div
Expand Down
2 changes: 1 addition & 1 deletion src/packages/address/existRender.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const ExistRender: FunctionComponent<
</ul>
</ScrollView>

{(custom || (custom && locale.address.chooseAnotherAddress)) && (
{(custom || (custom && locale.address?.chooseAnotherAddress)) && (
<View className={`${classPrefix}-footer`} onClick={onClick}>
<View className={`${classPrefix}-footer-btn`}>{custom}</View>
</View>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/address/existRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export const ExistRender: FunctionComponent<
)
})}
</ul>
{(custom || (custom && locale.address.chooseAnotherAddress)) && (
{(custom || (custom && locale.address?.chooseAnotherAddress)) && (
<div className={`${classPrefix}-footer`} onClick={onClick}>
<div className={`${classPrefix}-footer-btn`}>{custom}</div>
</div>
Expand Down
10 changes: 4 additions & 6 deletions src/packages/audio/audio.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const Audio: FunctionComponent<
})
audioCtx.onEnded(() => {
if (loop) {
console.warn(locale.audio.tips || 'onPlayEnd事件在loop=false时才会触发')
console.warn(locale.audio?.tips || 'onPlayEnd事件在loop=false时才会触发')
} else {
onPlayEnd?.(audioCtx)
}
Expand Down Expand Up @@ -191,20 +191,18 @@ export const Audio: FunctionComponent<
className="back"
onClick={handleBack}
>
{locale.audio.back || '快退'}
{locale.audio?.back}
</Button>
<Button
type="primary"
size="small"
className="start"
onClick={handleStatusChange}
>
{playing
? `${locale.audio.pause || '暂停'}`
: `${locale.audio.start || '开始'}`}
{playing ? `${locale.audio?.pause}` : `${locale.audio?.start}`}
</Button>
<Button type="primary" size="small" onClick={handleForward}>
{locale.audio.forward || '快进'}
{locale.audio?.forward}
</Button>
</View>
</>
Expand Down
12 changes: 5 additions & 7 deletions src/packages/audio/audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
const classPrefix = 'nut-audio'
const handleEnded = (e: SyntheticEvent<HTMLAudioElement>) => {
if (loop) {
console.warn(locale.audio.tips || 'onPlayEnd事件在loop=false时才会触发')
console.warn(locale.audio?.tips || 'onPlayEnd事件在loop=false时才会触发')

Check warning on line 71 in src/packages/audio/audio.tsx

View check run for this annotation

Codecov / codecov/patch

src/packages/audio/audio.tsx#L71

Added line #L71 was not covered by tests
} else {
onEnd?.(e)
}
Expand Down Expand Up @@ -183,20 +183,18 @@
className="back"
onClick={handleBack}
>
{locale.audio.back || '快退'}
{locale.audio?.back}
</Button>
<Button
type="primary"
size="small"
className="start"
onClick={handleStatusChange}
>
{playing
? `${locale.audio.pause || '暂停'}`
: `${locale.audio.start || '开始'}`}
{playing ? `${locale.audio?.pause}` : `${locale.audio?.start}`}
</Button>
<Button type="primary" size="small" onClick={handleForward}>
{locale.audio.forward || '快进'}
{locale.audio?.forward}
</Button>
<Button
type={
Expand All @@ -205,7 +203,7 @@
size="small"
onClick={handleMute}
>
{locale.audio.mute || '静音'}
{locale.audio?.mute}
</Button>
</div>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/packages/avatarcropper/avatarcropper.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
{locale.cancel}
</Button>,
<Button key="reset">{locale.reset}</Button>,
<Button key="rotate">{locale.avatarCropper.rotate}</Button>,
<Button key="rotate">{locale.avatarCropper?.rotate}</Button>,
<Button type="success" key="confirm">
{locale.confirm}
</Button>,
Expand Down Expand Up @@ -156,7 +156,7 @@
...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 @@ -168,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 @@ -250,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 @@ -267,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 @@ -324,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
4 changes: 2 additions & 2 deletions src/packages/avatarcropper/avatarcropper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
{locale.cancel}
</Button>,
<Button key="reset">{locale.reset}</Button>,
<Button key="rotate">{locale.avatarCropper.rotate}</Button>,
<Button key="rotate">{locale.avatarCropper?.rotate}</Button>,
<Button type="success" key="confirm">
{locale.confirm}
</Button>,
Expand Down Expand Up @@ -111,7 +111,7 @@
height,
borderRadius: shape === 'round' ? '50%' : '',
}
}, [devicePixelRatio, drawImage.swidth])

Check warning on line 114 in src/packages/avatarcropper/avatarcropper.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 @@ -458,7 +458,7 @@
accept="image/*"
className={`${classPrefix}-input`}
onChange={(e: any) => inputImageChange(e)}
aria-label={locale.avatarCropper.selectImage}
aria-label={locale.avatarCropper?.selectImage}
/>
<div className="nut-avatar-cropper-edit-text">{editText}</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions src/packages/calendar/calendar.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ export const Calendar = React.forwardRef<
type={type}
autoBackfill={autoBackfill}
popup={popup}
title={title || locale.calendaritem.title}
title={title || locale.calendaritem?.title}
defaultValue={defaultValue}
startDate={startDate}
endDate={endDate}
showToday={showToday}
startText={startText || locale.calendaritem.start}
endText={endText || locale.calendaritem.end}
confirmText={confirmText || locale.calendaritem.confirm}
startText={startText || locale.calendaritem?.start}
endText={endText || locale.calendaritem?.end}
confirmText={confirmText || locale.calendaritem?.confirm}
showTitle={showTitle}
showSubTitle={showSubTitle}
scrollAnimation={scrollAnimation}
Expand Down
8 changes: 4 additions & 4 deletions src/packages/calendar/calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ export const Calendar = React.forwardRef<
autoBackfill={autoBackfill}
renderBottomButton={renderBottomButton}
popup={popup}
title={title || locale.calendaritem.title}
title={title || locale.calendaritem?.title}
defaultValue={defaultValue}
startDate={startDate}
endDate={endDate}
showToday={showToday}
startText={startText || locale.calendaritem.start}
endText={endText || locale.calendaritem.end}
confirmText={confirmText || locale.calendaritem.confirm}
startText={startText || locale.calendaritem?.start}
endText={endText || locale.calendaritem?.end}
confirmText={confirmText || locale.calendaritem?.confirm}
showTitle={showTitle}
showSubTitle={showSubTitle}
scrollAnimation={scrollAnimation}
Expand Down
Loading
Loading