HeadMenu.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <template>
  2. <div>
  3. <div class="bigBox">
  4. <!-- 左侧标题 -->
  5. <div class="monyBox">
  6. <el-icon class="folders">
  7. <FolderRemove />
  8. </el-icon>
  9. <span class="headSpan">变电站scd检测</span>
  10. </div>
  11. <!-- 右侧功能 -->
  12. <div class="setBox">
  13. <!-- 返回图标 -->
  14. <div style="padding-right: 10px;border-right: 1px solid white;">
  15. <span class="outImg">
  16. <img class="backImg" src="../../assets/icon/back_to.png" alt="">
  17. </span>
  18. </div>
  19. <!-- 时间、日期显示 -->
  20. <div>
  21. <span class="date" style="margin-right: 10px;">{{ getDate() }}</span>
  22. <span class="date">{{ times }}</span>
  23. </div>
  24. <!-- 用户栏 -->
  25. <div class="userBox">
  26. <span class="userSpan">
  27. <img style="width: 12px;height: 12px;" src="../../assets/icon/user_gray.png" alt="">
  28. </span>
  29. <el-dropdown trigger="click">
  30. <span class="el-dropdown-link">
  31. Admin<el-icon class="el-icon--right" style="color: #BAC0E1;"><arrow-down /></el-icon>
  32. </span>
  33. <template #dropdown>
  34. <el-dropdown-menu>
  35. <el-dropdown-item>
  36. <!-- 个人信息 -->
  37. <div>
  38. <!-- 头像及登陆信息 -->
  39. <div
  40. style="display: flex;justify-content: space-around;align-items: center;height: 80px;border-bottom: 1px solid gray;">
  41. <div>
  42. <img style="width: 40px;height: 40px;" src="../../assets/icon/Avatar.png"
  43. alt="">
  44. </div>
  45. <div>
  46. <p>Admin</p>
  47. <p>登陆时间:2000-01-01</p>
  48. </div>
  49. </div>
  50. <div class="logOut" @click="logOut">
  51. <div style="text-align: center;line-height: 10px;">
  52. <img style="width: 20px;height: 20px;display: inline-block;"
  53. src="../../assets/icon/SignOut.png" alt="">
  54. </div>
  55. <div>
  56. <span>注销</span>
  57. </div>
  58. </div>
  59. </div>
  60. </el-dropdown-item>
  61. </el-dropdown-menu>
  62. </template>
  63. </el-dropdown>
  64. </div>
  65. <!-- 最小化,关闭 -->
  66. <div>
  67. <span class="moreSet" @click="miniSize">-</span>
  68. <span class="moreSet" @click="closeSize">x</span>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. </template>
  74. <script>
  75. import { ref, onMounted } from 'vue'
  76. import { useRouter } from 'vue-router';
  77. export default {
  78. setup() {
  79. let times = ref('')//时间显示
  80. let router = useRouter()
  81. // 获取日期
  82. function getDate() {
  83. const currentDate = new Date();
  84. const year = currentDate.getFullYear();
  85. const month = (currentDate.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始,需要加1,并补零
  86. const day = currentDate.getDate().toString().padStart(2, '0'); // 补零
  87. const formattedDate = `${year}.${month}.${day}`;
  88. return formattedDate
  89. }
  90. // 获取时间
  91. function getTime() {
  92. let currentDate = new Date();
  93. let hours = currentDate.getHours().toString().padStart(2, '0');
  94. let minutes = currentDate.getMinutes().toString().padStart(2, '0');
  95. let seconds = currentDate.getSeconds().toString().padStart(2, '0');
  96. let formattedTime = `${hours}:${minutes}:${seconds}`;
  97. times.value = formattedTime
  98. }
  99. // 最小化窗口
  100. function miniSize() {
  101. windowEx.Min()
  102. }
  103. // 关闭窗口
  104. function closeSize() {
  105. windowEx.Close()
  106. }
  107. // 退出登录
  108. function logOut(){
  109. // windowEx.Size(384,426)
  110. localStorage.removeItem("loginStatus")
  111. router.push("/login")
  112. }
  113. onMounted(() => {
  114. getTime()//不可注释,首次获取时间
  115. setInterval(() => {
  116. getTime()
  117. }, 1000)//一秒给times赋值,使其实时显示
  118. })
  119. return {
  120. getDate,//获取日期
  121. getTime,//获取时间
  122. times,//动态显示时间
  123. miniSize,//最小化窗口
  124. closeSize,//关闭窗口
  125. logOut,//登出
  126. }
  127. }
  128. }
  129. </script>
  130. <style scoped>
  131. p {
  132. margin: 0;
  133. padding: 0;
  134. }
  135. .bigBox {
  136. width: 97vw;
  137. height: 55px;
  138. /* border: 1px solid red; */
  139. margin: 0 auto;
  140. margin-left: -10px;
  141. display: flex;
  142. justify-content: space-between;
  143. align-items: center;
  144. }
  145. .monyBox {
  146. width: 230px;
  147. height: 50px;
  148. line-height: 50px;
  149. }
  150. .folders {
  151. font-size: 26px;
  152. color: #BAC0E1;
  153. }
  154. .headSpan {
  155. background: linear-gradient(0deg, #BAC0E1 50%, #EDF2FF 50%);
  156. -webkit-background-clip: text;
  157. background-clip: text;
  158. color: transparent;
  159. font-size: 26px;
  160. }
  161. .setBox {
  162. width: 400px;
  163. height: 50px;
  164. /* border: 1px solid white; */
  165. display: flex;
  166. justify-content: space-between;
  167. align-items: center;
  168. }
  169. .outImg {
  170. display: block;
  171. width: 26px;
  172. height: 26px;
  173. background: linear-gradient(to bottom, #BAC0E1, #EDF2FF);
  174. border-radius: 50%;
  175. text-align: center;
  176. line-height: 26px;
  177. }
  178. .backImg {
  179. width: 14px;
  180. height: 14px;
  181. z-index: 2;
  182. }
  183. .date {
  184. background: linear-gradient(0deg, #BAC0E1 50%, #EDF2FF 50%);
  185. -webkit-background-clip: text;
  186. background-clip: text;
  187. color: transparent;
  188. font-size: 14px;
  189. border-bottom: 1px dotted white;
  190. }
  191. .userSpan {
  192. display: inline-block;
  193. width: 24px;
  194. height: 24px;
  195. background-color: #BAC0E1;
  196. border-radius: 50%;
  197. text-align: center;
  198. line-height: 24px;
  199. }
  200. .el-dropdown-link {
  201. background: linear-gradient(0deg, #BAC0E1 50%, #EDF2FF 50%);
  202. -webkit-background-clip: text;
  203. background-clip: text;
  204. color: transparent;
  205. font-size: 14px;
  206. text-align: center;
  207. line-height: 25px;
  208. }
  209. .moreSet {
  210. display: inline-block;
  211. width: 30px;
  212. height: 30px;
  213. background: linear-gradient(to bottom, #BAC0E1, #EDF2FF);
  214. /* border-radius: 50%; */
  215. text-align: center;
  216. line-height: 24px;
  217. font-size: 26px;
  218. cursor: pointer;
  219. margin-right: 5px;
  220. }
  221. .moreSet:nth-child(1):hover {
  222. /* border: 1px black solid; */
  223. color: #BAC0E1;
  224. }
  225. .moreSet:nth-child(2):hover {
  226. background: rgb(197, 66, 66);
  227. color: red;
  228. }
  229. .logOut {
  230. width: 50px;
  231. height: 50px;
  232. text-align: center;
  233. line-height: 40px;
  234. display: flex;
  235. justify-content: space-around;
  236. align-items: center;
  237. }</style>