增加系统状态、logo等类名并简化部分组件dom

This commit is contained in:
Sun 2024-01-24 20:11:07 +08:00
parent bf1cc0cc00
commit 99d18df7f0
9 changed files with 77 additions and 75 deletions

View File

@ -18,11 +18,11 @@ const propClass = ref(props.class)
</script> </script>
<template> <template>
<div class="w-full"> <div class="item-card w-full">
<!-- 详情图标 --> <!-- 详情图标 -->
<div <div
v-if="cardTypeStyle === PanelPanelConfigStyleEnum.info" v-if="cardTypeStyle === PanelPanelConfigStyleEnum.info"
class="w-full rounded-2xl transition-all duration-200 flex" class="item-card-info w-full rounded-2xl transition-all duration-200 flex"
:class="propClass" :class="propClass"
:style="{ backgroundColor: backgroundColor ?? defaultBackground }" :style="{ backgroundColor: backgroundColor ?? defaultBackground }"
> >
@ -32,9 +32,10 @@ const propClass = ref(props.class)
<!-- 极简图标APP --> <!-- 极简图标APP -->
<div <div
v-if="cardTypeStyle === PanelPanelConfigStyleEnum.icon" v-if="cardTypeStyle === PanelPanelConfigStyleEnum.icon"
class="item-card-small"
> >
<div <div
class="overflow-hidden rounded-2xl sunpanel w-[70px] h-[70px] mx-auto transition-all duration-200" class="item-card-small-icon overflow-hidden rounded-2xl sunpanel w-[70px] h-[70px] mx-auto transition-all duration-200"
:class="propClass" :class="propClass"
:style="{ backgroundColor: backgroundColor ?? defaultBackground }" :style="{ backgroundColor: backgroundColor ?? defaultBackground }"
> >
@ -43,7 +44,7 @@ const propClass = ref(props.class)
<div <div
v-if="!iconTextIconHideTitle" v-if="!iconTextIconHideTitle"
class="text-center app-icon-text-shadow cursor-pointer mt-[2px]" class="item-card-small-title text-center app-icon-text-shadow cursor-pointer mt-[2px]"
:style="{ color: iconTextColor }" :style="{ color: iconTextColor }"
> >
{{ iconText }} {{ iconText }}

View File

