<template>
	<view class="list-box">
		<TreeNode v-for="(node, idx) in monitors" :key="node.code || node.id || idx" :node="node" />
	</view>
</template>

<script>
	import TreeNode from "./TreeNode.vue";

	export default {
		components: {
			TreeNode
		},
		data() {
			return {
				monitors: []
			};
		},
		onLoad() {
			this.getMonitors();
		},
		methods: {
			async getMonitors() {
				try {
					const res = await this.$u.api.getMonitors();
					if (res.code === 200) {
						this.monitors = res.data || [];
					} else {
						this.monitors = [];
					}
				} catch (error) {
					console.error("获取监控失败", error);
					this.monitors = [];
				}
			}
		}
	};
</script>

<style>
	.list-box {
		background: #f7f7f7;
		padding-top: 25rpx;
	}
</style>