-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.ts
37 lines (37 loc) · 1.4 KB
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const axios = require('axios');
const host = 'http://akapi.saki.cc/'
const getDailyData = (server) => axios
.get(`${host}?server=${server}`, {responseType: "json"})
.then(function (response) {
console.log(response.data, 'response')
return response.data;
})
.catch(function (error) {
alert('服务已崩溃 请联系管理员')
});
const saveNum = (num, server, pass) => axios
.get(`${host}save.php?num=${num}&server=${server}&pass=${pass}`, {responseType: "json"})
.then(function (response) {
console.log(response.data, 'response')
return response.data;
})
.catch(function (error) {
alert('服务已崩溃 请联系管理员')
});
const getGameDataByLangAndName = (language, jsonName) => {
const targetProject = language !== 'zh_CN' ? 'ArknightsGameData_YoStar' : 'ArknightsGameData';
return axios.get(`https://raw.githubusercontent.com/Kengxxiao/${targetProject}/master/${language}/gamedata/excel/${jsonName}.json`).catch((err) => {
console.log(`${language}语言 ${jsonName}文件 获取失败 重试`)
// console.log(JSON.stringify(err))
return getGameDataByLangAndName(language, jsonName)
})
}
const afterDealData = ({chartsData, server, pass}) => {
getDailyData(server).then(({num}) => {
if (num !== chartsData.length) {
saveNum(chartsData.length, server, pass).then(() => {
})
}
})
}
module.exports = {afterDealData, getGameDataByLangAndName}