From 24ffb17746a29aaeae5a3f15407c51d303e038c3 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Fri, 8 Nov 2024 23:58:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=87=8D=E6=9E=84=20=E6=81=AF?= =?UTF-8?q?=E7=9F=A5=E6=8E=A8=E9=80=81=20=E5=88=B0=E6=96=B0=E7=89=88?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/push/dingtalk.ts | 3 +++ src/push/xi-zhi.ts | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/push/dingtalk.ts b/src/push/dingtalk.ts index 276328a..5f27c32 100644 --- a/src/push/dingtalk.ts +++ b/src/push/dingtalk.ts @@ -22,6 +22,9 @@ export interface DingtalkConfig { DINGTALK_SECRET?: string } +export interface DingtalkOption { +} + export interface DingtalkResponse { errcode: number errmsg: string diff --git a/src/push/xi-zhi.ts b/src/push/xi-zhi.ts index 9c74374..1c2bc35 100644 --- a/src/push/xi-zhi.ts +++ b/src/push/xi-zhi.ts @@ -5,6 +5,20 @@ import { SendResponse } from '@/interfaces/response' const Debugger = debug('push:xi-zhi') +export interface XiZhiConfig { + // 息知的 key,前往 https://xz.qqoq.net/#/index 获取 + XI_ZHI_KEY: string +} + +export interface XiZhiOption { +} + +export interface XiZhiResponse { + // 状态码,200 表示成功 + code: number + msg: string +} + /** * 息知 推送,官方文档:https://xz.qqoq.net/#/index * @@ -16,15 +30,17 @@ const Debugger = debug('push:xi-zhi') export class XiZhi implements Send { private XI_ZHI_KEY: string - constructor(XI_ZHI_KEY: string) { + constructor(config: XiZhiConfig) { + const { XI_ZHI_KEY } = config this.XI_ZHI_KEY = XI_ZHI_KEY Debugger('set XI_ZHI_KEY: "%s"', XI_ZHI_KEY) if (!this.XI_ZHI_KEY) { throw new Error('XI_ZHI_KEY 是必须的!') } } - async send(title: string, content: string = ''): Promise { - Debugger('title: "%s", content: "%s"', title, content) + + async send(title: string, desp?: string): Promise> { + Debugger('title: "%s", desp: "%s"', title, desp) return ajax({ url: `https://xizhi.qqoq.net/${this.XI_ZHI_KEY}.send`, method: 'POST', @@ -33,7 +49,7 @@ export class XiZhi implements Send { }, data: { title, - content, + content: desp, }, }) }