Debug.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <script setup lang="ts">
  2. import { ref, watch, reactive } from 'vue'
  3. import { useData } from '../data'
  4. const data = useData()
  5. const el = ref<HTMLElement | null>(null)
  6. const open = ref(false)
  7. // FIXME: remove in next Vue release
  8. const tempData = reactive(data)
  9. watch(open, (value) => {
  10. if (!value) {
  11. el.value!.scrollTop = 0
  12. }
  13. })
  14. </script>
  15. <template>
  16. <div class="debug" :class="{ open }" ref="el" @click="open = !open">
  17. <p class="title">Debug</p>
  18. <pre class="block">{{ tempData }}</pre>
  19. </div>
  20. </template>
  21. <style scoped>
  22. .debug {
  23. box-sizing: border-box;
  24. position: fixed;
  25. right: 8px;
  26. bottom: 8px;
  27. z-index: 9999;
  28. border-radius: 4px;
  29. width: 74px;
  30. height: 32px;
  31. color: #eeeeee;
  32. overflow: hidden;
  33. cursor: pointer;
  34. background-color: rgba(0, 0, 0, 0.85);
  35. transition: all 0.15s ease;
  36. }
  37. .debug:hover {
  38. background-color: rgba(0, 0, 0, 0.75);
  39. }
  40. .debug.open {
  41. right: 0;
  42. bottom: 0;
  43. width: 100%;
  44. height: 100%;
  45. margin-top: 0;
  46. border-radius: 0;
  47. padding: 0 0;
  48. overflow: scroll;
  49. }
  50. @media (min-width: 512px) {
  51. .debug.open {
  52. width: 512px;
  53. }
  54. }
  55. .debug.open:hover {
  56. background-color: rgba(0, 0, 0, 0.85);
  57. }
  58. .title {
  59. margin: 0;
  60. padding: 6px 16px 6px;
  61. line-height: 20px;
  62. font-size: 13px;
  63. }
  64. .block {
  65. margin: 2px 0 0;
  66. border-top: 1px solid rgba(255, 255, 255, 0.16);
  67. padding: 8px 16px;
  68. font-family: Hack, monospace;
  69. font-size: 13px;
  70. }
  71. .block + .block {
  72. margin-top: 8px;
  73. }
  74. </style>