<script setup lang="ts">
import { useRouter } from 'vue-router'

const router = useRouter()
const dialogVisible = ref(false)

const openDialog = () => {
  dialogVisible.value = true
}

const handleLogout = () => {
  dialogVisible.value = false
  router.push('/login')
  sessionStorage.clear()
}
defineExpose({
  openDialog
})
</script>

<template>
  <el-dialog top="30vh" v-model="dialogVisible" class="logout-dialog" :width="400" title="Logout">
    <div>
      <span class="font_family icon-icon_tipsfilled_b"></span>
      <span class="tips"> Are you sure you want to logout？</span>
    </div>
    <template #footer>
      <el-button class="el-button--default" @click="dialogVisible = false">Cancel</el-button>
      <el-button class="el-button--dark" @click="handleLogout">Logout</el-button>
    </template>
  </el-dialog>
</template>

<style lang="scss" scoped>
.logout-dialog {
  .font_family {
    color: #f19d38;
    font-size: 18px;
    margin-right: 4px;
  }
  .tips {
    display: inline-block;
    transform: translateY(-2px);
  }
}
</style>
