Skip to content

Commit

Permalink
fix: 优化loadFontFace成功回调信息以及setTabBarBadge上标显示
Browse files Browse the repository at this point in the history
  • Loading branch information
guoenxuan committed Dec 12, 2023
1 parent 0d2967d commit 7adf0f2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/taro-h5/__tests__/ui/tab-bar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('tabbar', () => {

it('should be able to switchTab', done => {
Taro.switchTab({
url: '/pages/about/about'
url: '/pages/about/index'
}).then((res: any) => {
expect(res.errMsg).toBe('switchTab:ok')
done()
Expand Down
7 changes: 4 additions & 3 deletions packages/taro-h5/src/api/ui/fonts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export const loadFontFace: typeof Taro.loadFontFace = async options => {
try {
await fontFace.load()
fonts.add(fontFace)
return handle.success({})
return handle.success({ status: 'loaded' })
} catch (error) {
return handle.fail({
errMsg: error.message || error
status: 'error',
errMsg: error.message || error,
})
}
} else {
Expand Down Expand Up @@ -59,6 +60,6 @@ export const loadFontFace: typeof Taro.loadFontFace = async options => {

style.innerText = `@font-face{${innerText}}`
document.head.appendChild(style)
return handle.success()
return handle.success({ status: 'loaded' })
}
}
2 changes: 1 addition & 1 deletion packages/taro-h5/src/api/ui/tab-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ export const setTabBarBadge: typeof Taro.setTabBarBadge = (options) => {
return new Promise((resolve, reject) => {
Taro.eventCenter.trigger('__taroSetTabBarBadge', {
index,
text,
text: text.replace(/[\u0391-\uFFE5]/g, 'aa').length > 4 ? '...' : text,
successHandler: (res = {}) => handle.success(res, { resolve, reject }),
errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
})
Expand Down

0 comments on commit 7adf0f2

Please sign in to comment.