Skip to content

Commit

Permalink
feat: 1.Image组件兼容mode=""和src无值的情况;
Browse files Browse the repository at this point in the history
2.新增openLocation的实现;
3.路由错误抛出原始异常,便于定位;
4.修复Page.onReSize回调参数缺少的字段;
5.为navigateback添加数量上限限制;
6.修复redirectTo跳转不存在页面依然反馈成功的问题;
7.修复tab页面导航栏颜色配置无效的问题;
8.修复从有导航栏跳到无导航栏颜色配置无效的问题;
9.修改页面onShow和onReady生命周期出发顺序;
10.修复windows和mac路径差异问题;
11.优化Animation动画行为和微信小程序一致;
12.优化界面交互api的测试用例;
13.添加uuis出入框,修复tabbar显示长文本问题;
14.修改IntersectionObserver的监听反馈时间为timestamp值;
15.修复NodesRef.fields针对Canvas;
  • Loading branch information
tangcq-code committed Dec 11, 2023
1 parent f7dbda8 commit 27ab857
Show file tree
Hide file tree
Showing 32 changed files with 468 additions and 202 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Image events 1`] = `
<taro-image-core src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAFA3PEY8MlBGQUZaVVBfeMiCeG5uePWvuZHI////////////////////////////////////////////////////2wBDAVVaWnhpeOuCguv/////////////////////////////////////////////////////////////////////////wAARCAEsAZADASIAAhEBAxEB/8QAGQAAAwEBAQAAAAAAAAAAAAAAAAECAwQF/8QALhABAQACAgICAQMDAgcBAAAAAAECEQMhEjFBUWEEEyIyQnEjoRQzUmKBkbHB/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/8QAFhEBAQEAAAAAAAAAAAAAAAAAAAER/9oADAMBAAIRAxEAPwDcyMCIyAqirqKgyyY5tsmOYIACgE9kc9g2wb4scG2KDSGUMUJqk0EZMc22THMRJAKAAgMAAAQAHCOSgDIwBkAMgAAAAAAAAAAAAAAAAAAAB3GQAFTJAqiqqKDPJjk2yY5AgjJQHPZHPYN8G2LHBtig0hlFzHYJKtZJEck+QY5Mcm2THIEAB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GiPcAAF/5AEff4HaBaGjMC0eiChgAAAAMyAGAAAIwAAAAAAAAAIwYbGwALc+jl19l0XX2Dowu4phhfy2mUvyBgBQi0ZIEDIDikHsFFstjYCot0d3S8QTMtKl2PEeKKYTZYJkqK2No3dnJagrf1RN/QmMMBoaPYUGhowBaBkAALdAwWz2ALdPoAWxsEgoENqGC2AMAAZFsAYIAyGwALZbpkBbv2Jncb7Gvsrr4mwdOGczi3HMrj3br8Rrhz4330Dcil38jYCkAAIyAGQBQTtU3QIrdL8R4QGdlvqKmC9CgjxGlAEWUKpaAHsgB7GyIFkWwBgtnvYEDIBsEEADIAAYAAKAAAAAAAIGYBACtHsegGvupt/wClV/KbfroEXH5yuk+Xjf4zv7qvHZzj79boK488vl1YTc2y4uG+8nRJoEWEuooERWiUDAt0mZboNMMd+2mtFjNQwAIKHU2i0ogYIAZAtgZDY2AAJAHsgAEBAogAAIwAAAAAAC2AMEAMEFDBAGYLabUVVyk9J2k9UBs5C1VSAJNujjw12njw322k0qGRkqEnJVTlUVnYVujqbNgjLK5XUXhJjR/GDznwDonoJwy8sRvVBQpbTllJPYC2bG2O7ct4q3Yg12Ns5b8nv8gr4IvL8lsFBHkNitNjbPyHkCwjyGwUNp2AVstkAPY2ScqC9jbLdG00xp5DyZ7LZq418h5MtjZpjXyHky2NmmNfIeTLY2aY18h5Mtls0wrkWyCorFpGeLSIBWM3Urw9g3xmoop6NtkFQVRU2oyqsmWVAssmV5tdQ871WNSKflbfbSZaYxpFI6OHJpbtz4e22IC2ps37VUgJJJ0KAgWwAigwFQAwCQYAGAoADAgZAE5KTklEkZMtCkdIAABAQMUjIAAAI//Z">
<img class="taro-img__mode-scaletofill" src="">
</taro-image-core>
`;
exports[`Image events 1`] = `<taro-image-core src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAFA3PEY8MlBGQUZaVVBfeMiCeG5uePWvuZHI////////////////////////////////////////////////////2wBDAVVaWnhpeOuCguv/////////////////////////////////////////////////////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yZ7LZq418h5MtjZpjXyHky2NmmNfIeTLY2aY18h5Mtls0wrkWyCorFpGeLSIBWM3Urw9g3xmoop6NtkFQVRU2oyqsmWVAssmV5tdQ871WNSKflbfbSZaYxpFI6OHJpbtz4e22IC2ps37VUgJJJ0KAgWwAigwFQAwCQYAGAoADAgZAE5KTklEkZMtCkdIAABAQMUjIAAAI//Z"></taro-image-core>`;

