关于在IOS 真机与线上版本问题

小程序开发相关产品技术讨论,包括面板、智能小程序、React Native、Ray跨端框架、Panel SDK、微信小程序、小程序开发工具(IDE)及其他开发技术相关等话题


Post Reply
幽冥墨
Posts: 33

主要问题是 @ray-js/panel-sdk 中 new SmartDeviceModel<SmartDeviceSchema>() 中 onInitialized() 函数在Android 上面所有环境使用正常,IOS 上体验本与线上版本不能正常使用,但是开发者工具上与真机调试时表现正常

Code: Select all

********* devices *************

import { SmartDeviceModel } from '@ray-js/panel-sdk';
import { SmartDeviceSchema } from '../../typings/sdm';

export const devices = {
  lamp: new SmartDeviceModel<SmartDeviceSchema>(),
};

Object.keys(devices).forEach((k: keyof typeof devices) => {
  devices[k].init();
  
[b]---------------------------------------------------------------------[/b] ******** typings > sdm ******************** import { ProductName } from '@/constants'; type SmartDeviceSchema = typeof import('@/devices/schema').socketSchema; type SmartDevices = { socket?: import('@tuya-miniapp/sdm').SmartDeviceModel<SmartDeviceSchema>; }; declare module '@ray-js/sdm-react' { export const SdmProvider: React.FC<{ value: SmartDeviceModel<SmartDeviceSchema>; children: React.ReactNode; }>; export type SmartDeviceInstanceData = { devInfo: ReturnType<SmartDevices[ProductName]['getDevInfo']>; dpSchema: ReturnType<SmartDevices[ProductName]['getDpSchema']>; network: ReturnType<SmartDevices[ProductName]['getNetwork']>; bluetooth: ReturnType<SmartDevices[ProductName]['getBluetooth']>; }; export function useProps(): SmartDevices[ProductName]['model']['props']; export function useProps<Value extends any>( selector: (props?: SmartDevices[ProductName]['model']['props']) => Value, equalityFn?: (a: Value, b: Value) => boolean ): Value; export function useDevice(): SmartDeviceInstanceData; export function useDevice<Device extends any>( selector: (device: SmartDeviceInstanceData) => Device, equalityFn?: (a: Device, b: Device) => boolean ): Device; export function useActions(): SmartDevices[ProductName]['model']['actions']; } ----------------------------------------------------------------------------------------------------------------------- **************** 调用文件 *************** import { devices } from '@/devices'; class App extends React.Component<Props> { async onLaunch() { console.log('进入函数体 onLaunch'); console.log('查看这个数据对象类型', devices.lamp.onInitialized(res => { console.log('相同函数怎么会有不同的运行结果呢???*************'); return res })); devices.lamp.onInitialized(res => { console.log('进入 onInitialized 函数体'); }) } }); [b]Android 调用结果[/b] [attachment=2]android_bug.jpg[/attachment] [b]IOS 调用结果[/b] [attachment=1]IOS_bug.jpg[/attachment] [b]IOS 版本信息[/b] [attachment=0]IOS_info.jpg[/attachment]
Attachments
IOS_info.jpg
IOS_bug.jpg
android_bug.jpg
幽冥墨
Posts: 33

Re: 关于在IOS 真机与线上版本问题

将 onInitialized 函数提取到 App 函数体外面就可以正常运行,目前测试是没有什么问题

lshinylee
Posts: 312

Re: 关于在IOS 真机与线上版本问题

为避免出现类似问题,我们优化了一下模板,https://github.com/Tuya-Community/tuya-ray-demo/pull/20

:D :D :D

Post Reply