提交 7bcf3851 authored 作者: GOD_ZYX's avatar GOD_ZYX

update

上级 eea32e02
...@@ -92,19 +92,19 @@ const agentProcessor = () => { ...@@ -92,19 +92,19 @@ const agentProcessor = () => {
axios.defaults.headers = headers axios.defaults.headers = headers
axios.defaults.withCredentials = true axios.defaults.withCredentials = true
/* 日志记录,重新修改 2019.01.17 */ /* 日志记录,重新修改 2019.01.17 */
let _log = { // let _log = {
reqTime: timestamp, // 请求时长 // reqTime: timestamp, // 请求时长
sys: req.headers['tenant'], // 系统 // sys: req.headers['tenant'], // 系统
status: '', // 请求状态 // status: '', // 请求状态
name: req.headers['cur-name'], // 姓名 // name: req.headers['cur-name'], // 姓名
auth: req.headers['cur-auth'], // 账号 // auth: req.headers['cur-auth'], // 账号
IP: '', // IP值 // IP: '', // IP值
uuid: uuid, // uuid // uuid: uuid, // uuid
url: options.url, // 请求地址 // url: options.url, // 请求地址
type: '', // 1:视频 2:课后作业 3:作业内容 // type: '', // 1:视频 2:课后作业 3:作业内容
self: '', // 根据类型值,自定义 字符串参数 // self: '', // 根据类型值,自定义 字符串参数
param: JSON.stringify(options) // 请求参数 JSON str // param: JSON.stringify(options) // 请求参数 JSON str
} // }
/* 兼容老版本,登录接口 清除_SUP; 退出登录 清除_SUP */ /* 兼容老版本,登录接口 清除_SUP; 退出登录 清除_SUP */
if (/tenant\/user\/login/gi.test(options.url) || /tenant\/user\/code-login/gi.test(options.url) || /v3\/sso\/logout/gi.test(options.url)) { if (/tenant\/user\/login/gi.test(options.url) || /tenant\/user\/code-login/gi.test(options.url) || /v3\/sso\/logout/gi.test(options.url)) {
...@@ -112,33 +112,34 @@ const agentProcessor = () => { ...@@ -112,33 +112,34 @@ const agentProcessor = () => {
} }
/* 重新转发请求 */ /* 重新转发请求 */
axios(options).then((data) => { axios(options).then((data) => {
_log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms' // _log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms'
_log.status = 200 // _log.status = 200
setPorxyHeader(data, res) setPorxyHeader(data, res)
res.status(200).send(data.data) res.status(200).send(data.data)
}).catch((e) => { }).catch((e) => {
_log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms' // _log.reqTime = (new Date().getTime() - _log.reqTime) + 'ms'
_log.status = e.response.status || 500 // _log.status = e.response.status || 500
/* 返回执行代码出错 或者 服务器请求错误 */ /* 返回执行代码出错 或者 服务器请求错误 */
if (e.response && e.response.data) { if (e.response && e.response.data) {
/* 如果未登录 强制 弹出到 登录页 */ /* 如果未登录 强制 弹出到 登录页 */
setPorxyHeader(e.response, res) setPorxyHeader(e.response, res)
res.status(e.response.status).json(e.response.data) res.status(e.response.status).json(e.response.data)
console.error(uuid + '\\001' + JSON.stringify(options) + '\\001' + JSON.stringify(e.response)) // console.error(uuid + '\\001' + JSON.stringify(options) + '\\001' + JSON.stringify(e.response))
} else { } else {
res.status(500).json({ message: '系统错误,请稍后重试或联系管理员', errMsg: 'Error Proxy Request or BackData Excute Error', code: 500 }) res.status(500).json({ message: '系统错误,请稍后重试或联系管理员', errMsg: 'Error Proxy Request or BackData Excute Error', code: 500 })
console.error(uuid, e) // console.error(uuid, e)
}
}).finally(() => {
let _str = ''
for (let key in _log) {
_str += _log[key] + '\\001'
} }
console.log(_str + 'end')
}) })
// finally(() => {
// let _str = ''
// for (let key in _log) {
// _str += _log[key] + '\\001'
// }
// console.log(_str + 'end')
// })
} catch (e) { } catch (e) {
res.status(500).json({ message: '系统错误,请稍后重试或联系管理员', errMsg: 'Network Server Excute Error', code: 500 }) res.status(500).json({ message: '系统错误,请稍后重试或联系管理员', errMsg: 'Network Server Excute Error', code: 500 })
console.error('system error:', uuid, e) // console.error('system error:', uuid, e)
} }
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论