import {genSaltSync, hashSync} from 'bcryptjs'; export enum TrackingType { /** 进入游戏 */ Open = 'open', /** 临时卡槽(观看视频获得临时卡槽) */ TemporaryCabinet = 'temporary-cabinet', /** 洗牌(游戏无法进行下去的小特权) */ Shuffle = 'shuffle', /** 体力值 */ HealthPoints = 'health-points' } const KEY = `sssssssssk`; export class TrackingManager { public static async send(type: TrackingType) { const salt = genSaltSync(10); const hash = hashSync(KEY, salt); const formData = new FormData(); formData.append('listener', type); const res = await fetch('https://api.ad.game.06zk.com/app/anchor', { method: "POST", headers: { Key: hash, Href: location.href }, body: formData }); const data = await res.json(); if (data.code === 200) { console.log(`上报${type}成功`); } else { console.log(`上报${type}失败`); } } }