import * as tf from '@tensorflow/tfjs-core' ; import * as webgl from '@tensorflow/tfjs-backend-webgl' ; import * as fetchWechat from 'fetch-wechat' ; const plugin = requirePlugin ( 'tfjsPlugin' ) ; App < IAppOption > ( { globalData : { menuButtonBoundingRect : { } as WechatMiniprogram . Rect , statusBarHeight : 0 , menuHeaderHeight : 0 , systemInfo : { } as WechatMiniprogram . SystemInfo , openid : '' } , async onLaunch ( ) { if ( ! wx . cloud ) { console . error ( '请使用 2.2.3 或以上的基础库以使用云能力' ) ; } else { wx . cloud . init ( { traceUser : true , } ) ; } const systemInfo = wx . getSystemInfoSync ( ) ; let rect = wx . getMenuButtonBoundingClientRect ( ) ; this . globalData . menuButtonBoundingRect = rect ; this . globalData . statusBarHeight = systemInfo . statusBarHeight ; this . globalData . menuHeaderHeight = rect . bottom + rect . top - systemInfo . statusBarHeight ; this . globalData . systemInfo = wx . getSystemInfoSync ( ) ; plugin . configPlugin ( { fetchFunc : fetchWechat . fetchFunc ( ) , tf , webgl , canvas : wx . createOffscreenCanvas ( 0 , 0 ) } ) ; } , async onShow ( options ) { let loginRes = await wx . cloud . callFunction ( { name : 'Login' , data : { referrer : options . query . referrer || '' } } ) ; const openId = loginRes ?. result ?. openid || '' ; this . globalData . openid = openId ; } , } ) ;