Skip to content

Commit 13aeefb

Browse files
author
wangcuijuan
committed
feat: 修改comments提到的要修改的点
1 parent 71caebf commit 13aeefb

4 files changed

Lines changed: 36 additions & 6 deletions

File tree

packages/api-proxy/src/platform/api/camera/index.ios.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import CreateCamera from './rnCamera'
1+
import CameraContext from './rnCamera'
22

33
function createCameraContext () {
4-
return new CreateCamera()
4+
return new CameraContext()
55
}
66

77
export {

packages/api-proxy/src/platform/api/camera/rnCamera.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { noop, getFocusedNavigation } from '@mpxjs/utils'
22

3-
export default class CreateCamera {
3+
export default class CameraContext {
44
constructor () {
55
const navigation = getFocusedNavigation() || {}
66
this.camera = navigation.camera || {}

packages/core/@types/index.d.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,37 @@ export interface RnConfig {
387387
* @platform android
388388
* @default true
389389
*/
390-
enableNativeKeyboardAvoiding?: boolean
390+
enableNativeKeyboardAvoiding?: boolean,
391+
392+
/**
393+
* 自定义蓝牙权限检查函数,用于在调用 openBluetoothAdapter 时替代默认的权限检查逻辑。
394+
*
395+
* Mpx 在 iOS 上默认返回 true(假定权限由系统弹窗处理),在 Android 上会请求 ACCESS_FINE_LOCATION 或 BLUETOOTH_SCAN/CONNECT 权限。
396+
* 如果需要自定义权限申请逻辑(例如在某些定制 Android 设备上),可配置此函数。
397+
*
398+
* @returns Promise<boolean> Resolves 为 true 表示权限获取成功,false 表示失败。
399+
*/
400+
bluetoothPermission?: () => Promise<boolean>
401+
402+
/**
403+
* 自定义 Wi-Fi 权限检查函数,用于在调用 startWifi 时替代默认的权限检查逻辑。
404+
*
405+
* Mpx 在 Android 上默认会请求 ACCESS_FINE_LOCATION 权限。
406+
* 如果需要自定义权限申请逻辑,可配置此函数。
407+
*
408+
* @returns Promise<boolean> Resolves 为 true 表示权限获取成功,false 表示失败。
409+
*/
410+
wifiPermission?: () => Promise<boolean>
411+
412+
/**
413+
* 自定义相机权限检查函数,用于在渲染 Camera 组件前进行权限检查。
414+
*
415+
* 默认情况下,Mpx 会直接渲染 Camera 组件。
416+
* 如果配置了此函数,Camera 组件会等待该函数返回 true 后再进行渲染。
417+
*
418+
* @returns Promise<boolean> Resolves 为 true 表示权限获取成功,false 表示失败。
419+
*/
420+
cameraPermission?: () => Promise<boolean>
391421
}
392422

393423
interface MpxConfig {

packages/webpack-plugin/lib/runtime/components/react/mpx-camera.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { createElement, forwardRef, useRef, useCallback, useContext, useState, useEffect, useMemo } from 'react'
22
import { getCurrentPage, useTransformStyle, useLayout, extendObject } from './utils'
33
import useInnerProps, { getCustomEvent } from './getInnerListeners'
4+
import { Camera, useCameraDevice, useCodeScanner, useCameraFormat } from 'react-native-vision-camera'
45
import { noop, warn, hasOwn } from '@mpxjs/utils'
56
import { RouteContext } from './context'
67
import { watch, WatchOptions } from '@mpxjs/core'
@@ -66,7 +67,6 @@ let RecordRes: any = null
6667

6768
const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: CameraProps, ref): JSX.Element | null => {
6869
// eslint-disable-next-line @typescript-eslint/no-var-requires
69-
const { Camera, useCameraDevice, useCodeScanner, useCameraFormat } = require('react-native-vision-camera')
7070
const cameraRef = useRef<any>(null)
7171
const {
7272
mode = 'normal',
@@ -304,7 +304,7 @@ const _camera = forwardRef<HandlerRef<any, CameraProps>, CameraProps>((props: Ca
304304
}
305305
}, [])
306306

307-
const innerProps = useInnerProps(
307+
const innerProps:any = useInnerProps(
308308
extendObject(
309309
{},
310310
props,

0 commit comments

Comments
 (0)