提交测试versionTree

This commit is contained in:
X1627315083
2026-02-03 11:24:47 +08:00
parent 6f8091a5c5
commit cf010e570d
12 changed files with 659 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<script setup lang="ts">
import { ref, onMounted, onUnmounted, reactive, toRefs, computed } from "vue";
import VersionTreeIndex from './versionTree/index.vue'
//const props = defineProps({
//})
//const emit = defineEmits([
//])
let data = reactive({
})
const versionTreeData = ref({
drawer:false,
list:computed(()=>{
return []
})
})
onMounted(()=>{
})
onUnmounted(()=>{
})
defineExpose({})
const {} = toRefs(data);
</script>
<template>
<div class="homeNavBox">
<el-button type="primary" @click="versionTreeData.drawer = true">open Version Tree</el-button>
<VersionTreeIndex v-model:versionTreeData="versionTreeData" />
</div>
</template>
<style lang="less" scoped>
.homeNavBox{
width: 100%;
height: 100%;
position: relative;
}
</style>

View File

@@ -0,0 +1,110 @@
<script setup lang="ts">
import { ref, onMounted, onUnmounted, reactive, toRefs } from "vue";
import Tree from './tree/index.vue'
const props = defineProps({
versionTreeData:{
type:Object,
default:()=>{
return {
drawer:false,
list:[],
}
},
},
})
//const emit = defineEmits([
//])
const treeState = ref(false)//
const openTree = ()=>{
treeState.value = !treeState.value
}
let data = reactive({
})
onMounted(()=>{
})
onUnmounted(()=>{
})
defineExpose({})
const {} = toRefs(data);
</script>
<template>
<div class="versionTree">
<el-drawer
v-model="versionTreeData.drawer"
:close-on-press-escape="false"
:close-on-click-modal="false"
:size="treeState?'109rem':'49rem'"
body-class="versionTreeBody"
:with-header="false">
<div class="versionTreeTitle">
<span>Version Tree: Retro Sofa Sketch</span>
<div class="closeBtn" @click="versionTreeData.drawer = false">
<div class="closeIcon">
<SvgIcon name="close" />
</div>
</div>
</div>
<div style="display: flex;">
<el-button class="expandBtn" @click="openTree" style="width: 5rem;">+</el-button>
<el-button class="expandBtn" @click="openTree" style="width: 5rem;">-</el-button>
</div>
<div class="versionTreeBox">
<div class="tree">
<Tree :treeState="treeState"></Tree>
</div>
<div class="detail">
</div>
</div>
</el-drawer>
</div>
</template>
<style lang="less" scoped>
.versionTree{
--border-radius: 1rem;
:deep(.versionTreeBody){
--el-drawer-padding-primary: 0rem;
display: flex;
flex-direction: column;
}
.versionTreeTitle{
width: 100%;
height: 8rem;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 .8rem 0 1.2rem;
border-bottom: 1px solid #C9C9C9;
> span{
font-size: 2rem;
font-weight: 600;
}
> .closeBtn{
width: 2.4rem;
height: 2.4rem;
cursor: pointer;
}
}
.versionTreeBox{
flex: 1;
display: flex;
overflow: hidden;
> .tree{
flex: 1;
height: 100%;
overflow: hidden;
padding: 1.8rem 0 1.8rem 2.1rem;
}
> .detail{
width: 35rem;
margin: 1.4rem 3rem 0 3.4rem;
height: 100%;
overflow: auto;
background-color: #F5F5F5;
}
}
}
</style>

View File

@@ -0,0 +1,71 @@
<script setup lang="ts">
import { ref, onMounted, onUnmounted, reactive, toRefs, watch } from "vue";
import view1Item from './view1Item.vue'
import view2 from './view2/index.vue'
const props = defineProps({
treeState:{
default:false,
},
})
//const emit = defineEmits([
//])
let data = reactive({
})
const treeStateTime = ref(true)
watch(()=>props.treeState,(newVal,oldVal)=>{
treeStateTime.value = false
setTimeout(()=>{
treeStateTime.value = true
},250)
})
const view1List = ref([
{
name:'P1',
},{
name:'V1',
},{
name:'V1-1',
}
])
onMounted(()=>{
})
onUnmounted(()=>{
})
defineExpose({})
const {} = toRefs(data);
</script>
<template>
<div class="tree" v-show="treeStateTime">
<div v-if="!treeState" class="box view1">
<view1Item v-for="item in view1List" :key="item.name" :item="item"></view1Item>
</div>
<div v-else class="box view2">
<view2 :list="view1List"></view2>
</div>
</div>
</template>
<style lang="less" scoped>
.tree{
width: 100%;
height: 100%;
position: relative;
.box{
width: 100%;
height: 100%;
box-sizing: border-box;
&.view1{
overflow-y: auto;
}
&.view2{
border: 1px solid #D9D9D9;
background-color: #f7f7f7;
border-radius: var(--border-radius, 1rem);
}
}
}
</style>

View File

