|
@@ -1,5 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
-import {ref, onMounted} from 'vue'
|
|
|
+import {ref, onMounted, defineComponent} from 'vue'
|
|
|
+import {Tooltip} from "ant-design-vue"
|
|
|
import type{PropType} from 'vue'
|
|
|
import type{navItem} from '@/types/appleBar'
|
|
|
|
|
@@ -28,14 +29,21 @@ let props = defineProps({
|
|
|
|
|
|
onMounted(() => {
|
|
|
startHideTimer();
|
|
|
- console.log(props.navItems);
|
|
|
})
|
|
|
|
|
|
+
|
|
|
+let emits = defineEmits({
|
|
|
+ action: (actionCode: string) => true
|
|
|
+});
|
|
|
/**
|
|
|
* 用户交互时,重置隐藏计时器
|
|
|
*/
|
|
|
function barActiveHandle(): void{
|
|
|
isHidden.value = false;
|
|
|
+ if(hideTimer){
|
|
|
+ clearTimeout(hideTimer);
|
|
|
+ hideTimer = null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -43,19 +51,36 @@ function barActiveHandle(): void{
|
|
|
function startHideTimer(){
|
|
|
if(hideTimer){
|
|
|
clearTimeout(hideTimer);
|
|
|
+ hideTimer = null;
|
|
|
}
|
|
|
hideTimer = setTimeout(() => {
|
|
|
isHidden.value = true;
|
|
|
}, props.hideTime);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+function actionHandle(actionCode: string): void{
|
|
|
+ emits('action', actionCode);
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<div class="appleBarBox" :class="isHidden?'hidden':''">
|
|
|
- <div class="appleBar" @mousemove="barActiveHandle" @mouseout="startHideTimer">
|
|
|
- <div class="appleItem" v-for="item in props.navItems" :key="item.id">
|
|
|
- {{item.name}}
|
|
|
+ <div class="appleBar" @mouseenter="barActiveHandle" @mouseleave="startHideTimer">
|
|
|
+ <div class="bgMask"></div>
|
|
|
+ <div class="appleItemGroup">
|
|
|
+ <div class="appleItem"
|
|
|
+ v-for="item in props.navItems"
|
|
|
+ :key="item.id"
|
|
|
+ @click="actionHandle(item.actionCode)"
|
|
|
+ >
|
|
|
+ <icon-svg class="icon" :class-name="item.icon"></icon-svg>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+<!-- 右键-->
|
|
|
+ <div class="appleItem appleUser" @click="actionHandle('user')">
|
|
|
+ <icon-svg class="icon" class-name="user"></icon-svg>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -63,7 +88,7 @@ function startHideTimer(){
|
|
|
|
|
|
<style scoped>
|
|
|
.appleBarBox{
|
|
|
- width: 80%;
|
|
|
+ width: 55%;
|
|
|
height: 100%;
|
|
|
display: flex;
|
|
|
flex-direction: row;
|
|
@@ -74,21 +99,42 @@ function startHideTimer(){
|
|
|
.appleBar{
|
|
|
width: 100%;
|
|
|
height: 50px;
|
|
|
- background-color: var(--color-background-soft);
|
|
|
border-radius: 10px;
|
|
|
- box-shadow: 0 0 10px 0 rgba(0,0,0,0.2);
|
|
|
- opacity: 0.6;
|
|
|
+ box-shadow: 0 0 10px 0 var(--color-background-mute);
|
|
|
transition: all 0.8s;
|
|
|
margin-bottom: 20px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ position: relative;
|
|
|
+ justify-content: space-between;
|
|
|
+}
|
|
|
+.appleBar .bgMask{
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ top: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ border-radius: 10px;
|
|
|
+ opacity: 0.6;
|
|
|
+ background-color: var(--color-background-soft);
|
|
|
+ z-index: 1;
|
|
|
+}
|
|
|
+.appleItemGroup{
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ z-index: 2;
|
|
|
+ position: relative;
|
|
|
}
|
|
|
-
|
|
|
.appleItem{
|
|
|
width: 45px;
|
|
|
height: 45px;
|
|
|
display: flex;
|
|
|
margin: 0 10px;
|
|
|
border-radius: 50%;
|
|
|
- box-shadow: 0 0 3px 0 rgba(0,0,0,0.2);
|
|
|
+ box-shadow: 0 0 3px 0 var(--color-text);
|
|
|
justify-content: center;
|
|
|
align-items: center;
|
|
|
font-size: 20px;
|
|
@@ -96,8 +142,35 @@ function startHideTimer(){
|
|
|
color: var(--color-text);
|
|
|
cursor: pointer;
|
|
|
transition: all 0.8s;
|
|
|
+ background-color: var(--color-background-soft);
|
|
|
+ opacity: 0.8;
|
|
|
+}
|
|
|
+
|
|
|
+.appleUser{
|
|
|
+ width: 45px;
|
|
|
+ height: 45px;
|
|
|
+ display: flex;
|
|
|
+ flex-shrink: 0;
|
|
|
+ position: relative;
|
|
|
+ z-index: 2;
|
|
|
}
|
|
|
|
|
|
+.appleItem .icon{
|
|
|
+ height: 100%;
|
|
|
+ font-size: 1.5em;
|
|
|
+ color: var(--color-text);
|
|
|
+ transition: all 0.8s;
|
|
|
+}
|
|
|
+
|
|
|
+.appleItem:hover, .appleUser:hover{
|
|
|
+ transform: scale(1.3);
|
|
|
+ box-shadow: 0 0 10px 0 rgba(0,0,0,0.2);
|
|
|
+ color: var(--color-text);
|
|
|
+ background-color: var(--color-background-soft);
|
|
|
+ transition: all 0.8s;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
.hidden .appleBar{
|
|
|
width: 10%;
|
|
|
height: 10px;
|
|
@@ -105,7 +178,10 @@ function startHideTimer(){
|
|
|
opacity: 0.4;
|
|
|
margin-bottom: 5px;
|
|
|
cursor: pointer;
|
|
|
+}
|
|
|
|
|
|
+.hidden .appleBar .appleItem{
|
|
|
+ display: none;
|
|
|
}
|
|
|
|
|
|
|