mirror of
https://github.com/hi2shark/nazhua.git
synced 2026-01-19 02:30:43 +08:00
Compare commits
No commits in common. "f8cef00bfd71d5cf1ef6071f5d986b0392d6b58b" and "482e29579a4f8bff8d053bbbe5ea38de68a0096f" have entirely different histories.
f8cef00bfd
...
482e29579a
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "nazhua",
|
"name": "nazhua",
|
||||||
"version": "0.4.20",
|
"version": "0.4.19",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
|
|||||||
@ -36,29 +36,10 @@ export default (
|
|||||||
},
|
},
|
||||||
formatter: (params) => {
|
formatter: (params) => {
|
||||||
const time = dayjs(parseInt(params[0].axisValue, 10)).format('YYYY.MM.DD HH:mm');
|
const time = dayjs(parseInt(params[0].axisValue, 10)).format('YYYY.MM.DD HH:mm');
|
||||||
let res = `<p style="font-weight: bold; color: #ff6;">${time}</p>`;
|
let res = `${time}<br>`;
|
||||||
if (params.length < 10) {
|
|
||||||
params.forEach((i) => {
|
params.forEach((i) => {
|
||||||
res += `${i.marker} ${i.seriesName}: ${i.value[1]}ms<br>`;
|
res += `${i.marker} ${i.seriesName}: ${i.value[1]}ms<br>`;
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
res += '<table>';
|
|
||||||
let trEnd = false;
|
|
||||||
params.forEach((i, index) => {
|
|
||||||
if (index % 2 === 0) {
|
|
||||||
res += '<tr>';
|
|
||||||
}
|
|
||||||
res += `<td style="padding: 0 4px;">${i.marker} ${i.seriesName}: ${i.value[1]}ms</td>`;
|
|
||||||
if (index % 2 === 1) {
|
|
||||||
res += '</tr>';
|
|
||||||
trEnd = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!trEnd) {
|
|
||||||
res += '</tr>';
|
|
||||||
}
|
|
||||||
res += '</table>';
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
backgroundColor: mode === 'dark' ? 'rgba(0, 0, 0, 0.7)' : 'rgba(255, 255, 255, 0.7)',
|
backgroundColor: mode === 'dark' ? 'rgba(0, 0, 0, 0.7)' : 'rgba(255, 255, 255, 0.7)',
|
||||||
|
|||||||
@ -166,8 +166,10 @@ const showCates = ref({});
|
|||||||
|
|
||||||
const monitorData = ref([]);
|
const monitorData = ref([]);
|
||||||
|
|
||||||
const now = ref(Date.now());
|
const accpetShowTime = computed(() => {
|
||||||
const accpetShowTime = computed(() => now.value - (minute.value * 60 * 1000));
|
const now = store.state.serverTime || Date.now();
|
||||||
|
return now - (minute.value * 60 * 1000);
|
||||||
|
});
|
||||||
|
|
||||||
const minuteActiveArrowStyle = computed(() => {
|
const minuteActiveArrowStyle = computed(() => {
|
||||||
const index = minutes.findIndex((i) => i.value === minute.value);
|
const index = minutes.findIndex((i) => i.value === minute.value);
|
||||||
@ -306,7 +308,6 @@ function switchRefresh() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toggleMinute(value) {
|
function toggleMinute(value) {
|
||||||
now.value = store.state.serverTime || Date.now();
|
|
||||||
minute.value = value;
|
minute.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,7 +328,6 @@ async function loadMonitor() {
|
|||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
});
|
});
|
||||||
now.value = store.state.serverTime || Date.now();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let loadMonitorTimer = null;
|
let loadMonitorTimer = null;
|
||||||
|
|||||||
@ -39,11 +39,9 @@ export function getThreshold(data, tolerance = 2) {
|
|||||||
const lineColorMap = {};
|
const lineColorMap = {};
|
||||||
const lineColors = [];
|
const lineColors = [];
|
||||||
const defaultColors = [
|
const defaultColors = [
|
||||||
'#5470C6', '#91CC75', '#FAC858', '#EE6666',
|
'#5470c6', '#91cc75', '#fac858',
|
||||||
'#73C0DE', '#3BA272', '#FC8452', '#9A60B4',
|
'#ee6666', '#73c0de', '#3ba272',
|
||||||
'#EA7CCC', '#C23531', '#2F4554', '#61A0A8',
|
'#fc8452', '#9a60b4', '#ea7ccc',
|
||||||
'#D48265', '#91C7AE', '#749F83', '#CA8622',
|
|
||||||
'#BDA29A', '#6E7074', '#546570', '#C4CCD3',
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,24 +76,20 @@ function rgbDistance(color1, color2) {
|
|||||||
* 获取一个随机颜色
|
* 获取一个随机颜色
|
||||||
* @returns {string} 返回一个随机颜色的字符串
|
* @returns {string} 返回一个随机颜色的字符串
|
||||||
*/
|
*/
|
||||||
function getColor(count = 0, len = 0) {
|
function getColor() {
|
||||||
// 如果尝试次数超过 3 次,返回固定颜色组里面的颜色
|
|
||||||
if (count > 3) {
|
|
||||||
return defaultColors[len % defaultColors.length];
|
|
||||||
}
|
|
||||||
const { color } = uniqolor.random({
|
const { color } = uniqolor.random({
|
||||||
saturation: [75, 90],
|
saturation: [75, 90],
|
||||||
lightness: [65, 70],
|
lightness: [65, 70],
|
||||||
differencePoint: 100,
|
differencePoint: 100,
|
||||||
});
|
});
|
||||||
if (lineColors.includes(color)) {
|
if (lineColors.includes(color)) {
|
||||||
return getColor(count + 1, len);
|
return getColor();
|
||||||
}
|
}
|
||||||
if (lineColors.some((i) => rgbDistance(
|
if (lineColors.some((i) => rgbDistance(
|
||||||
hexToRgb(i),
|
hexToRgb(i),
|
||||||
hexToRgb(color),
|
hexToRgb(color),
|
||||||
) < 50)) {
|
) < 80)) {
|
||||||
return getColor(count + 1, len);
|
return getColor();
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
@ -110,7 +104,14 @@ export function getLineColor(name) {
|
|||||||
if (lineColorMap[name]) {
|
if (lineColorMap[name]) {
|
||||||
return lineColorMap[name];
|
return lineColorMap[name];
|
||||||
}
|
}
|
||||||
const color = getColor(0, lineColors.length);
|
// 如果默认颜色还有剩余,直接使用
|
||||||
|
if (defaultColors.length > 0) {
|
||||||
|
const color = defaultColors.shift();
|
||||||
|
lineColorMap[name] = color;
|
||||||
|
lineColors.push(color);
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
const color = getColor();
|
||||||
lineColorMap[name] = color;
|
lineColorMap[name] = color;
|
||||||
lineColors.push(color);
|
lineColors.push(color);
|
||||||
return color;
|
return color;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user