Header.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <script setup lang="ts">
  2. import {CirclePlus, UserFilled, SwitchButton} from "@element-plus/icons-vue";
  3. import {ref} from 'vue';
  4. import {router} from '../router'
  5. // const searchContent = ref('')
  6. const userName = ref()
  7. userName.value = sessionStorage.getItem("name")
  8. function logout() {
  9. ElMessageBox.confirm(
  10. '是否要退出登录?',
  11. '提示',
  12. {
  13. customClass: "customDialog",
  14. confirmButtonText: '是',
  15. cancelButtonText: '否',
  16. type: "warning",
  17. showClose: false,
  18. roundButton: true,
  19. center: true
  20. }
  21. ).then(() => {
  22. sessionStorage.setItem('token', '')
  23. router.push({path: "/login"})
  24. }).catch(() => {
  25. // do nothing
  26. })
  27. }
  28. function search() {
  29. //todo: search
  30. }
  31. </script>
  32. <template>
  33. <el-header class="customHeader" height="20">
  34. <el-row :gutter="20" :justify="'space-between'">
  35. <el-col :span="4">
  36. <router-link to="/allStore" v-slot="{navigate}">
  37. <h1 @click="navigate" class="text-xl text-white"> 蓝鲸在线购物 </h1>
  38. </router-link>
  39. </el-col>
  40. <el-col :span="10">
  41. </el-col>
  42. <el-col :span="2">
  43. <span> {{ userName }}</span>
  44. </el-col>
  45. <el-col :span="2">
  46. <router-link to="/manager/createStore" v-slot="{navigate}">
  47. <el-icon @click="navigate" :size="30" color="white" ><CirclePlus /></el-icon>
  48. </router-link>
  49. </el-col>
  50. <el-col :span="2">
  51. <router-link to="/dashboard" v-slot="{navigate}">
  52. <el-icon @click="navigate" :size="30" color="white" ><UserFilled /></el-icon>
  53. </router-link>
  54. </el-col>
  55. <el-col :span="2">
  56. <a @click="logout">
  57. <el-icon :size="30" color="white" ><SwitchButton /></el-icon>
  58. </a>
  59. </el-col>
  60. </el-row>
  61. </el-header>
  62. </template>
  63. <style scoped>
  64. .customHeader {
  65. background-color: #79bbff;
  66. }
  67. </style>