Utils.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { sys } from "cc";
  2. import { Config, nav_info } from "./NavInfo";
  3. export class Utils {
  4. public static copyToZone(str: string) {
  5. let input:any = document.createElement("input");
  6. let currentFocus:any = document.activeElement;
  7. document.body.appendChild(input);
  8. input.readOnly = 'readonly';
  9. input.value = str;
  10. input.focus();
  11. if (input.setSelectionRange)
  12. input.setSelectionRange(0, input.value.length);
  13. else
  14. input.select();
  15. let flag = true;
  16. try {
  17. document.execCommand("copy");
  18. }
  19. catch (eo) {
  20. flag = false;
  21. }
  22. input.blur();
  23. document.body.removeChild(input);
  24. currentFocus.focus();
  25. currentFocus.blur();
  26. return flag;
  27. }
  28. public static tryStartApp() {
  29. if(!sys.isMobile){
  30. // nav_info.scene.showTip("")
  31. return;
  32. }
  33. console.log("openSrc =", Config.scheme_prefix);
  34. window.location.href = Config.scheme_prefix;
  35. setTimeout(function () {
  36. if (!document.hidden) {
  37. let down_url = sys.platform == sys.Platform.IOS ? Config.download_ios_url : Config.downlaod_google_url;
  38. window.location.href = down_url;
  39. }
  40. }, 4000);
  41. }
  42. }