【sgTopo】强哥古法炮制、纯手工打造简单拓扑图、流程图、思维导图组件(完善中ing)(一)

简介: 【sgTopo】强哥古法炮制、纯手工打造简单拓扑图、流程图、思维导图组件(完善中ing)

疯狂撸码中ing

实现组件效果

src/components/sgTopo.vue

<template>
  <!-- 强哥的拓扑图2021.09.14 -->
  <div
    class="sg-topo tree-body"
    v-if="data"
    :arrow-right="data.body.arrowRight"
    :style="data.body.style || {}"
  >
    <div
      class="topo-title main-node"
      :active="data.body.title.active"
      :style="data.body.title.style || {}"
    >
      {{ data.body.title.text }}
    </div>
    <ul
      class="topo-container"
      :style="data.body.container ? data.body.container.style || {} : {}"
    >
      <li class="tree-level" v-for="(a, $i) in data.body.data" :key="$i">
        <!-- 拓扑图类型:1 ------------------------------------------>
        <div v-if="a.type == 1" :type="a.type">
          <span
            :active="a.title.active"
            :style="a.title.style || {}"
            class="node-title"
            >{{ a.title.text }}</span
          >
          <!-- 二级树 -->
          <div v-if="a.children" class="topo-childrens">
            <div
              class="tree-body"
              gray
              v-for="(child, $i) in a.children"
              :key="$i"
            >
              <div class="tree-level">
                <span
                  :active="child.title.active"
                  :style="child.title.style || {}"
                  class="topo-title"
                  gray
                  >{{ child.title.text }}</span
                >
                <ul class="topo-container">
                  <!-- 三级节点 -->
                  <li
                    :active="childNode.title.active"
                    :style="childNode.title.style || {}"
                    v-for="(childNode, $i) in child.data"
                    :key="$i"
                    class="node-title"
                    border
                  >
                    {{ childNode.title.text }}
                  </li>
                </ul>
              </div>
            </div>
          </div>
        </div>
        <!-- 拓扑图类型:2 ------------------------------------------>
        <div v-if="a.type == 2" :type="a.type">
          <span
            :active="a.title.active"
            :style="a.title.style || {}"
            class="node-title"
            >{{ a.title.text }}</span
          >
          <!-- 二级树 -->
          <ul v-if="a.children" class="topo-childrens">
            <li class="tree-level" v-for="(child, $i) in a.children" :key="$i">
              <span
                :active="child.title.active"
                :style="child.title.style || {}"
                class="topo-title"
                >{{ child.title.text }}</span
              >
              <ul v-if="child.children" class="topo-childrens">
                <!-- 三级节点 -->
                <li
                  v-for="(childNode, $i) in child.children"
                  :key="$i"
                  class="tree-level"
                >
                  <span
                    :active="childNode.title.active"
                    :style="childNode.title.style || {}"
                    class="topo-title"
                    >{{ childNode.title.text }}</span
                  >
                </li>
              </ul>
            </li>
          </ul>
        </div>
        <!-- 拓扑图类型:3 ------------------------------------------>
        <!-- 这个类型太没规律了,担心设计师的脑回路有一定问题 -->
      </li>
    </ul>
  </div>
</template>
 
<script>
export default {
  props: ["data"],
};
</script>
 
