-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
608 additions
and
367 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<!-- | ||
* @Description: echarts图表初始化 | ||
* @Author: hutu | ||
* @Date: 2021-12-30 10:32:19 | ||
* @LastEditors: hutu | ||
* @LastEditTime: 2022-01-11 08:50:29 | ||
--> | ||
<template> | ||
<div :id="prop.id" :style="{ width: prop.width, height: prop.height }"></div> | ||
</template> | ||
<script lang="ts" setup> | ||
import * as echarts from 'echarts/core' | ||
import { BarChart, LineChart, PieChart } from 'echarts/charts' | ||
import { TitleComponent, TooltipComponent, GridComponent, LegendComponent, ToolboxComponent } from 'echarts/components' | ||
import { LabelLayout, UniversalTransition } from 'echarts/features' | ||
import { CanvasRenderer } from 'echarts/renderers' | ||
import { IEchartsOption } from '@/interface' | ||
echarts.use([BarChart, LineChart, PieChart, TitleComponent, TooltipComponent, ToolboxComponent, GridComponent, LegendComponent, LabelLayout, UniversalTransition, CanvasRenderer]) | ||
import { ref, onMounted, onBeforeUnmount, onActivated, onDeactivated } from 'vue' | ||
import { debounce } from 'throttle-debounce' | ||
const prop = defineProps<{ | ||
id: string | ||
width: string | ||
height: string | ||
option: IEchartsOption | ||
}>() | ||
const chart = ref() | ||
/** | ||
* @desc: 初始化图表 | ||
*/ | ||
const initChart = () => { | ||
const charts = echarts.init(document.getElementById(prop.id) as HTMLElement) | ||
charts.setOption(prop.option) | ||
chart.value = charts | ||
} | ||
/** | ||
* @desc: 监听窗口变化重置图表 | ||
*/ | ||
const chartResizeHandler = debounce(100, false, () => { | ||
if (chart.value) { | ||
chart.value.resize({ | ||
animation: { | ||
duration: 200 | ||
} | ||
}) | ||
} | ||
}) | ||
/** | ||
* @desc: 添加监听窗口变化事件 | ||
*/ | ||
const initResizeEvent = () => { | ||
window.addEventListener('resize', chartResizeHandler) | ||
} | ||
/** | ||
* @desc: 移除监听窗口变化事件 | ||
*/ | ||
const destroyResizeEvent = () => { | ||
window.addEventListener('resize', chartResizeHandler) | ||
} | ||
/** | ||
* @desc: 添加监听侧边栏变化事件 | ||
*/ | ||
let sidebarElm: HTMLElement | ||
const initSidebarResizeEvent = () => { | ||
sidebarElm = document.getElementsByClassName('sidebar-container')[0] as HTMLElement | ||
sidebarElm && sidebarElm.addEventListener('transitionend', chartResizeHandler) | ||
} | ||
/** | ||
* @desc: 移除监听侧边栏变化事件 | ||
*/ | ||
const destroySidebarResizeEvent = () => { | ||
sidebarElm && sidebarElm.removeEventListener('transitionend', chartResizeHandler) | ||
} | ||
const mounted = () => { | ||
initChart() | ||
initResizeEvent() | ||
initSidebarResizeEvent() | ||
} | ||
const beforeDestroy = () => { | ||
destroyResizeEvent() | ||
destroySidebarResizeEvent() | ||
} | ||
let firstFlag = false //首次渲染 | ||
onMounted(() => { | ||
firstFlag = true | ||
mounted() | ||
}) | ||
onBeforeUnmount(() => { | ||
beforeDestroy() | ||
}) | ||
onActivated(() => { | ||
//如果首次渲染不重复执行 | ||
if (firstFlag) { | ||
firstFlag = false | ||
return false | ||
} | ||
mounted() | ||
}) | ||
onDeactivated(() => { | ||
beforeDestroy() | ||
}) | ||
</script> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,54 @@ | ||
@import "./sidebar.scss"; | ||
@import './sidebar.scss'; | ||
|
||
* { | ||
padding: 0px; | ||
margin: 0px; | ||
padding: 0px; | ||
margin: 0px; | ||
} | ||
a{ | ||
text-decoration: none; | ||
a { | ||
text-decoration: none; | ||
} | ||
#app { | ||
font-size: 14px; | ||
} | ||
|
||
// // 自定义滚动条 | ||
// ::-webkit-scrollbar { | ||
// width: 6px; | ||
// /*滚动条宽度*/ | ||
// height: 6px; | ||
// /*滚动条高度*/ | ||
// transform: translateX(-50px); | ||
// } | ||
position: fixed; | ||
height: 100%; | ||
width: 100%; | ||
font-size: 14px; | ||
|
||
// /*定义滚动条轨道 */ | ||
// ::-webkit-scrollbar-track { | ||
// background-color: transparent; | ||
// /*滚动条的背景颜色*/ | ||
// } | ||
|
||
// /*定义滑块 */ | ||
// ::-webkit-scrollbar-thumb { | ||
// cursor: pointer; | ||
// background-color: #d2e0ed; | ||
// border-radius: 2px; | ||
// /*滚动条的背景颜色*/ | ||
// } | ||
|
||
// ::-webkit-scrollbar-thumb:hover { | ||
// background-color: #d2e0ed; | ||
// /*滚动条的背景颜色*/ | ||
// } | ||
// ::-webkit-scrollbar-thumb:active { | ||
// background-color: #d2e0ed; | ||
// /*滚动条的背景颜色*/ | ||
// } | ||
.layout { | ||
position: relative; | ||
height: 100%; | ||
width: 100%; | ||
.sidebar-container { | ||
position: fixed; | ||
height: 100%; | ||
top: 0px; | ||
z-index: 1001; | ||
overflow: hidden; | ||
transition: width 0.28s; | ||
-moz-transition: width 0.28s; | ||
-webkit-transition: width 0.28s; | ||
-o-transition: width 0.28s; | ||
} | ||
.main-container { | ||
transition: margin-left 0.28s; | ||
-moz-transition: margin-left 0.28s; | ||
-webkit-transition: margin-left 0.28s; | ||
-o-transition: margin-left 0.28s; | ||
} | ||
} | ||
.openSidebar { | ||
.sidebar-container { | ||
width: 210px !important; | ||
} | ||
.main-container { | ||
margin-left: 210px; | ||
} | ||
} | ||
.hideSidebar { | ||
.sidebar-container { | ||
width: 64px !important; | ||
} | ||
.main-container { | ||
margin-left: 64px; | ||
} | ||
} | ||
} |
Oops, something went wrong.