mirror of
https://github.com/MCSManager/MCSManager.git
synced 2025-01-12 14:54:34 +08:00
Optimize: async function
This commit is contained in:
parent
e5047cca17
commit
cc538f56be
@ -9,18 +9,13 @@ const props = defineProps<{
|
||||
value: string;
|
||||
}>();
|
||||
|
||||
const copy = () => {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard
|
||||
.writeText(props.value)
|
||||
.then(() => {
|
||||
message.success(t("复制成功"));
|
||||
})
|
||||
.catch((error) => {
|
||||
message.error(t("复制失败:") + error);
|
||||
});
|
||||
} else {
|
||||
message.error(t("您当前的浏览器不支持 Clipboard API"));
|
||||
const copy = async () => {
|
||||
if (!navigator.clipboard) return message.error(t("您当前的浏览器不支持 Clipboard API"));
|
||||
try {
|
||||
await navigator.clipboard.writeText(props.value);
|
||||
message.success(t("复制成功"));
|
||||
} catch (error) {
|
||||
message.error(t("复制失败:") + error);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user