diff --git a/packages/uni-api/src/helpers/api/callback.ts b/packages/uni-api/src/helpers/api/callback.ts index abdef8dcb9747fd26fb33b08f8dd603457ed4e80..66bcfd43448bfdc06d75bfe65b0c86f71f4a8f21 100644 --- a/packages/uni-api/src/helpers/api/callback.ts +++ b/packages/uni-api/src/helpers/api/callback.ts @@ -81,7 +81,10 @@ export const API_SUCCESS = 'success' export const API_FAIL = 'fail' export const API_COMPLETE = 'complete' -type CALLBACK_TYPES = typeof API_SUCCESS | typeof API_FAIL | typeof API_COMPLETE +export type CALLBACK_TYPES = + | typeof API_SUCCESS + | typeof API_FAIL + | typeof API_COMPLETE type ApiCallbacks = { [key in CALLBACK_TYPES]?: Function diff --git a/packages/uni-api/src/helpers/api/index.ts b/packages/uni-api/src/helpers/api/index.ts index 4f65cc486d3afde03b2783ab82a1a889c2aff129..14ea1407d8a4496d979766586850d97120753d44 100644 --- a/packages/uni-api/src/helpers/api/index.ts +++ b/packages/uni-api/src/helpers/api/index.ts @@ -15,6 +15,7 @@ import { createKeepAliveApiCallback, removeKeepAliveApiCallback, } from './callback' +import type { CALLBACK_TYPES } from './callback' import { promisify } from './promise' function formatApiArgs( @@ -219,7 +220,7 @@ export function defineSyncApi( export function defineAsyncApi>( name: string, fn: ( - args: Omit, + args: Omit, res: { resolve: (res?: AsyncApiRes

) => void reject: (err?: string) => void diff --git a/packages/uni-api/src/helpers/protocol.ts b/packages/uni-api/src/helpers/protocol.ts index fbed299447b7b4a9e56702dee25854eeffc6d3cd..9b858be230b59a797e2d4c01b285aa3fc8854e62 100644 --- a/packages/uni-api/src/helpers/protocol.ts +++ b/packages/uni-api/src/helpers/protocol.ts @@ -23,8 +23,8 @@ export const HTTP_METHODS = [ 'CONNECT', ] -export function elemInArray(str: string, arr: string[]) { - if (arr.indexOf(str) === -1) { +export function elemInArray(str: T, arr: T[]) { + if (!str || arr.indexOf(str) === -1) { return arr[0] } return str diff --git a/packages/uni-api/src/index.ts b/packages/uni-api/src/index.ts index 5e3ba6ede6902b726dc54534939a48b1b621d553..1c77e0772d8639eed1cea38fbd3ba2da1a4a96d1 100644 --- a/packages/uni-api/src/index.ts +++ b/packages/uni-api/src/index.ts @@ -23,6 +23,7 @@ export * from './protocols/location/openLocation' export * from './protocols/media/chooseImage' export * from './protocols/media/chooseVideo' +export * from './protocols/media/chooseFile' export * from './protocols/media/getImageInfo' export * from './protocols/network/request' diff --git a/packages/uni-api/src/protocols/ui/tabBar.ts b/packages/uni-api/src/protocols/ui/tabBar.ts index 219b5a6670ebfcff51196e3a6a24b531327d1aae..b848edb100552deb680cf7a211270672a821360c 100644 --- a/packages/uni-api/src/protocols/ui/tabBar.ts +++ b/packages/uni-api/src/protocols/ui/tabBar.ts @@ -1,8 +1,7 @@ import { extend } from '@vue/shared' -import { getLen } from '@dcloudio/uni-shared' +import { getLen, removeLeadingSlash } from '@dcloudio/uni-shared' import { getRealPath } from '@dcloudio/uni-platform' import { getCurrentPageMeta } from '@dcloudio/uni-core' -import { removeLeadingSlash } from '@dcloudio/uni-shared' const IndexProtocol: ApiProtocol = { index: { diff --git a/packages/uni-h5/src/service/api/base/getBaseSystemInfo.ts b/packages/uni-h5/src/service/api/base/getBaseSystemInfo.ts index c08bffe6e4e9eeea0c99bad8474e34fb68b768c2..0b3080af4eb0a18bb2ed5ec5432bead156f39fe9 100644 --- a/packages/uni-h5/src/service/api/base/getBaseSystemInfo.ts +++ b/packages/uni-h5/src/service/api/base/getBaseSystemInfo.ts @@ -10,6 +10,8 @@ export const isMac = /Macintosh|Mac/i.test(ua) export const isLinux = /Linux|X11/i.test(ua) +export const isIPadOS = isMac && navigator.maxTouchPoints > 0 + export function getScreenFix() { return ( /^Apple/.test(navigator.vendor) && typeof window.orientation === 'number' diff --git a/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts b/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts index 116ccc3ba21236bab7cc67febc44d8b0d121beeb..c8665069d1a776ed1f2b9fe9e1e37288a1491bd7 100644 --- a/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts +++ b/packages/uni-h5/src/service/api/device/getSystemInfoSync.ts @@ -11,6 +11,7 @@ import { isWindows, isMac, isLinux, + isIPadOS, isLandscape, getScreenFix, getScreenWidth, @@ -88,6 +89,10 @@ export const getSystemInfoSync = defineSyncApi( break } } + } else if (isIPadOS) { + model = 'iPad' + osname = 'iOS' + osversion = typeof window.BigInt === 'function' ? '14.0' : '13.0' } else if (isWindows || isMac || isLinux) { model = 'PC' osname = 'PC' diff --git a/packages/uni-shared/src/utils.ts b/packages/uni-shared/src/utils.ts index a0131bf196082a57f4b80f1b251e9ea0e6b2691f..5cb574bfda5112ccfd0377273093c6ff50003dc8 100644 --- a/packages/uni-shared/src/utils.ts +++ b/packages/uni-shared/src/utils.ts @@ -13,3 +13,12 @@ export const invokeArrayFns = (fns: Function[], arg?: any) => { } return ret } + +export function updateElementStyle( + element: HTMLElement, + styles: Partial +) { + for (const attrName in styles) { + element.style[attrName] = styles[attrName]! + } +}