feat: update style

This commit is contained in:
Fine 2024-01-07 17:50:06 +08:00
parent 2912a6c030
commit 0a1e3e207a
2 changed files with 19 additions and 32 deletions

View File

@ -130,10 +130,10 @@ limitations under the License. -->
</div> </div>
<el-dialog <el-dialog
v-model="hierarchyRelated" v-model="hierarchyRelated"
width="1000px"
height="600px"
:destroy-on-close="true" :destroy-on-close="true"
@closed="hierarchyRelated = false" @closed="hierarchyRelated = false"
width="640px"
height="600px"
> >
<div class="hierarchy-related"> <div class="hierarchy-related">
<Map :config="config" /> <Map :config="config" />
@ -705,7 +705,8 @@ limitations under the License. -->
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.hierarchy-related { .hierarchy-related {
height: 100%; height: 600px;
width: 600px;
overflow: auto; overflow: auto;
} }

View File

@ -19,7 +19,7 @@ limitations under the License. -->
element-loading-background="rgba(0, 0, 0, 0)" element-loading-background="rgba(0, 0, 0, 0)"
:style="`height: ${height}px`" :style="`height: ${height}px`"
> >
<svg class="hierarchy-services-svg" :width="width - 100" :height="height" @click="svgEvent"> <svg class="hierarchy-services-svg" :width="width" :height="height" @click="svgEvent">
<g class="hierarchy-services-graph" :transform="`translate(${diff[0]}, ${diff[1]})`"> <g class="hierarchy-services-graph" :transform="`translate(${diff[0]}, ${diff[1]})`">
<g <g
class="topo-node" class="topo-node"
@ -84,7 +84,7 @@ limitations under the License. -->
</g> </g>
</g> </g>
</svg> </svg>
<div id="tooltip"></div> <div id="popover"></div>
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
@ -131,10 +131,10 @@ limitations under the License. -->
const graphConfig = computed(() => props.config.graph || {}); const graphConfig = computed(() => props.config.graph || {});
const depth = ref<number>(graphConfig.value.depth || 2); const depth = ref<number>(graphConfig.value.depth || 2);
const topologyLayout = ref<any>({}); const topologyLayout = ref<any>({});
const tooltip = ref<Nullable<any>>(null); const popover = ref<Nullable<any>>(null);
const graphWidth = ref<number>(100); const graphWidth = ref<number>(100);
const currentNode = ref<Nullable<Node>>(); const currentNode = ref<Nullable<Node>>();
const diff = computed(() => [(width.value - graphWidth.value - 130) / 2, 100]); const diff = computed(() => [(width.value - graphWidth.value - 100) / 2, 0]);
const radius = 8; const radius = 8;
onMounted(async () => { onMounted(async () => {
@ -144,11 +144,11 @@ limitations under the License. -->
}, 10); }, 10);
}); });
async function init() { async function init() {
const dom = document.querySelector(".topology")?.getBoundingClientRect() || { const dom = document.querySelector(".hierarchy-related")?.getBoundingClientRect() || {
height: 40, height: 80,
width: 0, width: 0,
}; };
height.value = dom.height - 40; height.value = dom.height - 80;
width.value = dom.width; width.value = dom.width;
svg.value = d3.select(".hierarchy-services-svg"); svg.value = d3.select(".hierarchy-services-svg");
graph.value = d3.select(".hierarchy-services-graph"); graph.value = d3.select(".hierarchy-services-graph");
@ -177,7 +177,7 @@ limitations under the License. -->
window.addEventListener("resize", resize); window.addEventListener("resize", resize);
await initLegendMetrics(); await initLegendMetrics();
draw(); draw();
tooltip.value = d3.select("#tooltip"); popover.value = d3.select("#popover");
} }
function computeLevels(calls: Call[], nodeList: Node[], levels: any[]) { function computeLevels(calls: Call[], nodeList: Node[], levels: any[]) {
@ -392,7 +392,7 @@ limitations under the License. -->
...html, ...html,
].join(" "); ].join(" ");
tooltip.value popover.value
.style("top", event.offsetY + 10 + "px") .style("top", event.offsetY + 10 + "px")
.style("left", event.offsetX + 10 + "px") .style("left", event.offsetX + 10 + "px")
.style("visibility", "visible") .style("visibility", "visible")
@ -401,7 +401,7 @@ limitations under the License. -->
function showLinkTip(event: MouseEvent, data: Call) { function showLinkTip(event: MouseEvent, data: Call) {
const html = `<div><span class="grey">${t("detectPoint")}:</span>${data.detectPoints.join(" | ")}</div>`; const html = `<div><span class="grey">${t("detectPoint")}:</span>${data.detectPoints.join(" | ")}</div>`;
tooltip.value popover.value
.style("top", event.offsetY + "px") .style("top", event.offsetY + "px")
.style("left", event.offsetX + "px") .style("left", event.offsetX + "px")
.style("visibility", "visible") .style("visibility", "visible")
@ -409,7 +409,7 @@ limitations under the License. -->
} }
function hideTip() { function hideTip() {
tooltip.value.style("visibility", "hidden"); popover.value.style("visibility", "hidden");
} }
function handleNodeClick(event: MouseEvent, d: Node & { x: number; y: number }) { function handleNodeClick(event: MouseEvent, d: Node & { x: number; y: number }) {
event.stopPropagation(); event.stopPropagation();
@ -438,11 +438,11 @@ limitations under the License. -->
return resp; return resp;
} }
function resize() { function resize() {
const dom = document.querySelector(".topology")?.getBoundingClientRect() || { const dom = document.querySelector(".hierarchy-related")?.getBoundingClientRect() || {
height: 40, height: 40,
width: 0, width: 0,
}; };
height.value = dom.height - 40; height.value = dom.height - 80;
width.value = dom.width; width.value = dom.width;
} }
function svgEvent() { function svgEvent() {
@ -454,18 +454,6 @@ limitations under the License. -->
onBeforeUnmount(() => { onBeforeUnmount(() => {
window.removeEventListener("resize", resize); window.removeEventListener("resize", resize);
}); });
watch(
() => [selectorStore.currentService, selectorStore.currentDestService],
(newVal, oldVal) => {
if (oldVal[0].id === newVal[0].id && !oldVal[1]) {
return;
}
if (oldVal[0].id === newVal[0].id && oldVal[1].id === newVal[1].id) {
return;
}
freshNodes();
},
);
watch( watch(
() => appStore.durationTime, () => appStore.durationTime,
() => { () => {
@ -478,8 +466,6 @@ limitations under the License. -->
<style lang="scss" scoped> <style lang="scss" scoped>
.hierarchy-services-topo { .hierarchy-services-topo {
position: relative; position: relative;
overflow: auto;
margin-top: 30px;
.relation-btn { .relation-btn {
position: absolute; position: absolute;
@ -498,7 +484,7 @@ limitations under the License. -->
.hierarchy-services-svg { .hierarchy-services-svg {
cursor: move; cursor: move;
background-color: $layout-background; background-color: var(--el-bg-color);
} }
.legend { .legend {
@ -612,7 +598,7 @@ limitations under the License. -->
top: 30%; top: 30%;
} }
#tooltip { #popover {
position: absolute; position: absolute;
visibility: hidden; visibility: hidden;
padding: 5px; padding: 5px;