55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
|
import request from "@/config/request.js";
|
||
|
import requesta from "@/config/requesta.js";
|
||
|
|
||
|
export function xuiat(data) {
|
||
|
return request.post(`xun_fei/tts`, data);
|
||
|
}
|
||
|
|
||
|
export function feiiat(data) {
|
||
|
return request.post(`xun_fei/iat`, data);
|
||
|
}
|
||
|
|
||
|
export function iatWss(data) {
|
||
|
return request.post(`xun_fei/iatWss`, data);
|
||
|
}
|
||
|
// http://chat.lihaink.cn/index/tts
|
||
|
//文字转语音
|
||
|
export function ttWss(data) {
|
||
|
return requesta.post(`index/tts`, data);
|
||
|
}
|
||
|
|
||
|
// -防抖
|
||
|
export function debounce(fn, wait) {
|
||
|
let delay = wait || 500
|
||
|
let timer
|
||
|
return function() {
|
||
|
let args = arguments;
|
||
|
if (timer) {
|
||
|
clearTimeout(timer)
|
||
|
console.log('拦截')
|
||
|
}
|
||
|
let callNow = !timer
|
||
|
timer = setTimeout(() => {
|
||
|
console.log('发送')
|
||
|
timer = null
|
||
|
}, delay)
|
||
|
if (callNow) fn.apply(this, args)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// -节流
|
||
|
export function throttle(fn, wait) {
|
||
|
let delay = wait || 500
|
||
|
let timer = null
|
||
|
return function() {
|
||
|
if (timer) {
|
||
|
console.log('拦截');
|
||
|
return
|
||
|
}
|
||
|
timer = setTimeout(() => {
|
||
|
console.log('发送');
|
||
|
fn.apply(this, arguments)
|
||
|
timer = null
|
||
|
}, delay)
|
||
|
}
|
||
|
}
|