popover.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <!-- -->
  2. <template>
  3. <div class="demo-ico__desc">
  4. <div class="demo-ico__desc_item" @click="exitFun(1)">
  5. <el-popover :width="300"
  6. popper-style="box-shadow: rgb(14 18 22 / 35%) 0px 10px 38px -10px, rgb(14 18 22 / 20%) 0px 10px 20px -15px; padding: 20px;">
  7. <template #reference>
  8. <el-avatar :size="30" :src="require('@/assets/img/userInfo.gif')" />
  9. </template>
  10. <template #default>
  11. <div class="demo-rich-conent" style="display: flex; gap: 16px; flex-direction: column">
  12. <el-avatar :size="50" :src="require('@/assets/img/userInfo.gif')" style="margin-bottom: 8px" />
  13. <div>
  14. <p class="demo-rich-content__name" style="margin: 0; font-weight: 500">
  15. 账号:{{ data.username }}
  16. </p>
  17. <p class="demo-rich-content__name" style="margin: 0; font-size: 14px;">
  18. 公司:{{ data.company }}
  19. </p>
  20. </div>
  21. <p class="demo-rich-content__desc" style="margin: 0">
  22. <el-collapse v-model="data.activeNames" accordion>
  23. <el-collapse-item title="重置密码" name="1">
  24. <div style="display: flex;">
  25. <el-input v-model="data.input" type="password" placeholder="请输入新密码" style="flex: 1;" show-password />
  26. <el-button type="primary" style="margin-left: 20px;">修改</el-button>
  27. </div>
  28. </el-collapse-item>
  29. <el-collapse-item title="设置展开/关闭" name="2">
  30. <el-switch v-model="data.switchValue" @change="changeSwiper" :inactive-value="true"
  31. :active-value="false" width="60" inline-prompt active-text="展开"
  32. inactive-text="收起" />
  33. </el-collapse-item>
  34. </el-collapse>
  35. </p>
  36. </div>
  37. </template>
  38. </el-popover>
  39. <p class="demo-ico__desc_item_p" style="margin-left: 5px;">{{ data.username }},你好</p>
  40. </div>
  41. <el-divider direction="vertical" />
  42. <div class="demo-ico__desc_item demo-ico__desc_hover" @click="exitFun(2)">
  43. <el-icon size="16">
  44. <Bell />
  45. </el-icon>
  46. <p class="demo-ico__desc_item_p">消息</p>
  47. </div>
  48. <el-divider direction="vertical" />
  49. <div class="demo-ico__desc_item demo-ico__desc_hover" @click="exitFun(3)">
  50. <el-icon size="16">
  51. <FullScreen />
  52. </el-icon>
  53. <p class="demo-ico__desc_item_p">全屏</p>
  54. </div>
  55. <el-divider direction="vertical" />
  56. <div class="demo-ico__desc_item demo-ico__desc_hover" @click="exitFun(4)">
  57. <el-icon size="16">
  58. <SwitchButton />
  59. </el-icon>
  60. <p class="demo-ico__desc_item_p">退出</p>
  61. </div>
  62. </div>
  63. </template>
  64. <script lang="ts" setup>
  65. import { exitFun } from "@/plugins/setFun";
  66. import { reactive, watch } from "vue";
  67. import { useStore } from "vuex";
  68. const store = useStore()
  69. const data = reactive({
  70. username: '',
  71. company: '',
  72. activeNames: '',
  73. switchValue: null,
  74. input:''
  75. })
  76. watch(() => store.state.switchValue, (toPath: any) => {
  77. data.switchValue = store.state.switchValue
  78. }, { immediate: true, deep: true })
  79. //函数
  80. const changeSwiper = async () => {
  81. store.commit('setswitchValue', data.switchValue) //存储导航状态
  82. }
  83. data.username = !store.state.userInfo.form.username ? '游客' : store.state.userInfo.form.username
  84. watch(() => store.state.company, () => {
  85. data.company = store.state.company == '' ? '未进入其他公司' : store.state.company
  86. }, { deep: true, immediate: true })
  87. </script>
  88. <style lang="scss">
  89. .demo-ico__desc {
  90. user-select: none;
  91. display: flex;
  92. align-items: center;
  93. &_item {
  94. padding: 10px 0;
  95. border-radius: 2px;
  96. cursor: pointer;
  97. display: flex;
  98. align-items: center;
  99. &_p {
  100. font-size: 12px;
  101. padding-left: 5px;
  102. }
  103. }
  104. &_hover:hover {
  105. color: var(--el-color-primary);
  106. ;
  107. }
  108. }
  109. </style>