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 38 39 40 41 42 43 44
| export function ding1ding(response: AxiosResponse) { if (process.env.NODE_ENV !== "production") { const Notification = require("element-ui").Notification; const accessToken = "xxxxx" let atMobiles = [ "13xxxxxxxxx", "18xxxxxxxxx", ]; let data: Record<string, any> = {}; if (response.config.data instanceof FormData) { response.config.data.forEach((value, key) => { data[key] = value; }); } else { data = response.config.data || {}; } let notice = Notification.warning({ title: "接口报错: " + response.config.url, message: "是否Ding一下?", offset: 200, onClick() { axios .post(`/dingding-api?access_token=${accessToken}`, { msgtype: "markdown", markdown: { title: "接口报警", text: `# 接口报警:${response.config.url} \n### 当前环境:${response.config.baseURL} \n > 请求状态:${response.status} \n\n### 参数:\n\n${JSON.stringify(data)} \n\n### 请求头: \n\n${JSON.stringify(response.headers)} \n\n### 返回结果:\n\n \`\`\`${JSON.stringify(response.data)}\`\`\` \n ### 项目关联人:\n@${atMobiles.join(" @")}`, }, at: { atMobiles, isAll: false, }, }) .then(() => { notice.close(); }); }, }); } }
|