Topbar.vue 1.14 KB
<script setup lang="ts">
import { useRouter } from 'vue-router'
const emit = defineEmits<{ (e: 'toggleSidebar'): void }>()
const router = useRouter()

function logout() {
  localStorage.removeItem('token')
  router.push('/login')
}
</script>

<template>
  <header class="topbar">
    <button class="icon-btn" @click="emit('toggleSidebar')">☰</button>
    <div class="title">SCRM Base</div>
    <div class="spacer" />
    <div class="actions">
      <button class="text-btn" @click="logout">退出</button>
    </div>
  </header>
</template>

<style scoped>
.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}
.title {
  font-weight: 600;
  margin-left: 8px;
}
.spacer {
  flex: 1;
}
.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 6px;
  cursor: pointer;
}
.text-btn {
  border: 1px solid #e5e7eb;
  background: #fff;
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
.icon-btn:hover, .text-btn:hover { background: #f9fafb; }
</style>