import {genSaltSync, hashSync} from 'bcryptjs'; export enum TrackingType { /** 进入游戏 */ Open = 'open', /** 临时柜子(观看视频获得柜子) */ TemporaryCabinet = 'temporary-cabinet', /** 撤回(撤回上次操作) */ Retract = 'retract', /** 打乱(打乱当前牌局) */ Shuffle = 'shuffle', /** 柜子(随机消除当前满柜的一个柜子内的麻将) */ Cabinet = 'cabinet', /** 增加时间 */ AddTime = 'add-time', /** 体力值 */ 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}失败`); } } }