修改全局复制方法

This commit is contained in:
A1300399510
2023-07-27 12:12:21 +08:00
parent 107b6a241e
commit ad303096ca
2 changed files with 21 additions and 6 deletions

View File

@@ -20,11 +20,23 @@ function goTologin() {
function copyToClipboard(text) { function copyToClipboard(text) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
navigator.clipboard.writeText(text).then(() => { const textareaEle = document.createElement("textarea");
resolve() document.body.appendChild(textareaEle);
}).catch((err) => { // 2. 将需要复制的文本传入输入框, 并调用 select 方法, 选中输入框中文本
reject() textareaEle.value = text;
}); textareaEle.select();
textareaEle.readOnly = 'readOnly';
// 3. 调用复制选中文本的方法
document.execCommand('copy');
// 4. 销毁输入框
document.body.removeChild(textareaEle);
resolve()
// navigator.clipboard.writeText(text).then(() => {
// resolve()
// }).catch((err) => {
// reject()
// });
}); });
} }

View File

@@ -37,7 +37,7 @@
<div class="operate-text">发布房源</div> <div class="operate-text">发布房源</div>
<choosing-identity></choosing-identity> <choosing-identity></choosing-identity>
</div> </div>
<template v-if="user.identity != 0"> <template v-if="user['aid'] && user.identity != 0">
<img class="" src="@/assets/img/publicImage/cut-off-rule.svg"> <img class="" src="@/assets/img/publicImage/cut-off-rule.svg">
<el-popover placement="bottom" :width="360" trigger="hover" :show-arrow="false" <el-popover placement="bottom" :width="360" trigger="hover" :show-arrow="false"
popper-style="background: transparent;padding:0;box-shadow: none;border: none;"> popper-style="background: transparent;padding:0;box-shadow: none;border: none;">
@@ -292,6 +292,8 @@ const handleDelete = (index, status) => {
// 监听滚动到底部 // 监听滚动到底部
const handleScroll = () => { const handleScroll = () => {
// console.log(user.value, "user");
if (!user.value['aid']) return
const scrollHeight = document.documentElement.scrollHeight; const scrollHeight = document.documentElement.scrollHeight;
const clientHeight = document.documentElement.clientHeight; const clientHeight = document.documentElement.clientHeight;
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop; const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
@@ -529,6 +531,7 @@ onUnmounted(() => {
align-items: center; align-items: center;
border-radius: 16px; border-radius: 16px;
} }
.bottom-tps { .bottom-tps {
font-weight: 400; font-weight: 400;
font-size: 14px; font-size: 14px;