main.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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:'2203181838_1375a0'
  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. let nickname = Math.random().toString(16).slice(2)
  26. try {
  27. let room = await xverse.joinRoom({
  28. canvas: document.getElementById('canvas'),
  29. skinId: '10089',
  30. avatarId: 'KGe_Boy',
  31. roomId: 'e629ef3e-022d-4e64-8654-703bb96410eb',
  32. userId: nickname,
  33. wsServerUrl: 'wss://uat-eks.xverse.cn/ws',
  34. // wsServerUrl: "ws://localhost:6688/ws",
  35. //wsServerUrl: "wss://meta-socket.4dage.com/ws",
  36. appId: "10016",
  37. token: " ",
  38. nickname: nickname,
  39. firends: ["user1"],
  40. viewMode: "full",
  41. resolution: {
  42. width: 1728,
  43. height: 720
  44. },
  45. pathName: 'thirdwalk',
  46. objectFit: null,
  47. hasAvatar: !0,
  48. syncToOthers: !0
  49. });
  50. window.room = room;
  51. u();
  52. c();
  53. //e(!1);
  54. } catch (M) {
  55. console.error(M);
  56. alert(M);
  57. return
  58. }
  59. }
  60. const u = ()=>{
  61. window.room.on("_coreClick", ({point: f})=>{
  62. window.room._userAvatar.moveTo({
  63. point: f
  64. })
  65. }
  66. )
  67. }
  68. const c = ()=>{
  69. window.room.on("repeatLogin", function() {
  70. toast("\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55", {
  71. duration: 1e4
  72. })
  73. }),
  74. window.room.on("reconnecting", function({count: f}) {
  75. toast(`\u5C1D\u8BD5\u7B2C${f}\u6B21\u91CD\u8FDE`)
  76. }),
  77. window.room.on("reconnected", function() {
  78. toast("\u91CD\u8FDE\u6210\u529F")
  79. }),
  80. window.room.on("disconnected", function() {
  81. const f = toast("\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5", {
  82. duration: 1e5,
  83. onClick() {
  84. f.hideToast(),
  85. window.room.reconnect()
  86. }
  87. })
  88. })
  89. }
  90. l();