<template>
  <header class="header">
    <el-button type="primary" link @click.stop="toPwd">修改密码</el-button>
    <el-popconfirm @confirm="confirm" title="确定退出登录?">
      <template #reference>
        <el-button type="primary" link>退出登录</el-button>
      </template>
    </el-popconfirm>
  </header>
</template>

<script setup>
import { loginout } from '@/api/index';
import { useRouter } from 'vue-router';
const router = useRouter();
const confirm = () => {
  loginout({}).then(r => {
    console.log(r);
    localStorage.setItem('token', '');
    localStorage.setItem('menu', '');
    router.replace({
      path: '/login',
    });
  });
};

const toPwd = () => {
  router.push({
    path: '/personalCenter',
    query: {},
  });
};
</script>

<style>
.header {
  text-align: right;
  height: 3em;
  line-height: 3em;
  padding-right: 1em;
  background-color: #393b48;
}
</style>
