mirror of
https://github.com/yudaocode/yudao-ui-admin-vue3.git
synced 2026-05-12 19:01:11 +00:00
【功能优化】IOT:枚举和复制到剪贴板方法优化
This commit is contained in:
@@ -53,16 +53,14 @@ const openForm = (type: string, id?: number) => {
|
||||
const { product, device } = defineProps<{ product: ProductVO; device: DeviceVO }>()
|
||||
const emit = defineEmits(['refresh'])
|
||||
|
||||
/**
|
||||
* 将文本复制到剪贴板
|
||||
*
|
||||
* @param text 需要复制的文本
|
||||
*/
|
||||
const copyToClipboard = (text: string) => {
|
||||
// TODO @haohao:可以考虑用 await 异步转同步哈
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
/** 复制到剪贴板方法 */
|
||||
const copyToClipboard = async (text: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
message.success('复制成功')
|
||||
})
|
||||
} catch (error) {
|
||||
message.error('复制失败')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -100,10 +100,13 @@ const mqttParams = ref({
|
||||
}) // 定义 MQTT 参数对象
|
||||
|
||||
/** 复制到剪贴板方法 */
|
||||
const copyToClipboard = (text: string) => {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
const copyToClipboard = async (text: string) => {
|
||||
try {
|
||||
await navigator.clipboard.writeText(text)
|
||||
message.success('复制成功')
|
||||
})
|
||||
} catch (error) {
|
||||
message.error('复制失败')
|
||||
}
|
||||
}
|
||||
|
||||
/** 打开 MQTT 参数弹框的方法 */
|
||||
|
||||
Reference in New Issue
Block a user