<template>
  <div>
    <router-view v-if="isRouterAlive" />
  </div>
</template>
 
<script>
export default {
  name: 'App',
  provide() {
    return { 
      reload: this.reload
    }
  },
  data() {
    return {
      isRouterAlive: true
    }
  },
  methods: {
    reload() {
      // 先将组件隐藏
      this.isRouterAlive = false
      
      // 使用nextTick确保DOM更新后再重新显示组件
      this.$nextTick(() => {
        this.isRouterAlive = true
      })
    }
  }
}

const debounce = (fn, delay) => {
  let timer
  return (...args) => {
    if (timer) {
      clearTimeout(timer)
    }
    timer = setTimeout(() => {
      fn(...args)
    }, delay)
  }
}

const _ResizeObserver = window.ResizeObserver
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback) {
    callback = debounce(callback, 200)
    super(callback)
  }
}
</script>

<style>
/* App.vue */
.layout {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}
/* #vite-error-overlay { display: none !important; } 隐藏vite错误提示 */
.control-area { 
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  /* 禁用默认滚动 */
}
</style>
