当前位置: 首页 > news >正文

VUE 集成企微机器人通知

message-robot

在这里插入图片描述

便于线上异常问题及时发现处理,项目中集成企微机器人通知,及时接收问题并处理

企微机器人通知工具类

export class MessageRobotUtil {constructor() {}/*** 发送 markdown 消息* @param robotKey 机器人 ID* @param title 消息标题* @param items 消息内容*/public sendMarkdownMessage(robotKey: string, title: string, items: Record<string, string>) {const content = this.generateMarkdownMessageContent(title, items);this.sendMessage(robotKey, {msgtype: "markdown",markdown: { content: content },});}/*** 构建 markdown 消息内容* @param title 消息标题* @param items 消息内容 键值对* @returns*/private generateMarkdownMessageContent(title: string, items: Record<string, any>) {let content = `### 【${title}】`;content += "\n";for (const key in items) {content += `> ${key}: <font color="warning">${items[key]}</font>\n`;}return content;}/*** 消息发送* @param robotKey 机器人 ID* @param message 消息内容*/private sendMessage(robotKey: string, message: Record<string, any>) {// 跟地址 https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=****const url = "/cgi-bin/webhook/send?key=" + robotKey;fetch(url, {method: "POST",headers: {"Content-Type": "application/json",},body: JSON.stringify(message),});}
}
http://www.lryc.cn/news/534281.html

相关文章:

  • 《Java核心技术 卷II》Java平台的脚本机制
  • Ollama + AnythingLLM + Deepseek r1 实现本地知识库
  • 记录 | WPF基础学习Style局部和全局调用
  • PromptSource安装报错
  • Leetcode 3448. Count Substrings Divisible By Last Digit
  • Maven 下载与配置教程:附百度网盘地址
  • 基于 GEE 的网格化降雨数据可视化与时间序列分析
  • java-初识List
  • windows下搭建tftp服务器+网络启动Linux
  • DeepSeek使用技巧大全(含本地部署教程)
  • PHP 面向对象编程详解
  • openbmc web/redfish到底层设计(持续更新...)
  • Linux init
  • Maven 版本管理与 SNAPSHOT 详解
  • TCP三次握手全方面详解
  • 【C#】一维、二维、三维数组的使用
  • MIT开源7B推理模型Satori:用行动思维链进行强化学习,增强自回归搜索
  • 【JVM详解二】常量池
  • w200基于spring boot的个人博客系统的设计与实现
  • 【算法】快速排序算法的实现:C 和 C++ 版本
  • 前沿科技一览未来发展趋势
  • js滚动到页面最底部
  • 视觉硬件选型和算法选择(CNN)
  • Mybatis篇
  • 【Python】元组
  • 【AI实践】deepseek支持升级git
  • 【AI实践】Cursor上手-跑通Hello World和时间管理功能
  • Redis数据库(二):Redis 常用的五种数据结构
  • 【计组】实验五 J型指令设计实验
  • ubuntu 本地部署deepseek r1 蒸馏模型