-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dc8232
commit cfff80b
Showing
4 changed files
with
50 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { AxiosResponse } from 'axios' | ||
import debug from 'debug' | ||
import { Send } from '../interfaces/send' | ||
import { ajax } from '@/utils/ajax' | ||
|
||
const Debugger = debug('push:xi-zhi') | ||
|
||
/** | ||
* 息知 推送,官方文档:https://xz.qqoq.net/#/index | ||
* | ||
* @author CaoMeiYouRen | ||
* @date 2022-02-18 | ||
* @export | ||
* @class XiZhi | ||
*/ | ||
export class XiZhi implements Send { | ||
private XI_ZHI_KEY: string | ||
|
||
constructor(XI_ZHI_KEY: string) { | ||
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<AxiosResponse<any>> { | ||
Debugger('title: "%s", content: "%s"', title, content) | ||
return ajax({ | ||
url: `https://xizhi.qqoq.net/${this.XI_ZHI_KEY}.send`, | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
data: { | ||
title, | ||
content, | ||
}, | ||
}) | ||
} | ||
} |