Meta2d.vue 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <div class="content">
  3. <div id="meta2d"></div>
  4. </div>
  5. </template>
  6. <script lang="ts" setup>
  7. import { onMounted, onUnmounted } from 'vue';
  8. let meta2d: any = null;
  9. onMounted(async () => {
  10. meta2d = new (window as any).Meta2d('meta2d');
  11. (window as any).registerCommonDiagram();
  12. _fetch('/json/data.json', function (text) {
  13. var data = JSON.parse(text);
  14. data.locked = 1;
  15. meta2d.open(data);
  16. });
  17. });
  18. function _fetch(url, cb) {
  19. var xhr = new XMLHttpRequest();
  20. xhr.open('GET', url, true);
  21. xhr.send();
  22. xhr.onreadystatechange = function () {
  23. if (xhr.readyState == 4 && xhr.status == 200) {
  24. cb && cb(xhr.responseText);
  25. }
  26. };
  27. }
  28. onUnmounted(() => {
  29. meta2d?.destroy();
  30. });
  31. </script>
  32. <style lang="scss" scoped>
  33. html,
  34. body {
  35. height: 100vh;
  36. margin: 0;
  37. padding: 0;
  38. }
  39. .content {
  40. position: relative;
  41. background-color: #f4f4f4;
  42. height: 100vh;
  43. #meta2d {
  44. position: absolute !important;
  45. width: 100%;
  46. height: 100%;
  47. touch-action: none;
  48. overflow: hidden;
  49. }
  50. }
  51. </style>