feat: 增加复制功能

This commit is contained in:
pixelmaxQM
2025-04-07 17:31:31 +08:00
parent 5a53da62e3
commit 07c9e97bf5

View File

@@ -70,6 +70,8 @@ import { createWeb
} from '@/api/autoCode' } from '@/api/autoCode'
import {ref} from 'vue' import {ref} from 'vue'
import WarningBar from '@/components/warningBar/warningBar.vue' import WarningBar from '@/components/warningBar/warningBar.vue'
import { ElMessage } from 'element-plus'
defineOptions({ defineOptions({
name: 'Picture' name: 'Picture'
@@ -91,6 +93,24 @@ const handleKeydown = (event) => {
} }
} }
// 复制方法:把某个字符串写进剪贴板
const copySnippet = (htmlString) => {
navigator.clipboard.writeText(htmlString)
.then(() => {
ElMessage({
message: '复制成功',
type: 'success',
})
})
.catch(err => {
ElMessage({
message: '复制失败',
type: 'warning',
})
})
}
const prompt = ref('') const prompt = ref('')
// 判断是否返回的标志 // 判断是否返回的标志