OperationTip.vue 1.9 KB

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