diff --git a/src/types/components.d.ts b/src/types/components.d.ts index 05ec63bd..39dccc21 100644 --- a/src/types/components.d.ts +++ b/src/types/components.d.ts @@ -6,6 +6,8 @@ import '@vue/runtime-core' declare module '@vue/runtime-core' { export interface GlobalComponents { DateCalendar: typeof import('./../components/DateCalendar.vue')['default'] + ElBreadcrumb: typeof import('element-plus/es')['ElBreadcrumb'] + ElBreadcrumbItem: typeof import('element-plus/es')['ElBreadcrumbItem'] ElButton: typeof import('element-plus/es')['ElButton'] ElCollapse: typeof import('element-plus/es')['ElCollapse'] ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem'] diff --git a/src/views/dashboard/controls/Tab.vue b/src/views/dashboard/controls/Tab.vue index 6f7f807d..5a013634 100644 --- a/src/views/dashboard/controls/Tab.vue +++ b/src/views/dashboard/controls/Tab.vue @@ -28,6 +28,7 @@ limitations under the License. --> class="tab-name" :readonly="isNaN(editTabIndex) && !canEditTabName" :class="{ view: !canEditTabName }" + :style="{ width: getStringWidth(child.name) + 'px' }" /> const l = dashboardStore.layout.findIndex((d: LayoutConfig) => d.i === props.data.i); dashboardStore.setCurrentTabItems(dashboardStore.layout[l].children[activeTabIndex.value].children); } + function getStringWidth(s: string) { + const dom = document.createElement("span"); + dom.style.display = "inline-block"; + dom.textContent = s; + document.body.appendChild(dom); + const width = dom.clientWidth; + + document.body.removeChild(dom); + return width + 10; + } function copyLink() { let path = ""; if (route.params.activeTabIndex === undefined) { @@ -254,6 +265,7 @@ limitations under the License. --> removeTab, clickTabs, copyLink, + getStringWidth, ...toRefs(props), activeTabWidget, dashboardStore, @@ -275,6 +287,7 @@ limitations under the License. --> overflow-x: auto; white-space: nowrap; overflow-y: hidden; + padding: 0 10px; span { display: inline-block; @@ -291,10 +304,9 @@ limitations under the License. --> outline: none; color: #333; font-style: normal; - margin-right: 5px; overflow: hidden; text-overflow: ellipsis; - text-align: center; + margin-right: 20px; } .tab-icons {