<style lang="scss" scoped>
@import "~@/css/sg";
.tree-body {
  height: min-content;
  position: relative;
  display: inline-block;
  background: #ffffff;
  border-radius: 4px;
  border: 1px dashed #0050b3;
  box-sizing: border-box;
  padding: 10px;
 
  &[gray] {
    background: #ffffff;
    border-radius: 4px;
    border: 1px dashed #dddddd;
    box-sizing: border-box;
    padding: 10px;
    display: inline-block;
    font-size: 12px;
    width: min-content;
    flex-shrink: 0;
  }
 
  &[arrow-right]::after {
    content: url(~@/assets/softwareIndustryBigBrain/common/tree-body/tree-body-arrow.jpg); //右上角的向右箭头图片
    position: absolute;
    right: -22px;
    top: -10px;
  }
  .topo-title {
    transition: 0.618s ease;
    pointer-events: none;
    cursor: pointer;
    box-sizing: border-box;
    text-align: center;
    width: calc(100% - 40px);
    height: 30px;
    line-height: 26px;
    padding: 0 20px;
    margin: 0 auto;
    margin-top: -25px;
    background: #002766;
    border-radius: 4px;
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #ffffff;
    &[gray] {
      padding: 0 10px;
      height: 22px;
      background: #f0f2f5;
      border-radius: 11px;
      font-size: 12px;
      font-weight: 400;
      color: #999999;
      line-height: 22px;
      display: inline-block;
      width: min-content;
      white-space: nowrap;
      display: block;
      margin-top: -20px;
    }
    &.main-node[active] {
      pointer-events: auto;
      &:hover {
        background: #0050b3!important;
      }
    }
  }
  .topo-container {
    margin-top: 15px;
    .node-title {
      pointer-events: none;
      display: inline-block;
      height: 30px;
      padding: 0 20px;
      background: #40a9ff;
      border-radius: 4px;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #ffffff;
      line-height: 26px;
      display: inline-block;
      width: min-content;
      white-space: nowrap;
      cursor: pointer;
      transition: 0.618s ease;
      &:hover {
        background: #0050b3;
      }
      &[active] {
        pointer-events: auto;
        background: #0050b3;
        &:hover {
          background: #0050b3cc;
        }
      }
    }
    [type="1"] {
      text-align: center;
 
      .topo-childrens {
        display: flex;
        justify-content: space-evenly;
        margin-top: 40px;
        position: relative;
        &::before {
          content: "";
          width: 1px;
          height: 16px;
          background: #40a9ff;
          position: absolute;
          top: -42px;
        }
        &::after {
          content: "";
          width: 50px; //二级横线宽度
          height: 1px;
          background: #40a9ff;
          position: absolute;
          top: -26px;
        }
        > * {
          position: relative;
          // 默认的节点⊥
          &::before {
            position: absolute;
            content: "";
            // width: 100%;
            width: 0;
            height: 16px;
            // border-radius: 4px;
            box-sizing: border-box;
            border-right: 1px solid #40a9ff;
            top: -27px;
          }
          //第一个节点顶部的曲线╭
          &:first-of-type {
            &::before {
              border: 1px solid #40a9ff;
              border-top-left-radius: 4px;
              border-right: none;
              left: 50%;
              width: 50%;
              border-bottom: none;
            }
          }
          //最后一个节点顶部的曲线╮
          &:last-of-type {
            &::before {
              border: 1px solid #40a9ff;
              border-top-right-radius: 4px;
              border-left: none;
              right: 50%;
              width: 50%;
              border-bottom: none;
            }
          }
        }
      }
      .node-title[border] {
        pointer-events: none;
        background: #ffffff;
        border: 1px solid #40a9ff;
        color: #40a9ff;
        margin-bottom: 10px;
        &:last-of-type {
          margin-right: 0;
          margin-bottom: 0;
        }
        cursor: pointer;
        transition: 0.618s ease;
        &:hover {
          color: #0050b3;
          border-color: #0050b3;
        }
        &[active] {
          pointer-events: auto;
          color: #0050b3;
          border-color: #0050b3;
          &:hover {
            background: #40a9ff33;
          }
        }
      }
    }
    .tree-level {
      margin-bottom: 10px;
      &:last-of-type {
        margin-right: 0;
        margin-bottom: 0;
      }
    }
  }
}
// ----------------------------------------
[type="2"] {
  width: min-content;
  margin: 0 auto;
  .tree-level {
    margin-top: -5px;
    width: min-content;
    margin-left: 20px;
    //二级元素 第一个节点的左侧线条└
    &:first-of-type .topo-title::before {
      height: 25px;
      top: -11px;
    }
  }
  .topo-title {
    pointer-events: none;
    margin-top: 15px;
    background: #ffffff;
    border: 1px solid #40a9ff;
    color: #40a9ff;
    font-size: 14px;
    height: 30px;
    line-height: 26px;
    display: block;
    width: min-content;
    white-space: nowrap;
    box-sizing: border-box;
    position: relative;
    cursor: pointer;
    transition: 0.618s ease;
    + .topo-childrens {
      margin-top: 10px;
      .tree-level {
        .topo-title {
          margin-right: -30px;
          margin-top: 15px;
          //二级元素 常规点的左侧线条└
          &::before {
            height: 40px;
            top: -26px;
          }
 
          //二级元素延长线|
          &::after {
            content: "";
            position: absolute;
            top: -25px;
            left: -36px;
            height: 40px;
            width: 1px;
            background: #40a9ff;
          }
        }
        //三级元素 第一个节点的左侧线条└
        &:first-of-type .topo-title::before {
          height: 25px;
          top: -11px;
        }
      }
    }
    &:hover {
      color: #0050b3;
      border-color: #0050b3;
    }
    /* &[active] {
      &:hover {
      color: #0044b1;
        border-color: #0044b1;
      }
    } */
    &[active] {
      pointer-events: auto;
      color: #0050b3;
      border-color: #0050b3;
      &:hover {
        background: #40a9ff33;
      }
    }
    &::before {
      content: "";
      position: absolute;
      left: -16px;
      top: -25px;
      width: 16px;
      height: 40px;
      box-sizing: border-box;
      border: 1px solid #40a9ff;
      border-top: 0;
      border-right: 0;
    }
  }
  > .topo-childrens {
    display: flex;
    flex-wrap: wrap;
    margin-top: 0px;
    > .tree-level {
      margin-top: -5px;
      margin-bottom: 0;
    }
  }
  .topo-childrens {
    flex-direction: column;
    .tree-level:last-of-type {
      position: relative;
      // 用于隐藏二级元素左侧最后多余的延长线|
      &::after {
        content: "";
        position: absolute;
        top: 30px;
        left: -15px;
        width: 1px;
        height: calc(100% - 40px);
        background: white;
      }
      // 最后一个节点元素左侧线条╰
      > .topo-title:last-of-type {
        &::before {
          border-bottom-left-radius: 4px;
        }
      }
    }
  }
}
</style>



