mirror of
https://github.com/hi2shark/nazhua.git
synced 2026-01-17 01:30:44 +08:00
✨ 新增网络监控状态切换的本地化存储
This commit is contained in:
parent
8dc1aa0154
commit
2708263440
@ -2,6 +2,7 @@
|
|||||||
<div
|
<div
|
||||||
v-if="option"
|
v-if="option"
|
||||||
class="line-box"
|
class="line-box"
|
||||||
|
:style="boxStyle"
|
||||||
>
|
>
|
||||||
<v-chart
|
<v-chart
|
||||||
ref="chartRef"
|
ref="chartRef"
|
||||||
@ -49,6 +50,13 @@ const option = computed(() => {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
const boxStyle = computed(() => {
|
||||||
|
const style = {};
|
||||||
|
if (props.size > 0) {
|
||||||
|
style.height = `${props.size}px`;
|
||||||
|
}
|
||||||
|
return style;
|
||||||
|
});
|
||||||
|
|
||||||
function handleResize() {
|
function handleResize() {
|
||||||
chartRef.value?.resize?.();
|
chartRef.value?.resize?.();
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
<dot-dot-box
|
<dot-dot-box
|
||||||
v-if="monitorData.length"
|
v-if="monitorData.length"
|
||||||
class="server-monitor-group"
|
class="server-monitor-group"
|
||||||
|
:class="{
|
||||||
|
'chart-type--multi': config.nazhua.monitorChartTypeToggle && monitorChartType === 'multi',
|
||||||
|
'chart-type--single': config.nazhua.monitorChartTypeToggle && monitorChartType === 'single',
|
||||||
|
}"
|
||||||
padding="16px 20px"
|
padding="16px 20px"
|
||||||
>
|
>
|
||||||
<div class="module-head-group">
|
<div class="module-head-group">
|
||||||
@ -126,6 +130,7 @@
|
|||||||
<line-chart
|
<line-chart
|
||||||
:date-list="monitorChartData.dateList"
|
:date-list="monitorChartData.dateList"
|
||||||
:value-list="[monitorChartData.valueList[index]]"
|
:value-list="[monitorChartData.valueList[index]]"
|
||||||
|
:size="240"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -234,13 +239,21 @@ const minutes = [{
|
|||||||
label: '24小时',
|
label: '24小时',
|
||||||
value: 1440,
|
value: 1440,
|
||||||
}];
|
}];
|
||||||
const refreshData = ref(true);
|
const localData = {
|
||||||
const peakShaving = ref(false);
|
peakShaving: window.localStorage.getItem('nazhua_monitor_peak_shaving'),
|
||||||
|
refreshData: window.localStorage.getItem('nazhua_monitor_refresh_data'),
|
||||||
|
chartType: window.localStorage.getItem('nazhua_monitor_chart_type'),
|
||||||
|
};
|
||||||
|
|
||||||
|
const peakShaving = validate.isSet(localData.peakShaving) ? ref(localData.peakShaving) : ref(false);
|
||||||
|
const refreshData = validate.isSet(localData.refreshData) ? ref(localData.refreshData) : ref(true);
|
||||||
const showCates = ref({});
|
const showCates = ref({});
|
||||||
const monitorData = ref([]);
|
const monitorData = ref([]);
|
||||||
const longPressTimer = ref(null);
|
const longPressTimer = ref(null);
|
||||||
|
|
||||||
const chartType = ref(config.nazhua.monitorChartType === 'single' ? 'single' : 'multi');
|
const chartType = validate.isSet(localData.chartType)
|
||||||
|
? ref(localData.chartType)
|
||||||
|
: ref(config.nazhua.monitorChartType === 'single' ? 'single' : 'multi');
|
||||||
const monitorChartType = computed(() => {
|
const monitorChartType = computed(() => {
|
||||||
if (config.nazhua.monitorChartTypeToggle) {
|
if (config.nazhua.monitorChartTypeToggle) {
|
||||||
return chartType.value;
|
return chartType.value;
|
||||||
@ -381,14 +394,17 @@ const monitorChartData = computed(() => {
|
|||||||
|
|
||||||
function switchPeakShaving() {
|
function switchPeakShaving() {
|
||||||
peakShaving.value = !peakShaving.value;
|
peakShaving.value = !peakShaving.value;
|
||||||
|
window.localStorage.setItem('nazhua_monitor_peak_shaving', peakShaving.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchRefresh() {
|
function switchRefresh() {
|
||||||
refreshData.value = !refreshData.value;
|
refreshData.value = !refreshData.value;
|
||||||
|
window.localStorage.setItem('nazhua_monitor_refresh_data', refreshData.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchChartType() {
|
function switchChartType() {
|
||||||
chartType.value = chartType.value === 'single' ? 'multi' : 'single';
|
chartType.value = chartType.value === 'single' ? 'multi' : 'single';
|
||||||
|
window.localStorage.setItem('nazhua_monitor_chart_type', chartType.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleMinute(value) {
|
function toggleMinute(value) {
|
||||||
@ -478,6 +494,10 @@ onUnmounted(() => {
|
|||||||
.server-monitor-group {
|
.server-monitor-group {
|
||||||
--line-chart-size: 300px;
|
--line-chart-size: 300px;
|
||||||
|
|
||||||
|
&.chart-type--single {
|
||||||
|
--line-chart-size: 240px;
|
||||||
|
}
|
||||||
|
|
||||||
.monitor-cate-item {
|
.monitor-cate-item {
|
||||||
--cate-item-height: 28px;
|
--cate-item-height: 28px;
|
||||||
--cate-item-font-size: 14px;
|
--cate-item-font-size: 14px;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user