mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-30 14:12:52 +08:00
feat: 智慧分词功能初始化
This commit is contained in:
parent
cfd6585828
commit
b34107a64d
@ -60,11 +60,46 @@ const handleBtnClick = (id) => {
|
|||||||
emit('onOverlayClick') // 退出侧栏
|
emit('onOverlayClick') // 退出侧栏
|
||||||
break
|
break
|
||||||
case 'word-split':
|
case 'word-split':
|
||||||
window.alert('增值服务 Comming Soon...')
|
// TODO: 限制文字长度 (前后端都限制)
|
||||||
|
// TODO: 限制请求频率 (前后端都限制)
|
||||||
|
fetchWordBreakResult(props.fullData.data)
|
||||||
break
|
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(() => {
|
onMounted(() => {
|
||||||
document.addEventListener('keydown', (e) => {
|
document.addEventListener('keydown', (e) => {
|
||||||
const { key } = e
|
const { key } = e
|
||||||
|
Loading…
x
Reference in New Issue
Block a user