src/layout/components/Navbar.vue
@@ -1,14 +1,11 @@
<template>
  <div class="navbar">
    <div>
      <hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
      <hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container"
        @toggleClick="toggleSideBar" />
      <breadcrumb v-if="!settingsStore.topNav" id="breadcrumb-container" class="breadcrumb-container" />
    </div>
<!--    <top-nav v-if="settingsStore.topNav" id="topmenu-container" class="topmenu-container" />-->
    <div class="center-menu">
      <span class="label">系统名称系统名称</span>
    </div>
    <div class="right-menu">
    <!--    <top-nav v-if="settingsStore.topNav" id="topmenu-container" class="topmenu-container" />-->
      <div class="avatar-container">
        <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
          <div class="avatar-wrapper">
@@ -31,7 +28,6 @@
        </el-dropdown>
      </div>
    </div>
  </div>
</template>
<script setup>
@@ -51,10 +47,14 @@
const appStore = useAppStore()
const userStore = useUserStore()
const settingsStore = useSettingsStore()
const factoryList = ref([])
function toggleSideBar() {
  appStore.toggleSideBar()
}
// const redirect = ref(undefined)
// watch(route, (newRoute) => {
//   redirect.value = newRoute.query && newRoute.query.redirect
// }, { immediate: true })
function handleCommand(command) {
  switch (command) {
@@ -89,6 +89,40 @@
function toggleTheme() {
  settingsStore.toggleTheme()
}
// function getUserLoginFacotryList() {
//   if (userStore.id) {
//     userLoginFacotryList({ userId: userStore.id }).then(res => {
//       console.log('res', res)
//       factoryList.value = res.data
//     })
//   } else {
//     factoryList.value = []
//   }
// }
function handleFactoryChange(command) {
  console.log('command', command)
  handleLogin(command.deptId);
}
function handleLogin(currentFatoryId) {
  const loginForm = {
    username: Cookies.get("username"),
    password: Cookies.get("password") === undefined ? null : decrypt(Cookies.get("password")),
    currentFatoryId: currentFatoryId
  }
  userStore.loginCheckFactory(loginForm).then(res => {
    forceReload();
  }).catch((err) => {
    console.log(err)
  })
}
function forceReload() {
  const currentUrl = window.location.origin + window.location.pathname;
  const timestamp = new Date().getTime();
  window.location.href = `${currentUrl}?reload=${timestamp}`;
}
</script>
<style lang='scss' scoped>
@@ -98,17 +132,6 @@
  position: relative;
  background: var(--navbar-bg);
  box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
  .center-menu {
    line-height: 50px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    .label {
      font-weight: bold;
      font-size: 18px;
      color: #333333;
    }
  }
  .hamburger-container {
    line-height: 46px;
@@ -170,10 +193,23 @@
        svg {
          transition: transform 0.3s;
          &:hover {
            transform: scale(1.15);
          }
        }
      }
    }
    .notification-container {
      margin-right: 20px;
      display: flex;
      align-items: center;
      cursor: pointer;
      .notification-badge {
        :deep(.el-badge__content) {
          border: none;
        }
      }
    }
@@ -203,4 +239,22 @@
    }
  }
}
</style>
<style lang="scss">
.notification-popover {
  padding: 0 !important;
  .el-popover__title {
    display: none;
  }
  .el-popover__body {
    padding: 0 !important;
  }
}
.el-badge__content.is-fixed{
  top: 12px;
}
</style>