指导手册:左侧树更改

This commit is contained in:
guoyue 2022-07-14 14:16:49 +08:00
parent de1868eb5c
commit 310a5f837d
2 changed files with 84 additions and 105 deletions

View File

@ -2,7 +2,7 @@
<div class="list-box"> <div class="list-box">
<div class="list-item" v-for="(item, i) in newDataList" :key="i" @click.stop="showChildren(item)"> <div class="list-item" v-for="(item, i) in newDataList" :key="i" @click.stop="showChildren(item)">
<a-tooltip placement="top" :title="item.title" arrow-point-at-center> <a-tooltip placement="top" :title="item.title" arrow-point-at-center>
<div :class="[clickData.title === item.title && item.isSelect ? 'select' : '', level === 1 ? 'parent' : '', judgeLeaf(item) ? 'leaf' : '']" <div :class="[newClickData.title === item.title ? 'select' : '', level === 1 ? 'parent' : '', judgeLeaf(item) ? 'leaf' : '']"
class="list-text"> class="list-text">
{{ item.title }} {{ item.title }}
<DownOutlined v-show="!item.show && !judgeLeaf(item)" /> <DownOutlined v-show="!item.show && !judgeLeaf(item)" />
@ -28,10 +28,6 @@ const props = defineProps({
type: Array, type: Array,
default: () => [] default: () => []
}, },
selectName: {
type: String,
default: ''
},
level: { level: {
type: Number, type: Number,
default: 1 default: 1
@ -59,15 +55,13 @@ const judgeLeaf = (item) => {
} }
const showChildren = (item) => { const showChildren = (item) => {
if (!item.children) { if (!(item.children && item.children.length > 0)) {
if (newClickData.value.title !== '') { if (newClickData.value.title !== '') {
handleTreeItem(item) handleTreeItem(item)
} else { } else {
handleTreeItem({ title: '' }) handleTreeItem({ title: '' })
} }
item.isSelect = !item.isSelect;
} }
if (item.children && item.children.length > 0) { if (item.children && item.children.length > 0) {
item.show = !item.show; item.show = !item.show;
} }
@ -113,33 +107,31 @@ const handleTreeItem = (item) => {
&:hover { &:hover {
color: #0058e1; color: #0058e1;
cursor: pointer;
} }
} }
.normal {
color: #333;
}
.parent { .parent {
margin-bottom: 10px; margin-bottom: 10px;
background: rgba(0, 135, 225, 0.1); background: rgba(0, 135, 225, 0.1);
color: #333; color: #333;
// margin-bottom: 10px;
&:hover { &:hover {
color: #fff; color: #fff;
background: #0058e1; background: #0058e1;
cursor: pointer;
} }
} }
.leaf { .leaf {
font-size: 14px; font-size: 14px;
color: #555; color: #555;
cursor: pointer;
} }
.select { .select {
color: #0058e1; color: #0058e1;
font-weight: 600; font-weight: 600;
cursor: pointer;
} }
</style> </style>

View File

@ -2,6 +2,7 @@
<div class="menu-box"> <div class="menu-box">
<home-header></home-header> <home-header></home-header>
<div id="container" class="content-menu"> <div id="container" class="content-menu">
<div class="rela">
<div class="left"> <div class="left">
<div class="first-title-text" v-for="(data, i) in titleList" :key="i" @click="changeName(data)" <div class="first-title-text" v-for="(data, i) in titleList" :key="i" @click="changeName(data)"
:style="{ color: data.name === titleData.name ? '#0058e1' : '' }"> :style="{ color: data.name === titleData.name ? '#0058e1' : '' }">
@ -11,13 +12,18 @@
<abilityDocTree :dataList="treeArray" @treeClick="treeClick" :clickData="clickData"></abilityDocTree> <abilityDocTree :dataList="treeArray" @treeClick="treeClick" :clickData="clickData"></abilityDocTree>
</div> </div>
<div class="right"> <div class="right">
<div v-if="titleData.name === '新手指引'">新手指引</div> <div class="new-menu-box" style="height:100%" v-if="titleData.name === '新手指引'">
<!-- 新手指引 -->
<a-empty description="新手指引" />
</div>
<div v-else style="height:100%"> <div v-else style="height:100%">
<iframe name="iframeName" width="1000" height="100%" id="iframeId" :frameborder="0" <iframe name="iframeName" width="1000" height="100%" id="iframeId" :frameborder="0"
:src="clickData.doc"></iframe> :src="clickData.doc"></iframe>
</div> </div>
</div> </div>
</div> </div>
</div>
</div> </div>
</template> </template>
<script setup> <script setup>
@ -26,6 +32,7 @@ import abilityDocTree from './components/abilityDocTree'
import { ref, reactive, onMounted, nextTick, watch } from 'vue' import { ref, reactive, onMounted, nextTick, watch } from 'vue'
import { Empty, message } from 'ant-design-vue' import { Empty, message } from 'ant-design-vue'
import { getDevelopDocTree } from '@/api/home' import { getDevelopDocTree } from '@/api/home'
import flatten from '@turf/flatten'
const titleList = ref([ const titleList = ref([
{ {
@ -39,12 +46,13 @@ const titleList = ref([
]) ])
const titleData = ref(titleList.value[0]) const titleData = ref(titleList.value[0])
const clickData = ref({}) const clickData = ref({})
let typeList = ['组件服务', '应用资源', '基础设施', '数据资源', '知识库'];
const treeArray = ref([]) const treeArray = ref([])
const treeArrayCopy = ref([])
let typeList = ['组件服务', '应用资源', '基础设施', '数据资源', '知识库'];
const treeClick = (item) => { const treeClick = (item) => {
console.log('item---treeClick--------->', item);
clickData.value = item; clickData.value = item;
console.log('clickData------------>', item);
titleData.value = titleList.value[1] titleData.value = titleList.value[1]
} }
@ -55,13 +63,56 @@ const getTreeData = () => {
return message.error(res.data.msg) return message.error(res.data.msg)
} }
treeArray.value = res.data.data || []; treeArray.value = res.data.data || [];
treeArrayCopy.value = JSON.parse(JSON.stringify(treeArray.value))
}).catch((err) => { }).catch((err) => {
message.error(err) message.error(err)
}); });
} }
const changeName = (item) => { const changeName = (item) => {
titleData.value = item titleData.value = item;
if (item.name == '新手指引') {
clickData.value = {}
}
if (item.name == '技术文档') {
if (!clickData.value.title) {
clickData.value = {}
treeArray.value = [];
treeArrayCopy.value.map((val, i) => {
let obj = Object.assign({}, val, {
title: val.title,
show: (i === 0 && val.children && val.children.length > 0) || typeList.includes(val.title) ? true : false,
children: []
})
formData(val.children, obj)
treeArray.value.push(obj)
})
getFirstData(treeArrayCopy.value[0] || {})
}
}
}
const formData = (children = [], dataItem) => {
children.map((item, index) => {
let _obj = Object.assign({}, item, {
title: item.title,
show: (index === 0 && item.children && item.children.length > 0) || typeList.includes(item.title) ? true : false,
children: []
})
if (item.children && item.children.length > 0) {
formData(item.children, _obj)
}
dataItem.children.push(_obj)
})
}
const getFirstData = (firstObj = {}) => {
if (firstObj && firstObj.children && firstObj.children.length > 0) {
getFirstData(firstObj.children[0])
} else {
clickData.value = firstObj
}
} }
onMounted(() => { onMounted(() => {
@ -69,18 +120,6 @@ onMounted(() => {
}) })
watch(
() => clickData.value,
(val) => {
if (val) {
console.log('val-watch---clickData-------->', val);
}
},
{
deep: true,
}
)
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
@ -103,21 +142,12 @@ watch(
} }
.content-menu { .content-menu {
// width: 1240px;
// display: flex;
// justify-content: flex-start;
// margin: 0 auto;
// margin-top: 74px;
// box-sizing: border-box;
// position: relative;
width: 1240px; width: 1240px;
display: flex; display: flex;
justify-content: flex-start; justify-content: flex-start;
margin: 0 auto; margin: 0 auto;
margin-top: 74px; margin-top: 74px;
box-sizing: border-box; box-sizing: border-box;
/* height: calc(100vh - 306px); */
position: fixed; position: fixed;
left: 50%; left: 50%;
bottom: 0; bottom: 0;
@ -132,14 +162,14 @@ watch(
height: 600px; height: 600px;
margin-right: 20px; margin-right: 20px;
background: rgba(244, 245, 248, 0.8); background: rgba(244, 245, 248, 0.8);
overflow-y: auto; overflow-y: scroll;
position: absolute; position: absolute;
top: 10px; top: 10px;
left: 0; left: 0;
} }
.right { .right {
width: 880px; width: 870px;
height: calc(100% - 20px); height: calc(100% - 20px);
position: absolute; position: absolute;
@ -172,59 +202,16 @@ watch(
background-size: 100%; background-size: 100%;
} }
#iframeId { .new-menu-box {
// ::-webkit-scrollbar { height: 100%;
// width: 6px; display: flex;
// height: 6px; align-items: center;
// background-color: rgb(255, 255, 255); justify-content: center;
// }
// ::-webkit-scrollbar-thumb {
// border-radius: 10px;
// background-color: rgb(200, 204, 209);
// }
/* 设置滚动条的样式 */
::-webkit-scrollbar {
width: 6px;
height: 6px;
// width: 2px;
// height: 2px;
// height: 67px;
} }
::scrollbar { .rela {
width: 6px; width: 100%;
height: 6px; height: 100%;
// width: 2px; position: relative;
// height: 2px;
// height: 67px;
}
/* 滚动槽 */
::-webkit-scrollbar-track {
display: none;
// -webkit-box-shadow: inset 0 0 3px #b18933;
// border-radius: 1px;
}
::scrollbar-track {
display: none;
// -webkit-box-shadow: inset 0 0 3px #98f165;
// border-radius: 1px;
}
/* 滚动条滑块 */
::-webkit-scrollbar-thumb {
border-radius: 10px;
background: #006666;
-webkit-box-shadow: inset 0 0 1px #006666;
}
::scrollbar-thumb {
border-radius: 10px;
background: #006666;
-webkit-box-shadow: inset 0 0 1px #006666;
}
} }
</style> </style>