Meta2d.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <!-- -->
  2. <template>
  3. <div class="content">
  4. <div id="meta2d"></div>
  5. </div>
  6. </template>
  7. <script>
  8. let meta2d = null;
  9. export default {
  10. name: 'meta2d',
  11. data() {
  12. return {};
  13. },
  14. mounted() {
  15. this.initMeta2d();
  16. },
  17. destroyed() {
  18. meta2d?.destroy();
  19. },
  20. methods: {
  21. initMeta2d() {
  22. meta2d = new window.Meta2d("meta2d");
  23. window.registerCommonDiagram();
  24. this._fetch("/json/data.json", function (text) {
  25. var data = JSON.parse(text);
  26. data.locked = 1;
  27. meta2d.open(data);
  28. });
  29. },
  30. _fetch(url, cb) {
  31. var xhr = new XMLHttpRequest();
  32. xhr.open("GET", url, true);
  33. xhr.send();
  34. xhr.onreadystatechange = function () {
  35. if (xhr.readyState == 4 && xhr.status == 200) {
  36. cb && cb(xhr.responseText);
  37. }
  38. };
  39. },
  40. },
  41. };
  42. </script>
  43. <style>
  44. html,
  45. body {
  46. height: 100vh;
  47. margin: 0;
  48. padding: 0;
  49. }
  50. .content {
  51. position: relative;
  52. background-color: #f4f4f4;
  53. height: 100vh;
  54. }
  55. #meta2d {
  56. position: absolute !important;
  57. width: 100%;
  58. height: 100%;
  59. touch-action: none;
  60. overflow: hidden;
  61. }
  62. </style>