| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- 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
|