@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
import GenericProgress from '../components/GenericProgress/index.vue' import GenericProgress from '../components/GenericProgress/index.vue'
import { correctionNumber, correctionNumberByCardStyle } from './common'
import { getCpuState } from '@/api/system/systemMonitor' import { getCpuState } from '@/api/system/systemMonitor'
import type { PanelPanelConfigStyleEnum } from '@/enums' import type { PanelPanelConfigStyleEnum } from '@/enums'
@ -16,10 +17,6 @@ const props = defineProps<Prop>()
let timer: NodeJS.Timer let timer: NodeJS.Timer
const cpuState = ref<SystemMonitor.CPUInfo | null>(null) const cpuState = ref<SystemMonitor.CPUInfo | null>(null)
function correctionNumber(v: number, keepNum = 2): number {
return v === 0 ? 0 : Number(v.toFixed(keepNum))
}
async function getData() { async function getData() {
try { try {
const { data, code } = await getCpuState<SystemMonitor.CPUInfo>() const { data, code } = await getCpuState<SystemMonitor.CPUInfo>()
@ -44,16 +41,15 @@ onUnmounted(() => {
</script> </script>
<template> <template>
<div class="w-full">
<GenericProgress <GenericProgress
:progress-color="progressColor" :progress-color="progressColor"
:progress-rail-color="progressRailColor" :progress-rail-color="progressRailColor"
:progress-height="5" :progress-height="5"
:percentage="correctionNumber(cpuState?.usages[0] || 0)" :percentage="correctionNumberByCardStyle(cpuState?.usages[0] || 0, cardTypeStyle)"
:card-type-style="cardTypeStyle" :card-type-style="cardTypeStyle"
:info-card-right-text="`${correctionNumber(cpuState?.usages[0] || 0)}%`" :info-card-right-text="`${correctionNumber(cpuState?.usages[0] || 0)}%`"
info-card-left-text="CPU" info-card-left-text="CPU"
:text-color="textColor" :text-color="textColor"
style="width: 100%;"
/> />
</div>
</template> </template>

View File

@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
import GenericProgress from '../components/GenericProgress/index.vue' import GenericProgress from '../components/GenericProgress/index.vue'
import { correctionNumberByCardStyle } from './common'
import type { PanelPanelConfigStyleEnum } from '@/enums' import type { PanelPanelConfigStyleEnum } from '@/enums'
import { bytesToSize } from '@/utils/cmn' import { bytesToSize } from '@/utils/cmn'
import { getDiskStateByPath } from '@/api/system/systemMonitor' import { getDiskStateByPath } from '@/api/system/systemMonitor'
@ -18,10 +19,6 @@ const props = defineProps<Prop>()
let timer: NodeJS.Timer let timer: NodeJS.Timer
const diskState = ref<SystemMonitor.DiskInfo | null>(null) const diskState = ref<SystemMonitor.DiskInfo | null>(null)
function correctionNumber(v: number, keepNum = 2): number {
return v === 0 ? 0 : Number(v.toFixed(keepNum))
}
function formatdiskSize(v: number): string { function formatdiskSize(v: number): string {
return bytesToSize(v) return bytesToSize(v)
} }
@ -54,16 +51,14 @@ onUnmounted(() => {
</script> </script>
<template> <template>
<div class="w-full">
<GenericProgress <GenericProgress
:progress-color="progressColor" :progress-color="progressColor"
:progress-rail-color="progressRailColor" :progress-rail-color="progressRailColor"
:progress-height="5" :progress-height="5"
:percentage="correctionNumber(diskState?.usedPercent || 0)" :percentage="correctionNumberByCardStyle(diskState?.usedPercent || 0, cardTypeStyle)"
:card-type-style="cardTypeStyle" :card-type-style="cardTypeStyle"
:info-card-right-text="`${formatdiskSize(formatdiskToByte(diskState?.used || 0))}/${formatdiskSize(formatdiskToByte(diskState?.free || 0))}`" :info-card-right-text="`${formatdiskSize(formatdiskToByte(diskState?.used || 0))}/${formatdiskSize(formatdiskToByte(diskState?.free || 0))}`"
:info-card-left-text="diskState?.mountpoint" :info-card-left-text="diskState?.mountpoint"
:text-color="textColor" :text-color="textColor"
/> />
</div>
</template> </template>

View File

@ -1,6 +1,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue' import { onMounted, onUnmounted, ref } from 'vue'
import GenericProgress from '../components/GenericProgress/index.vue' import GenericProgress from '../components/GenericProgress/index.vue'
import { correctionNumberByCardStyle } from './common'
import { getMemonyState } from '@/api/system/systemMonitor' import { getMemonyState } from '@/api/system/systemMonitor'
import type { PanelPanelConfigStyleEnum } from '@/enums' import type { PanelPanelConfigStyleEnum } from '@/enums'
import { bytesToSize } from '@/utils/cmn' import { bytesToSize } from '@/utils/cmn'
@ -17,10 +18,6 @@ const props = defineProps<Prop>()
let timer: NodeJS.Timer let timer: NodeJS.Timer
const memoryState = ref<SystemMonitor.MemoryInfo | null>(null) const memoryState = ref<SystemMonitor.MemoryInfo | null>(null)
function correctionNumber(v: number, keepNum = 2): number {
return v === 0 ? 0 : Number(v.toFixed(keepNum))
}
function formatMemorySize(v: number): string { function formatMemorySize(v: number): string {
return bytesToSize(v) return bytesToSize(v)
} }
@ -49,16 +46,14 @@ onUnmounted(() => {
</script> </script>
<template> <template>
<div class="w-full">
<GenericProgress <GenericProgress
:progress-color="progressColor" :progress-color="progressColor"
:progress-rail-color="progressRailColor" :progress-rail-color="progressRailColor"
:progress-height="5" :progress-height="5"
:percentage="correctionNumber(memoryState?.usedPercent || 0)" :percentage="correctionNumberByCardStyle(memoryState?.usedPercent || 0, cardTypeStyle)"
:card-type-style="cardTypeStyle" :card-type-style="cardTypeStyle"
:info-card-right-text="`${formatMemorySize(memoryState?.used || 0)}/${formatMemorySize((memoryState?.total || 0) - (memoryState?.used || 0) || 0)}`" :info-card-right-text="`${formatMemorySize(memoryState?.used || 0)}/${formatMemorySize((memoryState?.total || 0) - (memoryState?.used || 0) || 0)}`"
info-card-left-text="RAM" info-card-left-text="RAM"
:text-color="textColor" :text-color="textColor"
/> />
</div>
</template> </template>

View File

@ -0,0 +1,15 @@
import { PanelPanelConfigStyleEnum } from '@/enums'
export function correctionNumberByCardStyle(v: number, cardStyle: PanelPanelConfigStyleEnum): number {
let keepNum = 0
if (cardStyle === PanelPanelConfigStyleEnum.small)
keepNum = 1
else if (cardStyle === PanelPanelConfigStyleEnum.info)
keepNum = 2
return correctionNumber(v, keepNum)
}
export function correctionNumber(v: number, keepNum = 2): number {
return v === 0 ? 0 : Number(v.toFixed(keepNum))
}

View File

@ -47,7 +47,7 @@ const refreshInterval = 5000
<template #icon> <template #icon>
<!-- 图标 --> <!-- 图标 -->
<div class="w-[60px] h-[70px]"> <div class="w-[60px] h-[70px]">
<div class="w-[60px] h-full flex items-center justify-center text-white"> <div class="app-icon w-[60px] h-full flex items-center justify-center text-white">
<SvgIcon v-if="monitorType === MonitorType.cpu" icon="solar-cpu-bold" :style="{ color: extendParam.color }" style="width:35px;height:35px" /> <SvgIcon v-if="monitorType === MonitorType.cpu" icon="solar-cpu-bold" :style="{ color: extendParam.color }" style="width:35px;height:35px" />
<SvgIcon v-if="monitorType === MonitorType.memory" icon="material-symbols-memory-alt-rounded" :style="{ color: extendParam.color }" style="width:35px;height:35px" /> <SvgIcon v-if="monitorType === MonitorType.memory" icon="material-symbols-memory-alt-rounded" :style="{ color: extendParam.color }" style="width:35px;height:35px" />
<SvgIcon v-if="monitorType === MonitorType.disk" icon="clarity-hard-disk-solid" :style="{ color: extendParam.color }" style="width:35px;height:35px" /> <SvgIcon v-if="monitorType === MonitorType.disk" icon="clarity-hard-disk-solid" :style="{ color: extendParam.color }" style="width:35px;height:35px" />

View File

@ -27,7 +27,7 @@ const propClass = ref(props.class)
</script> </script>
<template> <template>
<div class="w-full"> <div class="generic-monitor-card w-full">
<ItemCard <ItemCard
:card-type-style="cardTypeStyle" :card-type-style="cardTypeStyle"
:icon-text="iconText" :icon-text="iconText"

View File

@ -17,8 +17,8 @@ defineProps<Prop>()
</script> </script>
<template> <template>
<template v-if="cardTypeStyle === PanelPanelConfigStyleEnum.info">
<div class="w-full"> <div class="w-full">
<div v-if="cardTypeStyle === PanelPanelConfigStyleEnum.info">
<div class="mb-1 text-xs" :style="{ color: textColor }"> <div class="mb-1 text-xs" :style="{ color: textColor }">
<span> <span>
{{ infoCardLeftText }} {{ infoCardLeftText }}
@ -38,8 +38,9 @@ defineProps<Prop>()
style="max-width: 135px;" style="max-width: 135px;"
/> />
</div> </div>
<div v-else> </template>
<div class="flex justify-center h-full w-full mt-3"> <template v-else>
<div class="w-full flex justify-center h-full w-full mt-3">
<NProgress <NProgress
:color="progressColor" :color="progressColor"
:rail-color="progressRailColor" :rail-color="progressRailColor"
@ -52,6 +53,5 @@ defineProps<Prop>()
</div> </div>
</NProgress> </NProgress>
</div> </div>
</div> </template>
</div>
</template> </template>

View File

@ -325,7 +325,7 @@ function handleAddItem(itemIconGroupId?: number) {
<template> <template>
<div class="w-full h-full sun-main"> <div class="w-full h-full sun-main">
<div <div
class="cover" :style="{ class="cover wallpaper" :style="{
filter: `blur(${panelState.panelConfig.backgroundBlur}px)`, filter: `blur(${panelState.panelConfig.backgroundBlur}px)`,
background: `url(${panelState.panelConfig.backgroundImageSrc}) no-repeat`, background: `url(${panelState.panelConfig.backgroundImageSrc}) no-repeat`,
backgroundSize: 'cover', backgroundSize: 'cover',
@ -345,12 +345,12 @@ function handleAddItem(itemIconGroupId?: number) {
<!-- --> <!-- -->
<div class="mx-[auto] w-[80%]"> <div class="mx-[auto] w-[80%]">
<div class="flex mx-[auto] items-center justify-center text-white"> <div class="flex mx-[auto] items-center justify-center text-white">
<div> <div class="logo">
<span class="text-2xl md:text-6xl font-bold text-shadow"> <span class="text-2xl md:text-6xl font-bold text-shadow">
{{ panelState.panelConfig.logoText }} {{ panelState.panelConfig.logoText }}
</span> </span>
</div> </div>
<div class="text-base lg:text-2xl mx-[10px]"> <div class="divider text-base lg:text-2xl mx-[10px]">
| |
</div> </div>
<div class="text-shadow"> <div class="text-shadow">