mirror of
https://github.com/ZiuChen/ClipboardManager.git
synced 2025-06-08 14:24:03 +08:00
feat: 移除对智慧分词的支持 减小插件体积 改为跳转插件
This commit is contained in:
parent
99edbaa907
commit
09468449fe
@ -7,15 +7,10 @@
|
|||||||
<div
|
<div
|
||||||
class="clip-full-operate-list-item"
|
class="clip-full-operate-list-item"
|
||||||
v-if="
|
v-if="
|
||||||
(id !== 'word-split' && id !== 'copy-select' && id !== 'clear-select') ||
|
id !== 'word-split' ||
|
||||||
(id === 'word-split' &&
|
(id === 'word-split' &&
|
||||||
fullData.type !== 'file' &&
|
fullData.type !== 'file' &&
|
||||||
fullData?.data?.length <= '\u0035\u0030\u0030' &&
|
fullData?.data?.length <= '\u0035\u0030\u0030')
|
||||||
splitWords.length === 0) ||
|
|
||||||
(id === 'copy-select' &&
|
|
||||||
splitWords.filter((item) => item.checked !== false).length !== 0) ||
|
|
||||||
(id === 'clear-select' &&
|
|
||||||
splitWords.filter((item) => item.checked !== false).length !== 0)
|
|
||||||
"
|
"
|
||||||
@click="handleBtnClick(id)"
|
@click="handleBtnClick(id)"
|
||||||
>
|
>
|
||||||
@ -29,10 +24,6 @@
|
|||||||
<div v-else-if="fullData.type === 'file'" class="clip-full-content">
|
<div v-else-if="fullData.type === 'file'" class="clip-full-content">
|
||||||
<FileList :data="JSON.parse(fullData.data)"></FileList>
|
<FileList :data="JSON.parse(fullData.data)"></FileList>
|
||||||
</div>
|
</div>
|
||||||
<ClipWordBreak
|
|
||||||
v-if="fullData.type === 'text' && splitWords.length !== 0"
|
|
||||||
:words="splitWords"
|
|
||||||
></ClipWordBreak>
|
|
||||||
</div>
|
</div>
|
||||||
</Transition>
|
</Transition>
|
||||||
<div class="clip-overlay" v-show="isShow" @click="onOverlayClick"></div>
|
<div class="clip-overlay" v-show="isShow" @click="onOverlayClick"></div>
|
||||||
@ -41,8 +32,7 @@
|
|||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import FileList from './FileList.vue'
|
import FileList from './FileList.vue'
|
||||||
import ClipWordBreak from './ClipWordBreak.vue'
|
import { onMounted } from 'vue'
|
||||||
import { ref, onMounted } from 'vue'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
isShow: {
|
isShow: {
|
||||||
@ -65,19 +55,9 @@ const btns = [
|
|||||||
{
|
{
|
||||||
id: 'word-split',
|
id: 'word-split',
|
||||||
name: '🎁 智慧分词'
|
name: '🎁 智慧分词'
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'copy-select',
|
|
||||||
name: '📑 复制选中'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'clear-select',
|
|
||||||
name: '💣 清空选中'
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const splitWords = ref([])
|
|
||||||
|
|
||||||
const handleBtnClick = (id) => {
|
const handleBtnClick = (id) => {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 'copy-all':
|
case 'copy-all':
|
||||||
@ -86,71 +66,14 @@ const handleBtnClick = (id) => {
|
|||||||
window.toTop()
|
window.toTop()
|
||||||
break
|
break
|
||||||
case 'word-split':
|
case 'word-split':
|
||||||
fetchWordBreakResult(props.fullData.data)
|
utools.redirect('超级分词', props.fullData.data)
|
||||||
break
|
// fetchWordBreakResult(props.fullData.data)
|
||||||
case 'copy-select':
|
|
||||||
const checkedList = splitWords.value.filter((item) => item.checked !== false)
|
|
||||||
if (checkedList.length !== 0) {
|
|
||||||
window.copy({
|
|
||||||
type: 'text',
|
|
||||||
data: checkedList.map((item) => item.value).join('')
|
|
||||||
})
|
|
||||||
emit('onOverlayClick')
|
|
||||||
window.toTop()
|
|
||||||
} else {
|
|
||||||
window.showNotify('尚未选中任何内容')
|
|
||||||
}
|
|
||||||
break
|
|
||||||
case 'clear-select':
|
|
||||||
splitWords.value.map((item) => (item.checked = false))
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchUserInfo = async () => {
|
|
||||||
return window.fetchToken().then(({ token, expired_at }) => {
|
|
||||||
return {
|
|
||||||
token,
|
|
||||||
expired_at
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const fetchWordBreakResult = async (origin) => {
|
|
||||||
const baseUrl = 'https://service-nlkfov43-1304937021.sh.apigw.tencentcs.com/release'
|
|
||||||
// const baseUrl = 'http://localhost:9000'
|
|
||||||
const url = baseUrl + '/v1/word-break'
|
|
||||||
const info = await fetchUserInfo()
|
|
||||||
return fetch(url, {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json'
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
domain: 'clipboard-manager',
|
|
||||||
word: origin,
|
|
||||||
...info
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.then((res) => res.json())
|
|
||||||
.then(({ code, data, msg }) => {
|
|
||||||
if (code !== 0) {
|
|
||||||
window.showNotify(msg)
|
|
||||||
} else {
|
|
||||||
// 请求成功 才算一次
|
|
||||||
splitWords.value = data.splitWord
|
|
||||||
.filter((w) => w !== '' && w !== ' ' && w.indexOf('\n') === -1)
|
|
||||||
.map((item) => ({
|
|
||||||
value: item,
|
|
||||||
checked: false
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const onOverlayClick = () => {
|
const onOverlayClick = () => {
|
||||||
emit('onOverlayClick')
|
emit('onOverlayClick')
|
||||||
splitWords.value = []
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user