import { sys } from "cc"; import { Config, nav_info } from "./NavInfo"; export class Utils { public static copyToZone(str: string, target:any, func:Function) { // let input:any = document.createElement("input"); // let currentFocus:any = document.activeElement; // document.body.appendChild(input); // input.readOnly = 'readonly'; // input.value = str; // input.focus(); // if (input.setSelectionRange) // input.setSelectionRange(0, input.value.length); // else // input.select(); // let flag = true; // try { // document.execCommand("copy"); // } // catch (eo) { // flag = false; // } // input.blur(); // document.body.removeChild(input); // currentFocus.focus(); // currentFocus.blur(); // return flag; if (!navigator.clipboard) { // 如果当前浏览器不支持 Clipboard API,则使用 execCommand 方法 var textArea = document.createElement("textarea"); textArea.value = str; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.select(); let flag = true; try { document.execCommand("copy"); } catch (err) { flag = false; } func.call(target, flag); document.body.removeChild(textArea); return; } navigator.clipboard.writeText(str) .then(() => { func.call(target, true); }) .catch((err) => { func.call(target, false); }); } public static tryStartApp() { if(!sys.isMobile){ // nav_info.scene.showTip("") return; } console.log("openSrc =", Config.scheme_prefix); window.location.href = Config.scheme_prefix; setTimeout(function () { console.log("--------timeout") if (!document.hidden) { let down_url = sys.os == sys.OS.IOS ? Config.download_ios_url : Config.downlaod_google_url; console.log("hide-------", down_url) window.location.href = down_url; } }, 4000); } }