import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App'
import './index.less'

// 防止移动端双指缩放
document.addEventListener('gesturestart', function (e) {
  e.preventDefault()
})

document.addEventListener('gesturechange', function (e) {
  e.preventDefault()
})

document.addEventListener('gestureend', function (e) {
  e.preventDefault()
})

// 防止双击缩放
let lastTouchEnd = 0
document.addEventListener(
  'touchend',
  function (e) {
    const now = Date.now()
    if (now - lastTouchEnd <= 300) {
      e.preventDefault()
    }
    lastTouchEnd = now
  },
  false
)

// 防止通过touch事件进行缩放
document.addEventListener(
  'touchstart',
  function (e) {
    if (e.touches.length > 1) {
      e.preventDefault()
    }
  },
  { passive: false }
)

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
)
