add:完善工具栏css表现

This commit is contained in:
lhj
2024-11-17 01:44:42 +08:00
parent be5667057e
commit e424ea63ec
2 changed files with 36 additions and 28 deletions

View File

@ -13,9 +13,12 @@
@mouseleave="isHovered = false" @mouseleave="isHovered = false"
> >
<div v-if="componentSelected" class="component-header" :style="headerStyle"> <div v-if="componentSelected" class="component-header" :style="headerStyle">
<span>{{ componentName }}</span> <div style="background-color:#3457cc;color: #ffffff;padding: 5px ;margin-right: 2px">{{ componentName }}</div>
<button style="color: #1057CC" @click="handleEditFunc">编辑</button> <div v-if="componentSelected" style="background-color:#3457cc;color:#ffffff;padding: 6px 5px 5px 5px;display: flex;width: fit-content;flex-wrap: nowrap">
<button style="color: #1057CC" @click="handleDeleteFunc">删除</button> <icon-copy class="clickable" size="20" />
<icon-edit class="clickable" @click="handleEditFunc" size="20"/>
<icon-delete class="clickable" @click="handleDeleteFunc" size="20"/>
</div>
</div> </div>
<div class="component-content"> <div class="component-content">
<component <component
@ -103,6 +106,7 @@ const adjustHeaderPosition = () => {
let top = 0; let top = 0;
let left = 0; let left = 0;
let justification='';
// 获取最外层组件渲染区域的边界 // 获取最外层组件渲染区域的边界
const containerEl = document.getElementById('renderArea'); const containerEl = document.getElementById('renderArea');
@ -110,34 +114,35 @@ const adjustHeaderPosition = () => {
const containerRect = containerEl.getBoundingClientRect(); const containerRect = containerEl.getBoundingClientRect();
debugger
// 计算上下左右的可用空间 // 计算上下左右的可用空间
const topSpace = componentRect.top - containerRect.top; const topSpace = componentRect.top - containerRect.top;
const bottomSpace = containerRect.bottom - componentRect.bottom; const bottomSpace = containerRect.bottom - componentRect.bottom;
const leftSpace = componentRect.left - containerRect.left;
const rightSpace = containerRect.right - componentRect.right;
// 检查上方是否有足够的空间 // 检查上方是否有足够的空间
if (topSpace >= headerRect.height) { if (topSpace >= headerRect.height) {
top = -headerRect.height - 10; top = -headerRect.height+2;
left = rightSpace >= headerRect.width ? componentRect.width - headerRect.width : 0;
} else if (bottomSpace >= headerRect.height) {
top = componentRect.height + 10;
left = rightSpace >= headerRect.width ? componentRect.width - headerRect.width : 0;
} else if (leftSpace >= headerRect.width) {
left = -headerRect.width - 10;
top = 0;
} else if (rightSpace >= headerRect.width) {
left = componentRect.width + 10;
top = 0;
}
} else if (bottomSpace >= headerRect.height) {
top = componentRect.height-2;
}
if (headerRect.width>componentRect.width)
{
left=-2;
justification='flex-start';
}else
{
left=componentRect.width-headerRect.width-2;
justification='flex-end';
}
headerStyle.value = { headerStyle.value = {
top: `${top}px`, top: `${top}px`,
left: `${left}px` left: `${left}px`,
justifyContent: justification
}; };
}; };
onMounted(() => { onMounted(() => {
adjustHeaderPosition()
// console.log("组件挂载后",props.componentData); // console.log("组件挂载后",props.componentData);
}); });
@ -159,21 +164,20 @@ watch(() => componentSelected.value, () => {
} }
.dynamic-component.hover-state { .dynamic-component.hover-state {
border: 1px dashed #1057CC; /* 悬停时浅蓝色虚线框 */ border: 1px dashed #3457cc; /* 悬停时浅蓝色虚线框 */
} }
.dynamic-component.click-state { .dynamic-component.click-state {
border: 2px solid #1057CC; /* 点击时深蓝色实线框 */ border: 2px solid #3457cc; /* 点击时深蓝色实线框 */
} }
.component-header { .component-header {
position: absolute; position: absolute;
color: #1057CC; color: #3457cc;
padding: 5px;
display: flex; display: flex;
flex-wrap: nowrap; /* 禁止换行 */
align-content: center;
align-items: center; align-items: center;
justify-content: space-between;
width: 100%;
z-index: 1000; z-index: 1000;
background-color: transparent; /* 确保没有背景颜色 */ background-color: transparent; /* 确保没有背景颜色 */
box-sizing: border-box; /* 确保内边距不会影响宽度 */ box-sizing: border-box; /* 确保内边距不会影响宽度 */
@ -186,7 +190,7 @@ watch(() => componentSelected.value, () => {
.component-header button { .component-header button {
background-color: transparent; background-color: transparent;
border: none; border: none;
color: #1057CC; color: #3457cc;
cursor: pointer; cursor: pointer;
margin-left: 10px; margin-left: 10px;
} }
@ -200,4 +204,8 @@ watch(() => componentSelected.value, () => {
position: relative; position: relative;
z-index: 1; z-index: 1;
} }
.clickable {
cursor: pointer; /* 当鼠标悬停在此元素上时,鼠标指针变为手形 */
}
</style> </style>

View File

@ -80,7 +80,7 @@ export const useSchemeStore = defineStore('scheme', {
}, },
updateNowScheme(updates: Partial<IPageComponent>) { updateNowScheme(updates: Partial<IPageComponent>) {
debugger; // debugger;
this.nowComponentsData = updates; this.nowComponentsData = updates;
pushToStack(this.selectedComponentStack, this.nowComponentsData.id); pushToStack(this.selectedComponentStack, this.nowComponentsData.id);
@ -89,7 +89,7 @@ export const useSchemeStore = defineStore('scheme', {
return this.nowComponentsData; return this.nowComponentsData;
}, },
deleteScheme(id: string) { deleteScheme(id: string) {
debugger; // debugger;
console.log("删除前,组件id", id); console.log("删除前,组件id", id);
const currentStateHash = this.currentHash; const currentStateHash = this.currentHash;
const objToDelete = findObjectById(this.previewScheme, id); const objToDelete = findObjectById(this.previewScheme, id);