WidgetViewer.vue 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <template>
  2. <component
  3. :is="widgetType"
  4. class="c-widget"
  5. :class="{ more }"
  6. :style="styles"
  7. :node="node"
  8. />
  9. </template>
  10. <script>
  11. import CText from './CText.vue'
  12. import CMarquee from './CMarquee.vue'
  13. import CImage from './CImage.vue'
  14. import CVideo from './CVideo.vue'
  15. import CTime from './CTime.vue'
  16. import CWeather from './CWeather.vue'
  17. import CWeb from './CWeb.vue'
  18. import CLive from './CLive.vue'
  19. export default {
  20. name: 'Widget',
  21. components: {
  22. CText,
  23. CMarquee,
  24. CImage,
  25. CVideo,
  26. CTime,
  27. CWeather,
  28. CWeb,
  29. CLive
  30. },
  31. props: {
  32. node: {
  33. type: Object,
  34. default: null
  35. }
  36. },
  37. computed: {
  38. more () {
  39. return this.node.sources?.length > 0
  40. },
  41. widgetType () {
  42. return this.node.type
  43. },
  44. styles () {
  45. const { top, left } = this.node
  46. return {
  47. top: `${top}px`,
  48. left: `${left}px`
  49. }
  50. }
  51. }
  52. }
  53. </script>
  54. <style scoped lang="scss">
  55. .c-widget {
  56. position: absolute !important;
  57. user-select: none;
  58. &.more {
  59. cursor: pointer;
  60. &:hover {
  61. outline: 2px dashed $gray;
  62. }
  63. }
  64. }
  65. </style>