feat:组件调整

This commit is contained in:
weiwei committed 2025-09-15 19:27:49 +08:00
1 parent afe6ab17f8
commit bf5828ef4d
11 files changed
+180 -273

No files matched your search

+59
View File
@@ -0,0 +1,59 @@
<template>
<view class="tree-container">
<view v-for="item in nodeData" :key="item.id">
<view
class="tree-item"
:style="item.id == selectedNode.id ? { borderColor: '#1879ff' } : { color: '#000' }"
@click.stop="toCurrentNode(item)"
>
<image class="tree-item-icon" :src="filePath(item.picUrl)" />
<text>{{ item.name }}</text>
</view>
<node-tree
v-model="selectedNode"
v-if="item.children && item.children.length"
:node-data="item.children"
:style="{ marginLeft: `${getLevel(item.level) * 60}rpx` }"
@currentNode="(v) => emit('currentNode', v)"
/>
</view>
</view>
</template>
<script setup lang="ts">
import { filePath } from "../utils/file"
import NodeTree from "./node-tree.vue"
withDefaults(defineProps<{ nodeData: any[] }>(), { nodeData: () => [] })
const emit = defineEmits(["currentNode"])
const selectedNode = defineModel<any>("modelValue")
const toCurrentNode = (item) => {
emit("currentNode", item)
selectedNode.value = item
}
const getLevel = (level) => {
return level
}
</script>
<style scoped>
.tree-container {
overflow: hidden;
}
.tree-item {
border: 4rpx solid #e4e7ed77;
margin-bottom: 16rpx;
display: flex;
align-items: center;
padding: 10rpx 20rpx;
border-radius: 10rpx;
}
.tree-item-icon {
width: 40rpx;
height: 40rpx;
margin-right: 10rpx;
}
</style>