diff --git a/src/common/WebApi.ts b/src/common/WebApi.ts index dabe1bf..93c10fa 100644 --- a/src/common/WebApi.ts +++ b/src/common/WebApi.ts @@ -2,6 +2,8 @@ import axios from 'axios' import { debugRoom, error } from './Debug' import { Service } from '../service/Service' +const isProd = process.env.NODE_ENV === 'production' +const SERVER_TOKEN = 'ibDbuTmpQn3f48uJr2mBMkGrqvIhSbIg' /** * 获取卡组详情 * @param {string} accountid @@ -11,7 +13,9 @@ import { Service } from '../service/Service' */ export async function getCardGroup(accountid: string, heroid: number, cardgroup: string) { const infoHost = await new Service().getInfoSvr() - return axios.get(`${ infoHost }/${ accountid }/group_info/${ heroid }/${ cardgroup }`) + return axios.get(`${ infoHost }/${ accountid }/group_info/${ heroid }/${ cardgroup }`, { + params: {token: SERVER_TOKEN} + }) .then(function (response) { let res = response.data if (res.errcode) { @@ -24,7 +28,7 @@ export async function getCardGroup(accountid: string, heroid: number, cardgroup: export async function getUserInfo(accountid: string, isMatch: boolean) { const infoHost = await new Service().getInfoSvr() - return axios.post(`${ infoHost }/${ accountid }/uinfo`, {isMatch}) + return axios.post(`${ infoHost }/${ accountid }/uinfo`, {isMatch, token: SERVER_TOKEN}) .then(function (response) { let res = response.data if (res.errcode) { @@ -36,7 +40,7 @@ export async function getUserInfo(accountid: string, isMatch: boolean) { } export async function randomUserInfo(min: number, max: number, accounts: string[]) { - const data = {min, max, accounts} + const data = {min, max, accounts, token: SERVER_TOKEN} const infoHost = await new Service().getInfoSvr() return axios.post(`${ infoHost }/randomrobot`, data) .then(function (response) { @@ -56,7 +60,7 @@ export async function randomUserInfo(min: number, max: number, accounts: string[ * @return {Promise>} */ export async function requestUnlockHero(accountid: string, heroid: number | string) { - let data = { 'type': 0 } + let data = { 'type': 0, token: SERVER_TOKEN } const infoHost = await new Service().getInfoSvr() return axios.post(`${ infoHost }/${ accountid }/hero/unlock/${ heroid }`, data) } @@ -66,6 +70,7 @@ export async function requestUnlockHero(accountid: string, heroid: number | stri * @param data */ export async function reportGameResult(data: any) { + data.token = SERVER_TOKEN let dataStr = JSON.stringify(data) const infoHost = await new Service().getInfoSvr() let reqConfig = { @@ -88,7 +93,7 @@ export async function reportGameResult(data: any) { * @param {number} count */ export async function useItem(accountid: string, itemid: number, count: number) { - const data = { itemid, count } + const data = { itemid, count, token: SERVER_TOKEN } let dataStr = JSON.stringify(data) const infoHost = await new Service().getInfoSvr() if (!infoHost) { @@ -114,7 +119,7 @@ export async function useItem(accountid: string, itemid: number, count: number) * @return {Promise} */ export async function checkMatchTicket(accountid: string, matchid: string) { - const data = { matchid } + const data = { matchid, token: SERVER_TOKEN } const infoHost = await new Service().getInfoSvr() const url = `${ infoHost }/${ accountid }/beginmatch` let reqConfig = {