|
@@ -13,39 +13,4 @@ export function timeStamp(StatusMinute, userCardType, nextSendTime) {
|
|
|
StatusMinute += parseFloat(min) + '分钟';
|
|
|
}
|
|
|
return StatusMinute.length ? StatusMinute : userCardType === 1 ? '0小时' : '';
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// 封装对剪贴板的访问为异步函数
|
|
|
-export function writeToClipboard(text, success = () => { }, error = () => { }) {
|
|
|
- // 如果navigator.clipboard存在,直接使用复制功能
|
|
|
- if (navigator.clipboard) {
|
|
|
- try {
|
|
|
- setTimeout(() => {
|
|
|
- navigator.clipboard.writeText(text).then(() => {
|
|
|
- success()
|
|
|
- }).catch((err) => {
|
|
|
- error()
|
|
|
- })
|
|
|
- }, 0);
|
|
|
- } catch (err) {
|
|
|
- error()
|
|
|
- }
|
|
|
- } else {
|
|
|
- const textArea = document.createElement('textarea');
|
|
|
- textArea.value = text;
|
|
|
- document.body.appendChild(textArea);
|
|
|
- textArea.select();
|
|
|
- try {
|
|
|
- const successful = document.execCommand('copy');
|
|
|
- if (successful) {
|
|
|
- success()
|
|
|
- } else {
|
|
|
- throw '复制失败'
|
|
|
- }
|
|
|
- } catch (err) {
|
|
|
- error()
|
|
|
- }
|
|
|
- document.body.removeChild(textArea);
|
|
|
- }
|
|
|
}
|