You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
bililive_webapp/src/request.ts

59 lines
1.6 KiB

import {changeEmailApi, changePwdApi, sendCodeApi, telegramBotApi, testTelegramBotApi} from "./interface";
// @ts-ignore
import {Message} from 'element3/src/components/Message'
/**
* 发送验证码
* @param userEmail
*/
export function sendCode(userEmail: string) {
return fetch(new Request(sendCodeApi, {method: 'POST', body: JSON.stringify({userEmail})}))
}
/**
* 更换邮箱
* @param oldEmail
* @param newEmail
* @param code
*/
export function changeEmail(oldEmail: string, newEmail: string, code: string) {
return fetch(new Request(changeEmailApi, {method: 'POST', body: JSON.stringify({oldEmail, newEmail, code})}))
}
/**
* 更换密码
* @param userEmail
* @param password
*/
export function changePwd(userEmail: string, password: string) {
return fetch(new Request(changePwdApi, {method: 'POST', body: JSON.stringify({userEmail, password})}))
}
/**
* 获取telegram bot
* @param userEmail
*/
export function getTelegramBot(userEmail: string) {
return fetch(new Request(`${telegramBotApi}?userEmail=${userEmail}`))
}
/**
* 测试机器人token
* @param token
*/
export function testTelegramBot(token: string) {
return fetch(new Request(testTelegramBotApi(token)))
}
export function bindTelegramBot(userEmail: string, token: string) {
return fetch(new Request(telegramBotApi), {method: 'POST', body: JSON.stringify({userEmail, token})})
}
export function message(res: any) {
new Message({
showClose: true,
duration: 3000,
message: res.message,
type: res.result === 'OK' ? 'success' : 'error'
})
}