refactor(frontend): widgets/server-metric内の型エラーを除去 (#12937)

This commit is contained in:
zyoshoka 2024-01-07 23:56:46 +09:00 committed by GitHub
parent fd519f5def
commit 0e536bdd86
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 103 additions and 30 deletions

View file

@ -80,13 +80,13 @@ import * as Misskey from 'misskey-js';
import { v4 as uuid } from 'uuid';
const props = defineProps<{
connection: any,
connection: Misskey.ChannelConnection<Misskey.Channels['serverStats']>,
meta: Misskey.entities.ServerInfoResponse
}>();
const viewBoxX = ref<number>(50);
const viewBoxY = ref<number>(30);
const stats = ref<any[]>([]);
const stats = ref<Misskey.entities.ServerStats[]>([]);
const cpuGradientId = uuid();
const cpuMaskId = uuid();
const memGradientId = uuid();
@ -107,6 +107,7 @@ onMounted(() => {
props.connection.on('statsLog', onStatsLog);
props.connection.send('requestLog', {
id: Math.random().toString().substring(2, 10),
length: 50,
});
});
@ -115,7 +116,7 @@ onBeforeUnmount(() => {
props.connection.off('statsLog', onStatsLog);
});
function onStats(connStats) {
function onStats(connStats: Misskey.entities.ServerStats) {
stats.value.push(connStats);
if (stats.value.length > 50) stats.value.shift();
@ -136,8 +137,8 @@ function onStats(connStats) {
memP.value = (connStats.mem.active / props.meta.mem.total * 100).toFixed(0);
}
function onStatsLog(statsLog) {
for (const revStats of [...statsLog].reverse()) {
function onStatsLog(statsLog: Misskey.entities.ServerStatsLog) {
for (const revStats of statsLog.reverse()) {
onStats(revStats);
}
}