feat: Add system information copy button for dashboard (#10109)

Refs #9725
This commit is contained in:
ssongliu 2025-08-22 15:59:52 +08:00 committed by GitHub
parent 83cefb2a72
commit 4fcf845934
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -178,6 +178,9 @@
</el-col>
<el-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8">
<CardWithHeader :header="$t('home.systemInfo')">
<template #header-r>
<el-button class="h-button-setting" @click="handleCopy" link icon="CopyDocument" />
</template>
<template #body>
<el-scrollbar>
<el-descriptions :column="1" class="h-systemInfo" border>
@ -259,7 +262,7 @@ import LicenseImport from '@/components/license-import/index.vue';
import CardWithHeader from '@/components/card-with-header/index.vue';
import i18n from '@/lang';
import { Dashboard } from '@/api/interface/dashboard';
import { dateFormatForSecond, computeSize, computeSizeFromKBs, loadUpTime, jumpToPath } from '@/utils/util';
import { dateFormatForSecond, computeSize, computeSizeFromKBs, loadUpTime, jumpToPath, copyText } from '@/utils/util';
import { useRouter } from 'vue-router';
import { loadBaseInfo, loadCurrentInfo } from '@/api/modules/dashboard';
import { getIOOptions, getNetworkOptions } from '@/api/modules/host';
@ -485,6 +488,41 @@ const onLoadCurrentInfo = async () => {
statusRef.value?.acceptParams(currentInfo.value, baseInfo.value);
};
const handleCopy = () => {
let content =
i18n.global.t('home.hostname') +
': ' +
baseInfo.value.hostname +
'\n' +
i18n.global.t('home.platformVersion') +
': ' +
(baseInfo.value.platformVersion
? baseInfo.value.platform + '-' + baseInfo.value.platformVersion
: baseInfo.value.platform) +
'\n' +
i18n.global.t('home.kernelVersion') +
': ' +
baseInfo.value.kernelVersion +
'\n' +
i18n.global.t('home.kernelVersion') +
': ' +
baseInfo.value.kernelArch +
'\n' +
i18n.global.t('home.ip') +
': ' +
baseInfo.value.ipV4Addr +
'\n' +
i18n.global.t('home.uptime') +
': ' +
currentInfo.value.timeSinceUptime +
'\n' +
i18n.global.t('home.runningTime') +
': ' +
loadUpTime(currentInfo.value.uptime) +
'\n';
copyText(content);
};
const loadData = async () => {
if (chartOption.value === 'io') {
chartsOption.value['ioChart'] = {