@@ -0,0 +1,70 @@
<script setup lang="ts">
import { ref, onMounted, onUnmounted, reactive, toRefs } from "vue";
const props = defineProps({
item: {
type: Object,
default: () => ({})
}
})
//const emit = defineEmits([
//])
let data = reactive({
})
onMounted(()=>{
})
onUnmounted(()=>{
})
defineExpose({})
const {} = toRefs(data);
</script>
<template>
<div class="btn">
{{ item.name }}
</div>
</template>
<style lang="less" scoped>
.btn{
font-size: 1.2rem;
width: 5rem;
height: 5rem;
font-weight: 500;
display: flex;
align-items: center;
justify-content: center;
border-radius: 50%;
border: 2px solid #000;
color: #000;
cursor: pointer;
margin-bottom: 4rem;
position: relative;
&::after{
content: '';
cursor: auto;
position: absolute;
top: calc(100% + 2px);
height: 4rem;
left: 50%;
width: 1.8px;
transform: translateX(-50%);
background:
repeating-linear-gradient(0deg, #333 0, #333 5px, transparent 5px, transparent 10px),
linear-gradient(white, white);
background-clip: padding-box, border-box;
background-origin: border-box;
}
&.active{
background-color: #e6e6e6;
}
}
.btn:nth-child(1){
background-color: #7A7A7A;
color: #FFF;
border: 2px solid #7A7A7A;
}
.btn:last-child{
margin-bottom: 0;
&::after{
display: none;
}
}
</style>

View File

@@ -0,0 +1,63 @@
<script setup lang="ts">
import { ref, onMounted, onUnmounted, reactive, toRefs } from "vue";
import type { Node, Edge } from '@vue-flow/core'
import { VueFlow } from '@vue-flow/core'
import SpecialEdge from './speciaiEdge.vue'
import SpecialNode from './speciaiNode.vue'
const props = defineProps({
item: {
type: Object,
default: () => ({})
}
})
//const emit = defineEmits([
//])
let data = reactive({
})
const nodes = ref<Node[]>([
{ id: '1', type: 'input', label: 'Node 1', position: { x: 250, y: 0 } },
{ id: '2', type: 'output', label: 'Node 2', position: { x: 100, y: 100 } },
{ id: '3', type: 'custom', label: 'Node 3', position: { x: 400, y: 100 } },
{ id: '4', type: 'custom', label: 'Node 3', position: { x: 400, y: 200 } },
])
const edges = ref<Edge[]>([
{ id: 'e1-2', source: '1', target: '2', type: 'custom' },
{ id: 'e1-3', source: '1', target: '3', animated: true },
{ id: 'e1-4', source: '1', target: '4', },
])
onMounted(()=>{
})
onUnmounted(()=>{
})
defineExpose({})
const {} = toRefs(data);
</script>
<template>
<div class="view2">
<VueFlow :nodes="nodes" :edges="edges">
<!-- bind your custom node type to a c omponent by using slots, slot names are always `node-<type>` -->
<template #node-custom="nodeProps">
<SpecialNode v-bind="nodeProps" />
</template>
<!-- <template #edge-custom="edgeProps">
<SpecialEdge v-bind="edgeProps" />
</template> -->
</VueFlow>
</div>
</template>
<style lang="less">
@import "@vue-flow/core/dist/style.css";
@import "@vue-flow/core/dist/theme-default.css";
</style>
<style lang="less" scoped>
.view2{
width: 100%;
height: 100%;
overflow: hidden;
}
</style>

View File

@@ -0,0 +1,45 @@
<script lang="ts" setup>
import { computed } from 'vue'
import type { EdgeProps } from '@vue-flow/core'
import { BaseEdge, EdgeLabelRenderer, getBezierPath, useVueFlow } from '@vue-flow/core'
const props = defineProps<EdgeProps>()
const { removeEdges } = useVueFlow()
const path = computed(() => getBezierPath(props))
</script>
<script lang="ts">
export default {
inheritAttrs: false,
}
</script>
<template>
<BaseEdge :path="path[0]" />
<EdgeLabelRenderer>
<div
:style="{
pointerEvents: 'all',
position: 'absolute',
transform: `translate(-50%, -50%) translate(${path[1]}px,${path[2]}px)`,
}"
class="nodrag nopan"
>
<button class="edgebutton" @click="removeEdges(id)">×</button>
</div>
</EdgeLabelRenderer>
</template>
<style>
.edgebutton {
border-radius: 999px;
cursor: pointer;
}
.edgebutton:hover {
box-shadow: 0 0 0 2px pink, 0 0 0 4px #f05f75;
}
</style>

View File

@@ -0,0 +1,55 @@
<script lang="ts" setup>
import { Handle, Position } from '@vue-flow/core'
import { ref } from 'vue'
const counter = ref(0)
</script>
<template>
<div class="custom-node">
<Handle type="target" :position="Position.Top" />
<button class="increment nodrag" @click="counter++">Increment</button>
<div v-if="counter > 0" class="counter">
<div class="count" v-for="count of counter" :key="`count-${count}`">{{ count }}</div>
</div>
</div>
</template>
<style>
.custom-node {
min-width: 100px;
gap: 4px;
padding: 8px;
background: white;
border: 1px solid black;
border-radius: 4px;
}
.increment {
border-radius: 4px;
background: #42b983;
font-size: 10px;
color: #fff;
cursor: pointer;
border: none;
}
.increment:hover {
box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}
.counter {
margin-top: 8px;
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 4px;
}
.count {
font-size: 6px;
color: #ff0072;
border: 1px solid rgba(0, 0, 0, 0.3);
border-radius: 8px;
}
</style>