HeadMenu.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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. <img style="display: block;" src="../../assets/image/flash_scd.png" alt="">
  11. </div>
  12. <!-- 右侧功能 -->
  13. <div class="setBox">
  14. <!-- 返回图标 -->
  15. <div style="padding-right: 16px;border-right: 1px solid white;">
  16. <span class="outImg">
  17. <img class="backImg" @mouseover="imgOver" @mouseout="imgOut"
  18. :src="img ? require('../../assets/image/back_gray.png') : require('../../assets/image/back_now.png')"
  19. alt="">
  20. </span>
  21. </div>
  22. <!-- 时间、日期显示 -->
  23. <div style="width: 30%;position: relative;">
  24. <span class="date" style="
  25. margin-right: 16px;
  26. width: 100%;
  27. height: 30px;
  28. display: inline-block;
  29. text-align: center;
  30. line-height: 30px;
  31. ">{{ getDate() }} {{ times }}</span>
  32. <img style="width: 100%;position: absolute;top: 23px;left: 0px;"
  33. src="../../assets/image/head_dotted.png" alt="">
  34. </div>
  35. <!-- 用户栏 -->
  36. <div class="userBox" style="background-color: rgba(50,59,91, 0.9);">
  37. <div class="userSpan" @click="isUser">
  38. <img style="
  39. width: 14px;
  40. height: 14px;
  41. display: block;
  42. background-color: #BAC0E1;
  43. border-radius: 50%;
  44. padding: 6px;
  45. " src="../../assets/icon/user_gray.png" alt="">
  46. <span style="color: white;display: block;margin: 5px;">{{ username }}</span>
  47. <img :src="isSrc" class="jsDown" alt="">
  48. </div>
  49. <!-- 个人信息 -->
  50. <div v-if="isTime" class="messageBox">
  51. <!-- 头像及登陆信息 -->
  52. <div style="
  53. display: flex;
  54. justify-content: flex-start;
  55. align-items: center;
  56. height: 80px;
  57. border-bottom: 1px solid gray;
  58. ">
  59. <div>
  60. <img style="width: 40px;height: 40px;margin: 0 10px;" src="../../assets/icon/Avatar.png"
  61. alt="">
  62. </div>
  63. <div>
  64. <p style="font-weight: bolder;font-size: 16px;">{{ username }}</p>
  65. <p>登陆时间:{{ currentTime }}</p>
  66. </div>
  67. </div>
  68. <div class="logOut" @click="logOut">
  69. <div style="text-align: center;line-height: 10px;">
  70. <img style="width: 20px;height: 20px;display: inline-block;"
  71. src="../../assets/icon/SignOut.png" alt="">
  72. </div>
  73. <div>
  74. <span>注销</span>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. <!-- 最小化,关闭 -->
  80. <div>
  81. <!-- <span class="moreSet" @click="miniSize">-</span>
  82. <span class="moreSet" @click="closeSize">x</span> -->
  83. <img :src="mini ? require('../../assets/image/mini_gray.png') : require('../../assets/image/window_min.png')"
  84. @click="miniSize" @mouseover="miniOver" @mouseout="miniOut" style="margin: 0 10px;" alt="">
  85. <img :src="close ? require('../../assets/image/close_red.png') : require('../../assets/image/window_close.png')"
  86. @click="closeSize" @mouseover="closeOver" @mouseout="closeOut" alt="">
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. </template>
  92. <script>
  93. import { ref, onMounted } from 'vue'
  94. import { useRouter } from 'vue-router';
  95. export default {
  96. setup() {
  97. let times = ref('')//时间显示
  98. let router = useRouter()
  99. let mini = ref(false)
  100. let close = ref(false)
  101. let img = ref(false)
  102. let userInfo = ref({})//用户信息
  103. let username = ref('')//用户名
  104. let isTime = ref(false)//用户详情
  105. let isSrc = ref(require('../../assets/icon/userdown.png'))
  106. const currentTime = ref(getCurrentTime());
  107. // 初始化组件
  108. function reload() {
  109. userInfo.value = JSON.parse(sessionStorage.getItem("userInfo"))
  110. username.value = userInfo.value.userinfo.name
  111. }
  112. // 获取日期
  113. function getDate() {
  114. const currentDate = new Date();
  115. const year = currentDate.getFullYear();
  116. const month = (currentDate.getMonth() + 1).toString().padStart(2, '0'); // 月份从0开始,需要加1,并补零
  117. const day = currentDate.getDate().toString().padStart(2, '0'); // 补零
  118. const formattedDate = `${year}.${month}.${day}`;
  119. return formattedDate
  120. }
  121. // 获取时间
  122. function getTime() {
  123. let currentDate = new Date();
  124. let hours = currentDate.getHours().toString().padStart(2, '0');
  125. let minutes = currentDate.getMinutes().toString().padStart(2, '0');
  126. let seconds = currentDate.getSeconds().toString().padStart(2, '0');
  127. let formattedTime = `${hours}:${minutes}:${seconds}`;
  128. times.value = formattedTime
  129. }
  130. function getCurrentTime() {
  131. const now = new Date();
  132. const year = now.getFullYear();
  133. const month = (now.getMonth() + 1).toString().padStart(2, '0');
  134. const day = now.getDate().toString().padStart(2, '0');
  135. return `${year}-${month}-${day}`;
  136. }
  137. function isUser() {
  138. if(isTime.value){
  139. isTime.value = false//显示用户信息盒子
  140. isSrc.value = require('../../assets/icon/userdown.png')
  141. }else{
  142. isTime.value = true
  143. isSrc.value = require('../../assets/icon/userup.png')
  144. }
  145. }
  146. // 最小化窗口
  147. function miniSize() {
  148. windowEx.Min()
  149. }
  150. // 关闭窗口
  151. function closeSize() {
  152. if (typeof (windowEx) === 'undefined') {
  153. //返回登录页面
  154. router.push('/login')
  155. return
  156. }
  157. windowEx.Close()
  158. }
  159. function miniOver() {//鼠标移入
  160. mini.value = true
  161. }
  162. function miniOut() {//鼠标移出
  163. mini.value = false
  164. }
  165. function closeOver() {
  166. close.value = true
  167. }
  168. function closeOut() {
  169. close.value = false
  170. }
  171. function imgOver() {
  172. img.value = true
  173. }
  174. function imgOut() {
  175. img.value = false
  176. }
  177. // 退出登录
  178. function logOut() {
  179. if (typeof windowEx != "undefined") {
  180. windowEx.Size(384, 426)
  181. }
  182. localStorage.removeItem("loginStatus")
  183. router.push("/login")
  184. }
  185. onMounted(() => {
  186. getTime()//不可注释,首次获取时间
  187. setInterval(() => {
  188. getTime()
  189. }, 1000)//一秒给times赋值,使其实时显示
  190. reload()
  191. })
  192. return {
  193. getDate,//获取日期
  194. getTime,//获取时间
  195. times,//动态显示时间
  196. miniSize,//最小化窗口
  197. closeSize,//关闭窗口
  198. logOut,//登出
  199. mini,
  200. miniOut,
  201. miniOver,
  202. close,
  203. closeOut,
  204. closeOver,
  205. img,
  206. imgOver,
  207. imgOut,
  208. reload,//初始化组件
  209. userInfo,//用户信息
  210. username,//用户名
  211. getCurrentTime,
  212. currentTime,
  213. isTime,//用户详情
  214. isUser,//显示用户信息盒子
  215. isSrc,
  216. }
  217. }
  218. }
  219. </script>
  220. <style scoped>
  221. @import url('https://fonts.font.im/css?family=Hanalei+Fill');
  222. p {
  223. margin: 0;
  224. padding: 0;
  225. }
  226. .bigBox {
  227. width: 97vw;
  228. height: 55px;
  229. /* border: 1px solid red; */
  230. margin: 0 auto;
  231. margin-left: -10px;
  232. display: flex;
  233. justify-content: space-between;
  234. align-items: center;
  235. }
  236. .monyBox {
  237. width: 12%;
  238. height: 50px;
  239. display: flex;
  240. justify-content: space-around;
  241. align-items: center;
  242. }
  243. .folders {
  244. font-size: 26px;
  245. color: #BAC0E1;
  246. }
  247. .headSpan {
  248. background: linear-gradient(0deg, #BAC0E1 50%, #EDF2FF 50%);
  249. -webkit-background-clip: text;
  250. background-clip: text;
  251. color: transparent;
  252. font-size: 26px;
  253. font-family: 'Hanalei Fill', cursive;
  254. }
  255. .setBox {
  256. width: 27%;
  257. height: 50px;
  258. /* border: 1px solid white; */
  259. display: flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. }
  263. .outImg {
  264. display: block;
  265. width: 30px;
  266. height: 30px;
  267. /* background: linear-gradient(to bottom, #BAC0E1, #EDF2FF); */
  268. border-radius: 50%;
  269. text-align: center;
  270. line-height: 26px;
  271. }
  272. .backImg {
  273. width: 30px;
  274. height: 30px;
  275. z-index: 2;
  276. }
  277. .date {
  278. background: linear-gradient(0deg, #BAC0E1 50%, #EDF2FF 50%);
  279. -webkit-background-clip: text;
  280. background-clip: text;
  281. color: transparent;
  282. font-size: 14px;
  283. /* border-bottom: 1px dotted white; */
  284. border-right: 1px solid white;
  285. padding-right: 16px;
  286. }
  287. .userSpan {
  288. width: 100%;
  289. height: 24px;
  290. display: flex;
  291. justify-content: center;
  292. align-items: center;
  293. }
  294. .el-dropdown-link {
  295. background: linear-gradient(0deg, #BAC0E1 50%, #EDF2FF 50%);
  296. -webkit-background-clip: text;
  297. background-clip: text;
  298. color: transparent;
  299. font-size: 14px;
  300. text-align: center;
  301. line-height: 25px;
  302. margin: 0 10px;
  303. }
  304. .moreSet {
  305. display: inline-block;
  306. width: 30px;
  307. height: 30px;
  308. background: linear-gradient(to bottom, #BAC0E1, #EDF2FF);
  309. /* border-radius: 50%; */
  310. text-align: center;
  311. line-height: 24px;
  312. font-size: 26px;
  313. cursor: pointer;
  314. margin-right: 5px;
  315. }
  316. .moreSet:nth-child(1):hover {
  317. /* border: 1px black solid; */
  318. color: #BAC0E1;
  319. }
  320. .moreSet:nth-child(2):hover {
  321. background: rgb(197, 66, 66);
  322. color: red;
  323. }
  324. .logOut {
  325. width: 50px;
  326. height: 50px;
  327. text-align: center;
  328. line-height: 40px;
  329. display: flex;
  330. justify-content: space-around;
  331. align-items: center;
  332. cursor: pointer;
  333. margin: 0 10px;
  334. }
  335. .userBox {
  336. width: 35%;
  337. height: 30px;
  338. text-align: center;
  339. line-height: 30px;
  340. }
  341. .jsDown {
  342. display: block;
  343. width: 12px;
  344. height: 12px;
  345. }
  346. .messageBox {
  347. width: 240px;
  348. height: calc(100vh - 800px);
  349. background-color: white;
  350. border-radius: 8px;
  351. z-index: 20;
  352. position: relative;
  353. box-shadow: 0px 2px 7px 0px rgba(138, 157, 205, 0.4);
  354. margin: 20px 0;
  355. }
  356. </style>