index.vue 471 B

1234567891011121314151617181920212223242526272829
  1. <template>
  2. <vab-icon :class="className" icon="refresh-line" @click="refreshRoute" />
  3. </template>
  4. <script lang="ts" setup>
  5. defineOptions({
  6. name: 'VabRefresh',
  7. })
  8. const className = ref<string>('')
  9. const rotate = () => {
  10. className.value = 'rotate'
  11. setTimeout(() => {
  12. className.value = ''
  13. }, 500)
  14. }
  15. const refreshRoute = () => {
  16. $pub('reload-router-view')
  17. rotate()
  18. }
  19. onBeforeMount(() => {
  20. $sub('refresh-rotate', () => {
  21. rotate()
  22. })
  23. })
  24. </script>