【sgTopo】强哥古法炮制、纯手工打造简单拓扑图、流程图、思维导图组件(完善中ing)(二)https://developer.aliyun.com/article/1476837

相关文章
|
6月前
|
Web App开发 前端开发 数据安全/隐私保护
从工具到“数字员工”:OpenClaw 云电脑部署与未来形态思考
本文详解如何通过阿里云部署预装OpenClaw的云电脑——即开即用的Docker容器,含桌面环境、Chrome、拼音输入法及自动备份/纯净启动等特性,全程图文指引,零配置快速体验。
464 28
从工具到“数字员工”:OpenClaw 云电脑部署与未来形态思考
|
数据可视化 Ubuntu Linux
研发实用工具,推荐一款代码统计神器GitStats
研发实用工具,推荐一款代码统计神器GitStats
2458 0
研发实用工具,推荐一款代码统计神器GitStats
|
存储 缓存 数据可视化
SourceTree使用教程图文详解
Git分布式版本控制系统是我们日常开发中不可或缺的一部分,能够大大提高我们协同工作的效率。前面的一篇文章如何玩转Git介绍过Git的相关知识。在工作中往往我们需要使用Git的可视化管理工具进行版本控制。目前市面上比较流行的Git可视化管理工具有SourceTree、Github Desktop、TortoiseGit等等,我们公司主要使用的是SourceTree。该篇文章主要结合日常开发工作的对于sourctree的一些常用操作进行讲解和总结,帮助没有使用过的同学进行快速入门,希望能对大家有所帮助!
2625 0
SourceTree使用教程图文详解
|
传感器 人工智能 运维
AR智慧运维系统介绍
阿法龙XR云平台是一款面向工业领域的增强现实(AR)智能化平台,助力企业实现数字化转型。平台集成智能巡检工作流、远程协助、AI视频验收、人脸识别等功能模块,支持AR眼镜与移动终端,提供虚实融合的运维体验。具备高度定制化能力,适配多种工业场景,提升运维效率与智能化水平。
|
人工智能 搜索推荐 前端开发
6.2k tar 热门项目,揭秘:一篇 Markdown 如何秒生成 PPT、书籍、文章
Quarkdown是一款现代化Markdown排版系统,支持编程逻辑(如函数、变量、条件语句)嵌入文档,实现内容复用与动态生成。它可一键输出为PDF、HTML幻灯片、文章或书籍等多种格式,打破传统Markdown在排版、逻辑和格式上的局限。相比Pandoc+Lua、mdBook等工具,Quarkdown更易用且功能全面,适合学术论文、技术分享、知识管理及出版流程等场景。项目地址:[https://github.com/iamgio/quarkdown](https://github.com/iamgio/quarkdown)。
813 5
|
小程序 Java 程序员
JDK 和 JRE 有什么区别
JDK(Java Development Kit)是Java开发工具包,包含编译器、调试器等开发工具,用于开发Java程序。JRE(Java Runtime Environment)是Java运行环境,包含Java虚拟机和类库,用于运行Java程序。简言之,JDK用于编写Java程序,JRE用于运行这些程序。
838 2
|
开发工具 git
Git 中 merge 和 rebase 的区别
$ git pull --rebase和$ git pull区别 是git fetch + git merge FETCH_HEAD的缩写,所以默认情况下,git pull就是先fetch,然后执行merge操作,如果加-rebase参数,就是使用git rebase代替git merge 。
31329 0
|
机器学习/深度学习 数据采集 人工智能
智能化运维的探索与实践:AI在IT运维中的应用
【6月更文挑战第19天】随着人工智能技术的不断成熟,其在IT运维领域的应用也愈发深入。本文将探讨AI技术如何赋能传统IT运维,提升效率和响应速度,实现故障预测、自动化处理及优化决策。通过分析AI在运维中的实际应用案例,我们能更好地了解其潜力与挑战,并预见未来智能化运维的发展路径。
1301 6
|
前端开发 JavaScript Go
Go 实战|使用 Wails 构建轻量级的桌面应用:仿微信登录界面 Demo
Wails 框架提供了一种简洁而强大的方式,让开发者能够利用 Go 的性能优势和 Web 前端的灵活性,从而能够使用更高效、更轻量级的方法来构建跨平台的桌面应用。本文探讨 Wails 框架的使用,从搭建环境到开发,再到最终的构建打包。
1590 1
Go 实战|使用 Wails 构建轻量级的桌面应用:仿微信登录界面 Demo
Kam
|
算法 Java Linux
使用SecureRandom生成验证码随机数,线程阻塞问题记录
使用SecureRandom生成验证码随机数,线程阻塞问题记录
Kam
1350 0

热门文章

最新文章