| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- import { SDK } from "../lib/dn-sdk-minigame/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("请先执行wxxyssdk的init方法")
- return false
- }
- return this.instance;
- }
- }
- export default DnSdk
|