<template>
|
<div class="video-box">
|
<div class="video-box-header">
|
<div class="video-box-title">
|
<div class="video-box-title-content">
|
<span class="video-box-title-icon">
|
<i class="iconfont icon-shexiangtou"></i>
|
</span>
|
<span class="video-box-title-text">{{ title }}</span>
|
<span class="link-dot"></span>
|
<span class="link-dot-list">
|
<span class="link-dot-item" v-for="index of linkDotNumber" :key="index"></span>
|
</span>
|
</div>
|
<div class="video-box-title-bg" ref="bg"></div>
|
</div>
|
<div class="video-box-header-body">
|
<slot name="videoTools"></slot>
|
</div>
|
</div>
|
<div class="video-box-body">
|
<div class="video-box-body-wrapper">
|
<slot></slot>
|
</div>
|
</div>
|
</div>
|
</template>
|
|
<script>
|
export default {
|
name: "video-box",
|
canvas: '',
|
props: {
|
title: {
|
type: String,
|
default: "",
|
},
|
id: {
|
type: [String, Number],
|
default: ""
|
},
|
isLink: {
|
type: Number,
|
default: -1,
|
},
|
},
|
data() {
|
return {
|
linkDotNumber: 20,
|
}
|
},
|
watch: {
|
title() {
|
// 重新绘制背景图
|
this.$nextTick(() => {
|
this.draw();
|
});
|
}
|
},
|
methods: {
|
initBg() {
|
let canvas = document.createElement('canvas');
|
this.$refs.bg.appendChild(canvas);
|
this.$options.canvas = canvas;
|
this.draw();
|
},
|
draw() {
|
let canvas = this.$options.canvas;
|
let width = this.$refs.bg.offsetWidth
|
let height = this.$refs.bg.offsetHeight;
|
canvas.width = width;
|
canvas.height = height;
|
let ctx = canvas.getContext('2d');
|
ctx.clearRect(0, 0, width, height);
|
ctx.beginPath();
|
ctx.moveTo(0, 0);
|
ctx.lineTo(width, 0);
|
ctx.lineTo(width - width / 10, height);
|
ctx.lineTo(0, height);
|
ctx.closePath();
|
ctx.fillStyle = "#030f7d";
|
ctx.fill();
|
ctx.strokeStyle = "#223ae4";
|
ctx.stroke();
|
},
|
},
|
mounted() {
|
this.initBg();
|
}
|
}
|
</script>
|
|
<style scoped>
|
.video-box {
|
display: flex;
|
flex-direction: column;
|
font-size: 14px;
|
padding: 8px 16px;
|
box-sizing: border-box;
|
height: 100%;
|
overflow-x: hidden;
|
}
|
|
.video-box-header {
|
display: flex;
|
margin-bottom: 8px;
|
}
|
|
.video-box-header-body {
|
flex: 1;
|
}
|
|
.video-box-title {
|
position: relative;
|
color: #00e5fd;
|
white-space: nowrap;
|
padding: 4px 32px 4px 4px;
|
}
|
|
.video-box-title
|
.video-box-title-content {
|
position: relative;
|
z-index: 1;
|
}
|
|
.video-box-title-bg {
|
position: absolute;
|
top: 0;
|
left: 0;
|
right: 0;
|
bottom: 0;
|
width: 100%;
|
height: 100%;
|
z-index: 0;
|
}
|
|
.video-box-title-icon {
|
margin-right: 4px;
|
}
|
|
.video-box-title-icon .iconfont {
|
font-size: 20px;
|
}
|
|
.link-dot {
|
display: inline-block;
|
height: 8px;
|
width: 8px;
|
margin-left: 12px;
|
border-radius: 50%;
|
background-color: #7f7e7e;
|
}
|
|
.link-dot.link-success {
|
background-color: #23dc65;
|
animation-name: twinkle_success;
|
animation-duration: 1500ms;
|
animation-iteration-count: infinite;
|
}
|
|
.link-dot.link-error {
|
background-color: #fa3122;
|
animation-name: twinkle_error;
|
animation-duration: 1500ms;
|
animation-iteration-count: infinite;
|
}
|
|
@keyframes twinkle_error {
|
0% {
|
background-color: #fa3122;
|
}
|
50% {
|
background-color: #7f7e7e;
|
}
|
100% {
|
background-color: #fa3122;
|
}
|
}
|
|
@keyframes twinkle_success {
|
0% {
|
background-color: #23dc65;
|
}
|
50% {
|
background-color: #7f7e7e;
|
}
|
100% {
|
background-color: #23dc65;
|
}
|
}
|
|
.video-box-body {
|
flex: 1;
|
}
|
|
.video-box-body-wrapper {
|
position: relative;
|
width: 100%;
|
height: 100%;
|
}
|
|
.link-dot-list {
|
white-space: normal;
|
margin-left: 100px;
|
display: inline-block;
|
width: 35px;
|
}
|
|
.link-dot-list {
|
font-size: 0;
|
}
|
|
.link-dot-item {
|
display: inline-block;
|
width: 3px;
|
height: 3px;
|
margin-left: 1px;
|
margin-top: 1px;
|
border-radius: 50%;
|
background-color: #4aaae4;
|
}
|
</style>
|