提交 f34dc72f 编写于 作者: D DCloud_LXH

chore: getSystemInfoSync

上级 853a81b2
...@@ -81,7 +81,10 @@ export const API_SUCCESS = 'success' ...@@ -81,7 +81,10 @@ export const API_SUCCESS = 'success'
export const API_FAIL = 'fail' export const API_FAIL = 'fail'
export const API_COMPLETE = 'complete' 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 = { type ApiCallbacks = {
[key in CALLBACK_TYPES]?: Function [key in CALLBACK_TYPES]?: Function
......
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
createKeepAliveApiCallback, createKeepAliveApiCallback,
removeKeepAliveApiCallback, removeKeepAliveApiCallback,
} from './callback' } from './callback'
import type { CALLBACK_TYPES } from './callback'
import { promisify } from './promise' import { promisify } from './promise'
function formatApiArgs<T extends ApiLike>( function formatApiArgs<T extends ApiLike>(
...@@ -219,7 +220,7 @@ export function defineSyncApi<T extends ApiLike>( ...@@ -219,7 +220,7 @@ export function defineSyncApi<T extends ApiLike>(
export function defineAsyncApi<T extends AsyncApiLike, P = AsyncApiOptions<T>>( export function defineAsyncApi<T extends AsyncApiLike, P = AsyncApiOptions<T>>(
name: string, name: string,
fn: ( fn: (
args: Omit<P, 'success' | 'fail' | 'complete'>, args: Omit<P, CALLBACK_TYPES>,
res: { res: {
resolve: (res?: AsyncApiRes<P>) => void resolve: (res?: AsyncApiRes<P>) => void
reject: (err?: string) => void reject: (err?: string) => void
......
...@@ -23,8 +23,8 @@ export const HTTP_METHODS = [ ...@@ -23,8 +23,8 @@ export const HTTP_METHODS = [
'CONNECT', 'CONNECT',
] ]
export function elemInArray(str: string, arr: string[]) { export function elemInArray<T = string>(str: T, arr: T[]) {
if (arr.indexOf(str) === -1) { if (!str || arr.indexOf(str) === -1) {
return arr[0] return arr[0]
} }
return str return str
......
...@@ -23,6 +23,7 @@ export * from './protocols/location/openLocation' ...@@ -23,6 +23,7 @@ export * from './protocols/location/openLocation'
export * from './protocols/media/chooseImage' export * from './protocols/media/chooseImage'
export * from './protocols/media/chooseVideo' export * from './protocols/media/chooseVideo'
export * from './protocols/media/chooseFile'
export * from './protocols/media/getImageInfo' export * from './protocols/media/getImageInfo'
export * from './protocols/network/request' export * from './protocols/network/request'
......
import { extend } from '@vue/shared' 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 { getRealPath } from '@dcloudio/uni-platform'
import { getCurrentPageMeta } from '@dcloudio/uni-core' import { getCurrentPageMeta } from '@dcloudio/uni-core'
import { removeLeadingSlash } from '@dcloudio/uni-shared'
const IndexProtocol: ApiProtocol<API_TYPE_SET_TAB_BAR_ITEM> = { const IndexProtocol: ApiProtocol<API_TYPE_SET_TAB_BAR_ITEM> = {
index: { index: {
......
...@@ -10,6 +10,8 @@ export const isMac = /Macintosh|Mac/i.test(ua) ...@@ -10,6 +10,8 @@ export const isMac = /Macintosh|Mac/i.test(ua)
export const isLinux = /Linux|X11/i.test(ua) export const isLinux = /Linux|X11/i.test(ua)
export const isIPadOS = isMac && navigator.maxTouchPoints > 0
export function getScreenFix() { export function getScreenFix() {
return ( return (
/^Apple/.test(navigator.vendor) && typeof window.orientation === 'number' /^Apple/.test(navigator.vendor) && typeof window.orientation === 'number'
......
...@@ -11,6 +11,7 @@ import { ...@@ -11,6 +11,7 @@ import {
isWindows, isWindows,
isMac, isMac,
isLinux, isLinux,
isIPadOS,
isLandscape, isLandscape,
getScreenFix, getScreenFix,
getScreenWidth, getScreenWidth,
...@@ -88,6 +89,10 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>( ...@@ -88,6 +89,10 @@ export const getSystemInfoSync = defineSyncApi<typeof uni.getSystemInfoSync>(
break break
} }
} }
} else if (isIPadOS) {
model = 'iPad'
osname = 'iOS'
osversion = typeof window.BigInt === 'function' ? '14.0' : '13.0'
} else if (isWindows || isMac || isLinux) { } else if (isWindows || isMac || isLinux) {
model = 'PC' model = 'PC'
osname = 'PC' osname = 'PC'
......
...@@ -13,3 +13,12 @@ export const invokeArrayFns = (fns: Function[], arg?: any) => { ...@@ -13,3 +13,12 @@ export const invokeArrayFns = (fns: Function[], arg?: any) => {
} }
return ret 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.
先完成此消息的编辑!
想要评论请 注册