mirror of
https://github.com/pipipi-pikachu/PPTist.git
synced 2025-04-15 02:20:00 +08:00
perf: 代码优化
This commit is contained in:
parent
b59aa88e4b
commit
e3ba935dd6
@ -1,6 +1,6 @@
|
||||
import { computed } from 'vue'
|
||||
import { MutationTypes, useStore } from '@/store'
|
||||
import { decrypt } from '@/utils/crypto'
|
||||
import { pasteCustomClipboardString } from '@/utils/clipboard'
|
||||
import { PPTElement, Slide } from '@/types/slides'
|
||||
import { createRandomCode } from '@/utils/common'
|
||||
import { createElementIdMap } from '@/utils/element'
|
||||
@ -93,13 +93,7 @@ export default () => {
|
||||
const onlySlide = options?.onlySlide || false
|
||||
const onlyElements = options?.onlyElements || false
|
||||
|
||||
let clipboardData
|
||||
try {
|
||||
clipboardData = JSON.parse(decrypt(text))
|
||||
}
|
||||
catch {
|
||||
clipboardData = text
|
||||
}
|
||||
const clipboardData = pasteCustomClipboardString(text)
|
||||
|
||||
// 元素或页面
|
||||
if (typeof clipboardData === 'object') {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import Clipboard from 'clipboard'
|
||||
import { decrypt } from '@/utils/crypto'
|
||||
|
||||
/**
|
||||
* 复制文本到剪贴板
|
||||
@ -37,4 +38,17 @@ export const readClipboard = (): Promise<string> => {
|
||||
}
|
||||
else reject('浏览器不支持或禁止访问剪贴板,请使用快捷键 Ctrl + V')
|
||||
})
|
||||
}
|
||||
|
||||
// 解析加密后的剪贴板内容
|
||||
export const pasteCustomClipboardString = (text: string) => {
|
||||
let clipboardData
|
||||
try {
|
||||
clipboardData = JSON.parse(decrypt(text))
|
||||
}
|
||||
catch {
|
||||
clipboardData = text
|
||||
}
|
||||
|
||||
return clipboardData
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user