| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <template>
- <div class="chart-box" :class="color">
- <div class="chart-title" v-if="name">
- <div class="name">
- <img :src="`/src/assets/images/common/chart-${color || 'icon'}.png`" alt="" />
- <span>{{name}}</span>
- <slot name="title-left"></slot>
- </div>
- <div class="slot">
- <slot name="title-right"></slot>
- </div>
- </div>
- <slot v-else name="title-name"></slot>
- <div class="chart-content">
- <div v-show="arrow" :class="['arrow',arrow]" @click="handleShrink">
- <el-icon class="icon" color="#141414"><DArrowLeft /></el-icon>
- </div>
- <slot></slot>
- </div>
- </div>
- </template>
- <script setup>
- import {ref} from 'vue'
- const props = defineProps({
- name:{
- type:String,
- defalut:''
- },
- arrow:{
- type:String,
- defalut:''
- },
- color:{
- type:String,
- defalut:'icon'
- }
- })
- const isShrink = ref(true)
- const handleShrink = () =>{
- }
- </script>
- <style lang="scss" scoped>
- .chart-box {
- width: 100%;
- height: 100%;
- box-sizing: border-box;
- border-radius: 4px;
- background: #232323;
- border: 0.6px solid rgb(255, 255, 255,0.4);
- .chart-title {
- width: 100%;
- height: 38px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- background: rgba(255, 255, 255, 0.05);
- padding-right: 12px;
- box-sizing: border-box;
- flex: none;
- .name {
- display: flex;
- align-items: center;
- padding: 0 12px;
- span{
- font-size: 18px;
- margin-left: 6px;
- font-family: 'SOURCEHANTIFINE';
- margin-right: 8px;
- }
- }
- }
- .chart-content{
- position: relative;
- width: 100%;
- height: calc(100% - 38px);
- padding: 4px 8px;
- box-sizing: border-box;
- .arrow{
- position: absolute;
- right: -16px;
- top:calc(50% - 40px);
- background: #fff;
- width: 16px;
- height: 80px;
- line-height: 80px;
- border-radius: 0 5px 5px 0;
- text-align: center;
- cursor: pointer;
- }
- .arrow-left{
- left: -16px;
- border-radius: 5px 0 0 5px;
- .icon{
- transform: rotate(180deg);
- }
- }
- }
- &.yellow{
- border: 0.6px solid #444444;
- border-radius: 8px;
- background: #191919;
- .chart-title{
- height: 59px;
- .name{
- color: #FFD489;
- span{
- font-size: 22px;
- }
- }
- }
- .chart-content{
- padding: 0;
- height: calc(100% - 59px);
- }
- }
- }
- .shrink-animation {
- width: 100%; /* 初始宽度,与关键帧中的初始状态一致 */
- overflow: hidden; /* 防止内容溢出 */
- animation: shrink-horizontal 2s forwards; /* 应用动画,持续时间为2秒,动画结束后保持最终状态 */
- }
- /* 定义动画关键帧 */
- @keyframes shrink-horizontal {
- 0% {
- width: 100%; /* 初始宽度,可以是具体的像素值或百分比 */
- transform: scaleX(1); /* 初始缩放比例 */
- }
- 100% {
- width: 0%; /* 最终宽度,这里设置为0表示完全收缩 */
- transform: scaleX(0); /* 最终缩放比例,这里设置为0表示在X轴上完全收缩 */
- }
- }
- </style>
|