完成系统监控
This commit is contained in:
parent
cdf16277ff
commit
899c945fff
@ -1,14 +1,15 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { nextTick, onMounted, ref } from 'vue'
|
import { nextTick, onMounted, ref } from 'vue'
|
||||||
import { VueDraggable } from 'vue-draggable-plus'
|
import { VueDraggable } from 'vue-draggable-plus'
|
||||||
import { NButton, NDropdown, useDialog } from 'naive-ui'
|
import { NButton, NDropdown, useDialog, useMessage } from 'naive-ui'
|
||||||
import AppIconSystemMonitor from './AppIconSystemMonitor/index.vue'
|
import AppIconSystemMonitor from './AppIconSystemMonitor/index.vue'
|
||||||
import type { CardStyle, MonitorData } from './typings'
|
import { type CardStyle, type MonitorData, MonitorType } from './typings'
|
||||||
import Edit from './Edit/index.vue'
|
import Edit from './Edit/index.vue'
|
||||||
import { deleteByIndex, getAll, saveAll } from './common'
|
import { deleteByIndex, getAll, saveAll } from './common'
|
||||||
import { usePanelState } from '@/store'
|
import { usePanelState } from '@/store'
|
||||||
import { PanelPanelConfigStyleEnum } from '@/enums'
|
import { PanelPanelConfigStyleEnum } from '@/enums'
|
||||||
import { SvgIcon } from '@/components/common'
|
import { SvgIcon } from '@/components/common'
|
||||||
|
import { t } from '@/locales'
|
||||||
|
|
||||||
interface MonitorGroup extends Panel.ItemIconGroup {
|
interface MonitorGroup extends Panel.ItemIconGroup {
|
||||||
sortStatus?: boolean
|
sortStatus?: boolean
|
||||||
@ -23,6 +24,7 @@ const props = defineProps<{
|
|||||||
const panelState = usePanelState()
|
const panelState = usePanelState()
|
||||||
|
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
|
const ms = useMessage()
|
||||||
|
|
||||||
const dropdownMenuX = ref(0)
|
const dropdownMenuX = ref(0)
|
||||||
const dropdownMenuY = ref(0)
|
const dropdownMenuY = ref(0)
|
||||||
@ -72,6 +74,24 @@ function handleClick(index: number, item: MonitorData) {
|
|||||||
|
|
||||||
async function getData() {
|
async function getData() {
|
||||||
monitorDatas.value = await getAll()
|
monitorDatas.value = await getAll()
|
||||||
|
|
||||||
|
if (monitorDatas.value.length === 0) {
|
||||||
|
// 防止空 - 默认数据
|
||||||
|
monitorDatas.value.push(
|
||||||
|
{
|
||||||
|
extendParam: {
|
||||||
|
backgroundColor: '#2a2a2a6b',
|
||||||
|
color: '#fff',
|
||||||
|
progressColor: '#fff',
|
||||||
|
progressRailColor: '#CFCFCFA8',
|
||||||
|
},
|
||||||
|
monitorType: MonitorType.cpu,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
// 生成并保存
|
||||||
|
saveAll(monitorDatas.value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@ -104,7 +124,7 @@ function handleContextMenu(e: MouseEvent, index: number | null, item: MonitorDat
|
|||||||
function getDropdownMenuOptions() {
|
function getDropdownMenuOptions() {
|
||||||
const dropdownMenuOptions = [
|
const dropdownMenuOptions = [
|
||||||
{
|
{
|
||||||
label: '删除',
|
label: t('common.delete'),
|
||||||
key: 'delete',
|
key: 'delete',
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
@ -134,6 +154,10 @@ function handleRightMenuSelect(key: string | number) {
|
|||||||
positiveText: '确定',
|
positiveText: '确定',
|
||||||
negativeText: '取消',
|
negativeText: '取消',
|
||||||
onPositiveClick: () => {
|
onPositiveClick: () => {
|
||||||
|
if (monitorDatas.value.length <= 1) {
|
||||||
|
ms.warning(t('common.leastOne'))
|
||||||
|
return
|
||||||
|
}
|
||||||
if (currentRightSelectIndex.value !== null)
|
if (currentRightSelectIndex.value !== null)
|
||||||
deleteOneByIndex(currentRightSelectIndex.value)
|
deleteOneByIndex(currentRightSelectIndex.value)
|
||||||
},
|
},
|
||||||
|
@ -40,6 +40,7 @@ export default {
|
|||||||
regularUser: '普通',
|
regularUser: '普通',
|
||||||
admin: '管理',
|
admin: '管理',
|
||||||
},
|
},
|
||||||
|
leastOne: '请至少保留一项',
|
||||||
},
|
},
|
||||||
setting: {
|
setting: {
|
||||||
setting: '设置',
|
setting: '设置',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user