main.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. import Xverse from "./Xverse.js"
  2. import Codes from "./enum/Codes.js"
  3. const xverse = new Xverse({
  4. env: "DEV",
  5. appId:"10016",
  6. releaseId:'2203120033_29769e'
  7. });
  8. const l = async()=>{
  9. var R;
  10. try {
  11. await ((R = xverse.preload) == null ? void 0 : R.start('full', (M,x)=>{
  12. const I = `(${M}/${x})`;
  13. //s(I)
  14. }
  15. ))
  16. } catch (M) {
  17. if (console.error(M),
  18. M.code === Codes.PreloadCanceled) {
  19. toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
  20. return
  21. }
  22. toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
  23. return
  24. }
  25. try {
  26. let room = await xverse.joinRoom({
  27. canvas: document.getElementById('canvas'),
  28. skinId: '10092',
  29. avatarId: 'KGe_Boy',
  30. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  31. userId: '1f7acca1db9d5',
  32. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  33. appId: "10016",
  34. token: " ",
  35. nickname: '1f7acca1db9d5',
  36. firends: ["user1"],
  37. viewMode: "full",
  38. resolution: {
  39. width: 1728,
  40. height: 720
  41. },
  42. pathName: 'thirdwalk',
  43. objectFit: null,
  44. hasAvatar: !0,
  45. syncToOthers: !0
  46. });
  47. window.room = room;
  48. u();
  49. c();
  50. //e(!1);
  51. } catch (M) {
  52. console.error(M);
  53. alert(M);
  54. return
  55. }
  56. }
  57. const u = ()=>{
  58. window.room.on("_coreClick", ({point: f})=>{
  59. window.room._userAvatar.moveTo({
  60. point: f
  61. })
  62. }
  63. )
  64. }
  65. const c = ()=>{
  66. window.room.on("repeatLogin", function() {
  67. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  68. duration: 1e4
  69. })
  70. }),
  71. window.room.on("reconnecting", function({count: f}) {
  72. toast(`\u5C1D\u8BD5\u7B2C${f}\u6B21\u91CD\u8FDE`)
  73. }),
  74. window.room.on("reconnected", function() {
  75. toast("\u91CD\u8FDE\u6210\u529F")
  76. }),
  77. window.room.on("disconnected", function() {
  78. const f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  79. duration: 1e5,
  80. onClick() {
  81. f.hideToast(),
  82. window.room.reconnect()
  83. }
  84. })
  85. })
  86. }
  87. l();