OperationTip.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <Transition name="fade-out">
  3. <div
  4. v-show="isShow"
  5. class="operation-tip"
  6. >
  7. <img
  8. class=""
  9. :src="
  10. require(`@/assets/images/icon_operation_${props.direction}_${props.color}.png`)
  11. "
  12. alt=""
  13. draggable="false"
  14. >
  15. <div
  16. v-if="props.text"
  17. class="text"
  18. >
  19. {{ props.text }}
  20. </div>
  21. </div>
  22. </Transition>
  23. </template>
  24. <script setup>
  25. import useSizeAdapt from "@/useFunctions/useSizeAdapt"
  26. import { ref, computed, watch } from "vue"
  27. const { windowSizeInCssForRef, windowSizeWhenDesignForRef } = useSizeAdapt()
  28. const props = defineProps({
  29. direction: {
  30. type: String,
  31. default: "v", // h
  32. },
  33. color: {
  34. type: String,
  35. default: "white", // 'green'
  36. },
  37. text: {
  38. type: String,
  39. default: "",
  40. },
  41. isShow: {
  42. type: Boolean,
  43. default: true,
  44. },
  45. })
  46. const color = computed(() => {
  47. if (props.color === "white") {
  48. return "#fff"
  49. } else if (props.color === "green") {
  50. return "#7B916B"
  51. } else {
  52. return props.color
  53. }
  54. })
  55. const isShow = ref(true)
  56. const propIsShow = computed(() => {
  57. return props.isShow
  58. })
  59. watch(propIsShow, (v) => {
  60. if (!v) {
  61. isShow.value = false
  62. }
  63. })
  64. // setTimeout(() => {
  65. // isShow.value = false
  66. // }, 2000)
  67. </script>
  68. <style lang="less" scoped>
  69. .operation-tip {
  70. position: fixed;
  71. display: flex;
  72. flex-direction: column;
  73. align-items: center;
  74. > .text {
  75. color: v-bind("color");
  76. margin-right: 5px;
  77. font-family: KaiTi;
  78. font-weight: 400;
  79. font-size: 20px;
  80. }
  81. > img {
  82. width: 40px;
  83. height: 41px;
  84. }
  85. }
  86. </style>