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

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

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


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