mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
Merge branch 'pipipi-pikachu:master' into master
This commit is contained in:
commit
66c3718998
@ -1,6 +1,6 @@
|
|||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { MutationTypes, useStore } from '@/store'
|
import { MutationTypes, useStore } from '@/store'
|
||||||
import { decrypt } from '@/utils/crypto'
|
import { pasteCustomClipboardString } from '@/utils/clipboard'
|
||||||
import { PPTElement, Slide } from '@/types/slides'
|
import { PPTElement, Slide } from '@/types/slides'
|
||||||
import { createRandomCode } from '@/utils/common'
|
import { createRandomCode } from '@/utils/common'
|
||||||
import { createElementIdMap } from '@/utils/element'
|
import { createElementIdMap } from '@/utils/element'
|
||||||
@ -93,13 +93,7 @@ export default () => {
|
|||||||
const onlySlide = options?.onlySlide || false
|
const onlySlide = options?.onlySlide || false
|
||||||
const onlyElements = options?.onlyElements || false
|
const onlyElements = options?.onlyElements || false
|
||||||
|
|
||||||
let clipboardData
|
const clipboardData = pasteCustomClipboardString(text)
|
||||||
try {
|
|
||||||
clipboardData = JSON.parse(decrypt(text))
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
clipboardData = text
|
|
||||||
}
|
|
||||||
|
|
||||||
// 元素或页面
|
// 元素或页面
|
||||||
if (typeof clipboardData === 'object') {
|
if (typeof clipboardData === 'object') {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Clipboard from 'clipboard'
|
import Clipboard from 'clipboard'
|
||||||
|
import { decrypt } from '@/utils/crypto'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 复制文本到剪贴板
|
* 复制文本到剪贴板
|
||||||
@ -38,3 +39,16 @@ export const readClipboard = (): Promise<string> => {
|
|||||||
else reject('浏览器不支持或禁止访问剪贴板,请使用快捷键 Ctrl + V')
|
else reject('浏览器不支持或禁止访问剪贴板,请使用快捷键 Ctrl + V')
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 解析加密后的剪贴板内容
|
||||||
|
export const pasteCustomClipboardString = (text: string) => {
|
||||||
|
let clipboardData
|
||||||
|
try {
|
||||||
|
clipboardData = JSON.parse(decrypt(text))
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
clipboardData = text
|
||||||
|
}
|
||||||
|
|
||||||
|
return clipboardData
|
||||||
|
}
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, onUnmounted, ref, watch } from 'vue'
|
import { defineComponent, onUnmounted, ref, watch } from 'vue'
|
||||||
|
import { pasteCustomClipboardString } from '@/utils/clipboard'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'custom-textarea',
|
name: 'custom-textarea',
|
||||||
@ -56,7 +57,12 @@ export default defineComponent({
|
|||||||
const clipboardDataFirstItem = e.clipboardData.items[0]
|
const clipboardDataFirstItem = e.clipboardData.items[0]
|
||||||
|
|
||||||
if (clipboardDataFirstItem && clipboardDataFirstItem.kind === 'string' && clipboardDataFirstItem.type === 'text/plain') {
|
if (clipboardDataFirstItem && clipboardDataFirstItem.kind === 'string' && clipboardDataFirstItem.type === 'text/plain') {
|
||||||
clipboardDataFirstItem.getAsString(text => emit('updateValue', text))
|
clipboardDataFirstItem.getAsString(text => {
|
||||||
|
const clipboardData = pasteCustomClipboardString(text)
|
||||||
|
if (typeof clipboardData === 'object') return
|
||||||
|
emit('updateValue', text)
|
||||||
|
document.execCommand('insertText', false, text)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user