OperationTip.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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, onMounted, inject } from "vue"
  25. import { useRoute, useRouter } from "vue-router"
  26. import { useStore } from "vuex"
  27. const route = useRoute()
  28. const router = useRouter()
  29. const store = useStore()
  30. const $env = inject('$env')
  31. const {
  32. windowSizeInCssForRef,
  33. windowSizeWhenDesignForRef,
  34. } = useSizeAdapt()
  35. const props = defineProps({
  36. direction: {
  37. type: String,
  38. default: 'v', // h
  39. },
  40. color: {
  41. type: String,
  42. default: 'white', // 'green'
  43. },
  44. text: {
  45. type: String,
  46. default: '',
  47. },
  48. isShow: {
  49. type: Boolean,
  50. default: true,
  51. }
  52. })
  53. const color = computed(() => {
  54. if (props.color === 'white') {
  55. return '#fff'
  56. } else if (props.color === 'green') {
  57. return '#7B916B'
  58. } else {
  59. return props.color
  60. }
  61. })
  62. const isShow = ref(true)
  63. const propIsShow = computed(() => {
  64. return props.isShow
  65. })
  66. watch(propIsShow, (v) => {
  67. if (!v) {
  68. isShow.value = false
  69. }
  70. })
  71. setTimeout(() => {
  72. isShow.value = false
  73. }, 2000)
  74. </script>
  75. <style lang="less" scoped>
  76. .operation-tip{
  77. position: fixed;
  78. display: flex;
  79. align-items: center;
  80. >.text{
  81. color: v-bind('color');
  82. margin-right: calc(5 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  83. font-family: KaiTi, KaiTi;
  84. font-weight: 400;
  85. font-size: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  86. }
  87. >img{
  88. width: calc(40 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  89. height: calc(41 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
  90. }
  91. }
  92. </style>