feat:轮询异常提醒
This commit is contained in:
父節點
0a2c10c584
當前提交
eff594035a
22
src/poll.ts
22
src/poll.ts
@ -1,9 +1,10 @@
|
||||
import {IJsonCourse} from "./types"
|
||||
import {getTimeNow, sduAxios, sleep} from "./includes"
|
||||
import {getTimeNow, logAndNotifyUser, sduAxios, sleep} from "./includes"
|
||||
import {appConfig} from "./config"
|
||||
import * as qs from "qs"
|
||||
|
||||
export let reqBody = 'sEcho=1&iColumns=15&sColumns=&iDisplayStart=0&iDisplayLength=2000&mDataProp_0=kch&mDataProp_1=kcmc&mDataProp_2=kxhnew&mDataProp_3=jkfs&mDataProp_4=xmmc&mDataProp_5=fzmc&mDataProp_6=ktmc&mDataProp_7=xf&mDataProp_8=skls&mDataProp_9=sksj&mDataProp_10=skdd&mDataProp_11=xqmc&mDataProp_12=syrs&mDataProp_13=ctsm&mDataProp_14=czOper'
|
||||
let errorCount = 0
|
||||
|
||||
export const JsonCourseList = <{ bx: IJsonCourse[], xx: IJsonCourse[], rx: IJsonCourse[] }>{
|
||||
bx: [],
|
||||
@ -16,7 +17,8 @@ async function updateBx() {
|
||||
let resp = await sduAxios.post('/jsxsd/xsxkkc/xsxkBxxk?1=1&kcxx=&skls=&skfs=&xqid=', reqBody)
|
||||
JsonCourseList.bx.length = 0
|
||||
JsonCourseList.bx.push(...resp.data.aaData)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
processError(_e as Error)
|
||||
console.log('获取必修JsonList失败 at ' + getTimeNow())
|
||||
}
|
||||
}
|
||||
@ -26,7 +28,8 @@ async function updateXx() {
|
||||
let resp = await sduAxios.post('/jsxsd/xsxkkc/xsxkXxxk?1=1&kcxx=&skls=&skfs=&xqid=', reqBody)
|
||||
JsonCourseList.xx.length = 0
|
||||
JsonCourseList.xx.push(...resp.data.aaData)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
processError(_e as Error)
|
||||
console.log('获取限选JsonList失败 at ' + getTimeNow())
|
||||
}
|
||||
}
|
||||
@ -36,7 +39,8 @@ async function updateRx() {
|
||||
let resp = await sduAxios.post('/jsxsd/xsxkkc/xsxkGgxxkxk?kcxx=&skls=&skxq=&skjc=&sfym=false&sfct=false&szjylb=&sfxx=true&skfs=&xqid=', reqBody)
|
||||
JsonCourseList.rx.length = 0
|
||||
JsonCourseList.rx.push(...resp.data.aaData)
|
||||
} catch (e) {
|
||||
} catch (_e) {
|
||||
processError(_e as Error)
|
||||
console.log('获取任选JsonList失败 at ' + getTimeNow())
|
||||
}
|
||||
}
|
||||
@ -56,3 +60,13 @@ export async function poll() {
|
||||
}
|
||||
setImmediate(poll)
|
||||
}
|
||||
|
||||
function processError(e: Error) {
|
||||
if (errorCount != -1) {
|
||||
errorCount++
|
||||
if (errorCount >= 30) {
|
||||
logAndNotifyUser('[error]出现轮询error过多,请检查。上一次异常信息:' + e.message)
|
||||
errorCount = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
載入中…
x
新增問題並參考
Block a user