fix dropdown

This commit is contained in:
Qiuxia Fan 2022-05-09 16:27:47 +08:00
parent d93a7cead2
commit e57e29d0b6
2 changed files with 24 additions and 48 deletions

View File

@ -118,7 +118,7 @@ const theme = ["VirtualMachine", "Kubernetes"].includes(name.value || "")
? ref("light") ? ref("light")
: ref("black"); : ref("black");
const routes = ref<any>(useRouter().options.routes); const routes = ref<any>(useRouter().options.routes);
if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { if (/Android|webOS|iPhone|iPod|iPad|BlackBerry/i.test(navigator.userAgent)) {
appStore.setIsMobile(true); appStore.setIsMobile(true);
} else { } else {
appStore.setIsMobile(false); appStore.setIsMobile(false);

View File

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div class="flex-h tab-header"> <div class="flex-h tab-header">
<div class="tabs scroll_bar_style"> <div class="tabs scroll_bar_style" @click="handleClick">
<span <span
v-for="(child, idx) in data.children || []" v-for="(child, idx) in data.children || []"
:key="idx" :key="idx"
@ -26,15 +26,15 @@ limitations under the License. -->
v-model="child.name" v-model="child.name"
placeholder="Please input" placeholder="Please input"
class="tab-name" class="tab-name"
:readonly="isNaN(editTabIndex)" :readonly="isNaN(editTabIndex) && !canEditTabName"
:class="{ view: isNaN(editTabIndex) }" :class="{ view: !canEditTabName }"
/> />
<Icon <Icon
v-show="activeTabIndex === idx" v-show="activeTabIndex === idx"
size="sm" size="sm"
iconName="cancel" iconName="cancel"
@click="deleteTabItem($event, idx)" @click="deleteTabItem($event, idx)"
v-if="dashboardStore.editMode" v-if="dashboardStore.editMode && canEditTabName"
/> />
</span> </span>
<span class="tab-icons" v-if="dashboardStore.editMode"> <span class="tab-icons" v-if="dashboardStore.editMode">
@ -46,35 +46,21 @@ limitations under the License. -->
</span> </span>
</div> </div>
<div class="operations" v-if="dashboardStore.editMode"> <div class="operations" v-if="dashboardStore.editMode">
<el-popover <el-dropdown placement="bottom" trigger="click" :width="200">
placement="bottom" <span class="icon-operation">
trigger="click" <Icon iconName="ellipsis_v" size="middle" />
:width="200"
v-model:visible="showTools"
>
<template #reference>
<span>
<Icon
iconName="ellipsis_v"
size="middle"
class="operation"
@click="showTools = true"
/>
</span> </span>
</template> <template #dropdown>
<div <el-dropdown-menu>
class="tools" <el-dropdown-item @click="canEditTabName = true">
@click="
canEditTabName = true;
showTools = false;
"
>
<span class="edit-tab">{{ t("editTab") }}</span> <span class="edit-tab">{{ t("editTab") }}</span>
</div> </el-dropdown-item>
<div class="tools" @click="removeTab"> <el-dropdown-item @click="removeTab">
<span>{{ t("delete") }}</span> <span>{{ t("delete") }}</span>
</div> </el-dropdown-item>
</el-popover> </el-dropdown-menu>
</template>
</el-dropdown>
</div> </div>
</div> </div>
<div class="tab-layout" @click="handleClick"> <div class="tab-layout" @click="handleClick">
@ -144,7 +130,6 @@ export default defineComponent({
const editTabIndex = ref<number>(NaN); // edit tab item name const editTabIndex = ref<number>(NaN); // edit tab item name
const canEditTabName = ref<boolean>(false); const canEditTabName = ref<boolean>(false);
const needQuery = ref<boolean>(false); const needQuery = ref<boolean>(false);
const showTools = ref<boolean>(false);
const l = dashboardStore.layout.findIndex( const l = dashboardStore.layout.findIndex(
(d: LayoutConfig) => d.i === props.data.i (d: LayoutConfig) => d.i === props.data.i
); );
@ -248,7 +233,6 @@ export default defineComponent({
editTabIndex, editTabIndex,
needQuery, needQuery,
canEditTabName, canEditTabName,
showTools,
t, t,
dragIgnoreFrom, dragIgnoreFrom,
}; };
@ -316,6 +300,11 @@ export default defineComponent({
padding-right: 10px; padding-right: 10px;
} }
.icon-operation {
display: inline-block;
margin-top: 8px;
}
.tab-header { .tab-header {
justify-content: space-between; justify-content: space-between;
width: 100%; width: 100%;
@ -349,17 +338,4 @@ export default defineComponent({
padding-top: 30px; padding-top: 30px;
color: #888; color: #888;
} }
.tools {
padding: 5px 0;
color: #999;
cursor: pointer;
position: relative;
text-align: center;
&:hover {
color: #409eff;
background-color: #eee;
}
}
</style> </style>