提交 f34dc72f 编写于 作者: D DCloud_LXH

chore: getSystemInfoSync

上级 853a81b2
......@@ -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
......
......@@ -15,6 +15,7 @@ import {
createKeepAliveApiCallback,
removeKeepAliveApiCallback,
} from './callback'
import type { CALLBACK_TYPES } from './callback'
import { promisify } from './promise'
function formatApiArgs<T extends ApiLike>(
......@@ -219,7 +220,7 @@ export function defineSyncApi<T extends ApiLike>(
export function defineAsyncApi<T extends AsyncApiLike, P = AsyncApiOptions<T>>(
name: string,
fn: (
args: Omit<P, 'success' | 'fail' | 'complete'>,
args: Omit<P, CALLBACK_TYPES>,
res: {
resolve: (res?: AsyncApiRes<P>) => void
reject: (err?: string) => void
......
......@@ -23,8 +23,8 @@ export const HTTP_METHODS = [
'CONNECT',
]
export function elemInArray(str: string, arr: string[]) {
if (arr.indexOf(str) === -1) {
export function elemInArray<T = string>(str: T, arr: T[]) {
if (!str || arr.indexOf(str) === -1) {
return arr[0]
}
return str
......
......@@ -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'
......
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<API_TYPE_SET_TAB_BAR_ITEM> = {
index: {
......
......@@ -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'
......
......@@ -11,6 +11,7 @@ import {
isWindows,
isMac,
isLinux,
isIPadOS,
isLandscape,
getScreenFix,
getScreenWidth,
......@@ -88,6 +89,10 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
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'
......
......@@ -13,3 +13,12 @@ export const invokeArrayFns = (fns: Function[], arg?: any) => {
}
return ret
}
export function updateElementStyle(
element: HTMLElement,
styles: Partial<CSSStyleDeclaration>
) {
for (const attrName in styles) {
element.style[attrName] = styles[attrName]!
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册