exports[`Image should preload images 1`] = `
<taro-image-core>
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"dev:library-react": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-react run dev",
"dev:library-vue2": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-vue2 run dev",
"dev:library-vue3": "cross-env NODE_ENV=development pnpm --filter @tarojs/components-library-vue3 run dev",
"generate:lib": "mkdir -p lib",
"generate:lib": "node -e \"require('fs').mkdirSync('lib', { recursive: true })\"",
"generate:stencil-config": "esbuild ./scripts/stencil/stencil.config.ts --bundle --platform=node --outfile=stencil.config.js",
"sync:types": "pnpm run tsx --files scripts/json-schema-to-types.ts",
"test": "cross-env NODE_ENV=test stencil test --spec --e2e",
Expand Down
28 changes: 17 additions & 11 deletions packages/taro-components/src/components/image/image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,32 @@ export class Image implements ComponentInterface {
didLoad
} = this

// mode="" 按默认值处理
const compMode = mode || 'scaleToFill'

const cls = classNames({
'taro-img__widthfix': mode === 'widthFix'
'taro-img__widthfix': compMode === 'widthFix'
})
const imgCls = classNames(
`taro-img__mode-${mode.toLowerCase().replace(/\s/g, '')}`,
`taro-img__mode-${compMode.toLowerCase().replace(/\s/g, '')}`,
{
[`taro-img__mode-aspectfill--${aspectFillMode}`]: mode === 'aspectFill'
[`taro-img__mode-aspectfill--${aspectFillMode}`]: compMode === 'aspectFill'
}
)

return (
<Host class={cls}>
<img
ref={(img) => (this.imgRef = img!)}
class={imgCls}
src={lazyLoad && !didLoad ? undefined : src}
onLoad={imageOnLoad.bind(this)}
onError={imageOnError.bind(this)}
{...nativeProps}
/>
{
src ? (
<img
ref={(img) => (this.imgRef = img!)}
class={imgCls}
src={lazyLoad && !didLoad ? undefined : src}
onLoad={imageOnLoad.bind(this)}
onError={imageOnError.bind(this)}
{...nativeProps} />
) : ''
}
</Host>
)
}
Expand Down
7 changes: 4 additions & 3 deletions packages/taro-h5/__tests__/base/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ describe('others', () => {
test('should covert base64 to arraybuffer', () => {
const base64 = 'CxYh'
const arrayBuffer = Taro.base64ToArrayBuffer(base64)
expect(arrayBuffer[0]).toBe(11)
expect(arrayBuffer[1]).toBe(22)
expect(arrayBuffer[2]).toBe(33)
const initBuffer = new Uint8Array(arrayBuffer)
expect(initBuffer[0]).toBe(11)
expect(initBuffer[1]).toBe(22)
expect(initBuffer[2]).toBe(33)
})
})
12 changes: 6 additions & 6 deletions packages/taro-h5/__tests__/ui/animation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ describe('createAnimation', () => {
const ani: any = Taro.createAnimation()
const { rules, transform } = ani
ani.left(10)
expect(rules[0]).toEqual('left: 10px')
expect(rules[0]).toEqual({ 'key': 'left', 'rule': 'left: 10px' })
ani.top('10')
expect(rules[1]).toEqual('top: 10px')
expect(rules[1]).toEqual({ 'key': 'top', 'rule': 'top: 10px' })
ani.right('10%')
expect(rules[2]).toEqual('right: 10%')
expect(rules[2]).toEqual({ 'key': 'right', 'rule': 'right: 10%' })
ani.translate(10, '10%')
expect(transform[1]).toEqual('translate(10px, 10%)')
expect(transform[0]).toEqual({ 'key': 'translate', 'transform': 'translate(10px, 10%)' })
ani.translateX('10')
expect(transform[2]).toEqual('translateX(10px)')
expect(transform[1]).toEqual({ 'key': 'translateX', 'transform': 'translateX(10px)' })
ani.translate3d('10', 10, '20%')
expect(transform[3]).toEqual('translate3d(10px, 10px, 20%)')
expect(transform[2]).toEqual({ 'key': 'translate3d', 'transform': 'translate3d(10px, 10px, 20%)' })
})
})
39 changes: 18 additions & 21 deletions packages/taro-h5/__tests__/ui/interaction/actionSheet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('actionSheet', () => {
complete
})
.then(res => {
const expectObj = { errMsg: 'showActionSheet:ok', tapIndex: 1 }
const expectObj = { errMsg: 'showActionSheet:ok', tapIndex: 0 }
expect(success).toHaveBeenCalledWith(expectObj)
expect(fail.mock.calls.length).toBe(0)
expect(complete).toHaveBeenCalledWith(expectObj)
Expand All @@ -117,10 +117,10 @@ describe('actionSheet', () => {
const mask = actionSheet.firstChild
const list = actionSheet.lastChild.firstChild

expect(list.childNodes.length).toBe(3)
expect(list.childNodes[0]).toHaveTextContent(itemA)
expect(list.childNodes[1]).toHaveTextContent(itemB)
expect(list.childNodes[2]).toHaveTextContent(itemC)
expect(list.childNodes.length).toBe(4)
expect(list.childNodes[1]).toHaveTextContent(itemA)
expect(list.childNodes[2]).toHaveTextContent(itemB)
expect(list.childNodes[3]).toHaveTextContent(itemC)

setTimeout(() => {
expect(actionSheet).toBeVisible()
Expand Down Expand Up @@ -197,14 +197,13 @@ describe('actionSheet', () => {
Taro.showActionSheet({
itemList: [itemA, itemB, itemC]
})

const actionSheet: any = document.body.lastChild
const list = actionSheet.lastChild.firstChild

expect(list.childNodes.length).toBe(3)
expect(list.childNodes[0]).toHaveTextContent(itemA)
expect(list.childNodes[1]).toHaveTextContent(itemB)
expect(list.childNodes[2]).toHaveTextContent(itemC)
expect(list.childNodes.length).toBe(4)
expect(list.childNodes[1]).toHaveTextContent(itemA)
expect(list.childNodes[2]).toHaveTextContent(itemB)
expect(list.childNodes[3]).toHaveTextContent(itemC)
})

test('should update list item when itemList get longer', () => {
Expand All @@ -216,16 +215,15 @@ describe('actionSheet', () => {
Taro.showActionSheet({
itemList: [itemA, itemB, itemC, itemD, itemE]
})

const actionSheet: any = document.body.lastChild
const list = actionSheet.lastChild.firstChild

expect(list.childNodes.length).toBe(5)
expect(list.childNodes[0]).toHaveTextContent(itemA)
expect(list.childNodes[1]).toHaveTextContent(itemB)
expect(list.childNodes[2]).toHaveTextContent(itemC)
expect(list.childNodes[3]).toHaveTextContent(itemD)
expect(list.childNodes[4]).toHaveTextContent(itemE)
expect(list.childNodes.length).toBe(6)
expect(list.childNodes[1]).toHaveTextContent(itemA)
expect(list.childNodes[2]).toHaveTextContent(itemB)
expect(list.childNodes[3]).toHaveTextContent(itemC)
expect(list.childNodes[4]).toHaveTextContent(itemD)
expect(list.childNodes[5]).toHaveTextContent(itemE)
})

test('should update list item when only itemList get shorter', () => {
Expand All @@ -234,12 +232,11 @@ describe('actionSheet', () => {
Taro.showActionSheet({
itemList: [itemA, itemB]
})

const actionSheet: any = document.body.lastChild
const list = actionSheet.lastChild.firstChild

expect(list.childNodes.length).toBe(2)
expect(list.childNodes[0]).toHaveTextContent(itemA)
expect(list.childNodes[1]).toHaveTextContent(itemB)
expect(list.childNodes.length).toBe(3)
expect(list.childNodes[1]).toHaveTextContent(itemA)
expect(list.childNodes[2]).toHaveTextContent(itemB)
})
})
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
2 changes: 1 addition & 1 deletion packages/taro-h5/src/api/base/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function arrayBufferToBase64 (arrayBuffer: ArrayBuffer) {
}

export function base64ToArrayBuffer (base64: string) {
return toByteArray(base64)
return toByteArray(base64).buffer
}

export * from './crypto'
Expand Down
8 changes: 6 additions & 2 deletions packages/taro-h5/src/api/device/clipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import { isFunction } from '@tarojs/shared'

import { MethodHandler } from '../../utils/handler'
import { getStorageSync, setStorage, setStorageSync } from '../storage/index'
import { showToast } from '../ui/interaction'

const CLIPBOARD_STORAGE_NAME = 'taro_clipboard'

document.addEventListener('copy', () => {
setStorage({
key: CLIPBOARD_STORAGE_NAME,
Expand All @@ -21,7 +21,6 @@ document.addEventListener('copy', () => {
console.error(e)
})
})

/**
* 设置系统剪贴板的内容
*/
Expand Down Expand Up @@ -49,6 +48,11 @@ export const setClipboardData: typeof Taro.setClipboardData = async ({ data, suc
} else {
throw new Error('Unsupported Function: \'document.execCommand\'.')
}
showToast({
title: '内容已复制',
icon: 'none',
duration: 1500
})
return handle.success()
} catch (e) {
return handle.fail({ errMsg: e.message })
Expand Down
10 changes: 7 additions & 3 deletions packages/taro-h5/src/api/device/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {
}

const networkStatusManager = new CallbackManager()

const networkStatusListener = async () => {
const { networkType } = await getNetworkType()
const isConnected = networkType !== 'none'
Expand All @@ -79,8 +78,13 @@ export const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = callback

export const offNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('offNetworkWeakChange')

export const offNetworkStatusChange: typeof Taro.offNetworkStatusChange = callback => {
networkStatusManager.remove(callback)
export const offNetworkStatusChange: typeof Taro.offNetworkStatusChange = (callback) => {
// 取消监听网络状态变化事件,参数为空,则取消所有的事件监听。
if (callback) {
networkStatusManager.remove(callback)
} else {
networkStatusManager.removeAll()
}
const connection = getConnection()
if (connection && networkStatusManager.count() === 0) {
connection.removeEventListener('change', networkStatusListener)
Expand Down
Loading

0 comments on commit 27ab857

Please sign in to comment.