From b34107a64d5e2787a6e6583ee1b789b41fb13907 Mon Sep 17 00:00:00 2001 From: ZiuChen <457353192@qq.com> Date: Wed, 7 Sep 2022 09:56:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=99=BA=E6=85=A7=E5=88=86=E8=AF=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/cpns/ClipFullData.vue | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/cpns/ClipFullData.vue b/src/cpns/ClipFullData.vue index 5453575..5d99aef 100644 --- a/src/cpns/ClipFullData.vue +++ b/src/cpns/ClipFullData.vue @@ -60,11 +60,46 @@ const handleBtnClick = (id) => { emit('onOverlayClick') // 退出侧栏 break case 'word-split': - window.alert('增值服务 Comming Soon...') + // TODO: 限制文字长度 (前后端都限制) + // TODO: 限制请求频率 (前后端都限制) + fetchWordBreakResult(props.fullData.data) break } } +const fetchUserInfo = async () => { + return utools.fetchUserServerTemporaryToken().then(({ token, expired_at }) => { + return { + token, + expired_at + } + }) +} + +const fetchWordBreakResult = async (origin) => { + const url = 'https://service-a0pyrkub-1304937021.sh.apigw.tencentcs.com/release/v1/word-break' + const info = await fetchUserInfo() + console.log(info) + return fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + word: origin + }) + }) + .then((res) => res.json()) + .then(({ code, data, msg }) => { + if (code !== 0) { + console.log(msg) + } else { + console.log(data.splitWord) + console.log(data.extractWord) + } + }) +} + onMounted(() => { document.addEventListener('keydown', (e) => { const { key } = e