plugin.uts 804 字节
Newer Older
1
import { Stat } from '@/uni_modules/uni-stat'
M
mehaotian 已提交
2 3 4 5 6

// 实例统计sdk
const stat_instance = Stat.getInstance()

const lifecycle = defineMixin({
7
  // onLaunch(options : OnLaunchOptions) { stat_instance.onLaunch(options, this) },
M
mehaotian 已提交
8
  // @ts-ignore
M
mehaotian 已提交
9 10
  onLoad() {
		// @ts-ignore
11 12
    stat_instance.onLoad(this)
  },
M
mehaotian 已提交
13
  // @ts-ignore
M
mehaotian 已提交
14 15
  onShow() {
		// @ts-ignore
16 17
    stat_instance.onShow(this)
  },
M
mehaotian 已提交
18
  // @ts-ignore
M
mehaotian 已提交
19 20
  onHide() {
		// @ts-ignore
21 22
    stat_instance.onHide(this)
  },
M
mehaotian 已提交
23
  // @ts-ignore
M
mehaotian 已提交
24 25
  onUnload() {
		// @ts-ignore
26 27 28
    stat_instance.onUnload(this)
  },
  // onError(error : string) { stat_instance.onError(error) }
M
mehaotian 已提交
29 30 31 32
})


export const uniStat = definePlugin({
33 34 35 36
  install(app : VueApp, options : UTSJSONObject) {
    stat_instance.init(options)
    app.mixin(lifecycle)
  }
M
mehaotian 已提交
37
})