import { SDK } from "../lib/dn-sdk-minigame/index" import { getStorage } from "../utils/index" class DnSdk { static instance = null static overrideShareFunc = false constructor() { } static init(dnSdkOptions) { if(!dnSdkOptions) { console.warn("DnSdk.init错误,请传入腾讯广告小游戏SDK参数") return false } if (!this.instance) { this.instance = new SDK(dnSdkOptions) } if(!this.overrideShareFunc) { wx.shareAppMessage = (function(){ const nativeShareAppMessage = wx.shareAppMessage return function(shareData) { console.log('override shareAppMessage exec') // 腾讯广告小游戏SDK上报 DnSdk.getInstance().track('SHARE', { target: 'APP_MESSAGE' }); return nativeShareAppMessage(shareData) } })() this.overrideShareFunc = true } } static getInstance() { if (!this.instance) { console.warn("请先执行miniGameSdk的init方法") return false } return this.instance; } } export default DnSdk