Header.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. function logout() {
  7. ElMessageBox.confirm(
  8. '是否要退出登录?',
  9. '提示',
  10. {
  11. customClass: "customDialog",
  12. confirmButtonText: '是',
  13. cancelButtonText: '否',
  14. type: "warning",
  15. showClose: false,
  16. roundButton: true,
  17. center: true
  18. }
  19. ).then(() => {
  20. localStorage.setItem('token', '')
  21. router.push({path: "/login"})
  22. }).catch(() => {
  23. // do nothing
  24. })
  25. }
  26. function search() {
  27. //todo: search
  28. }
  29. </script>
  30. <template>
  31. <div class="bg-primary-500 min-w-full top-0 shadow-md flex-shrink-0 rounded-b-xl">
  32. <div class="mx-4 p-4">
  33. <div class="flex items-center justify-between space-x-4">
  34. <div class="flex items-center">
  35. <router-link to="/home" v-slot="{navigate}">
  36. <h1 @click="navigate" class="text-xl text-white"> 蓝鲸在线购物 </h1>
  37. </router-link>
  38. </div>
  39. <div class="w-3/4">
  40. <form>
  41. <div class="relative">
  42. <!--网上抄的logo-->
  43. <div class="absolute inset-y-0 start-0 flex items-center ps-3 pointer-events-none">
  44. <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
  45. <path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
  46. </svg>
  47. </div>
  48. <input type="search" id="search"
  49. v-model="searchContent"
  50. class="block w-full p-4 ps-10 text-gray-900 border border-gray-300 rounded-3xl bg-gray-50 focus:ring-blue-500 focus:border-blue-500" placeholder="国货好物" required>
  51. <button type="submit" @click="search"
  52. class="text-white absolute end-5 bottom-2.5 bg-primary-600 hover:bg-primary-700 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-3xl text-sm px-4 py-2">搜索商品</button>
  53. </div>
  54. </form>
  55. </div>
  56. <div class="flex items-center space-x-4 mx-3">
  57. <router-link to="/manager/createStore" v-slot="{navigate}">
  58. <el-icon @click="navigate" :size="30" color="white" ><CirclePlus /></el-icon>
  59. </router-link>
  60. <router-link to="/dashboard" v-slot="{navigate}">
  61. <el-icon @click="navigate" :size="30" color="white" ><UserFilled /></el-icon>
  62. </router-link>
  63. <a @click="logout" class="hover:cursor-pointer">
  64. <el-icon :size="30" color="white" ><SwitchButton /></el-icon>
  65. </a>
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <style>
  72. .customDialog {
  73. @apply w-1/4 space-y-5 text-4xl font-semibold rounded-2xl pb-5 pt-2
  74. }
  75. </style>
  76. <style scoped>
  77. </style>