From 9be10c98e4e57bf71fb9cb06bef0a7e86f48c527 Mon Sep 17 00:00:00 2001 From: helltab Date: Sun, 31 Mar 2024 10:59:02 +0800 Subject: [PATCH] feat(#238): Issue about incorporating custom components within a tab layout. --- ui-vue3/src/base/constants.ts | 20 ++++-- ui-vue3/src/components/SearchTable.vue | 1 - ui-vue3/src/layout/index.vue | 4 +- ui-vue3/src/layout/tab/layout_tab.vue | 2 +- ui-vue3/src/router/RouterMeta.ts | 2 + ui-vue3/src/router/defaultRoutes.ts | 6 +- ui-vue3/src/views/home/index.vue | 71 +++++++++++-------- .../views/resources/applications/index.vue | 2 +- .../applications/slots/AppTabHeaderSlot.vue | 44 ++++++++++++ 9 files changed, 110 insertions(+), 42 deletions(-) create mode 100644 ui-vue3/src/views/resources/applications/slots/AppTabHeaderSlot.vue diff --git a/ui-vue3/src/base/constants.ts b/ui-vue3/src/base/constants.ts index 08aa943b2..5fbe6ffb5 100644 --- a/ui-vue3/src/base/constants.ts +++ b/ui-vue3/src/base/constants.ts @@ -15,8 +15,12 @@ * limitations under the License. */ +import type { Component } from 'vue' import { computed, h, reactive, ref } from 'vue' +import type { RouteRecordType } from '@/router/defaultRoutes' +import type { RouteLocationNormalizedLoaded } from 'vue-router' +// 2aacb8 export const PRIMARY_COLOR_DEFAULT = '#17b392' export const LOCAL_STORAGE_LOCALE = 'LOCAL_STORAGE_LOCALE' @@ -31,13 +35,17 @@ export const INSTANCE_REGISTER_COLOR: { [key: string]: string } = { HEALTHY: 'green' } -export const TAB_HEADER_TITLE_VNODE = reactive({ - vnode: h('div', 'something') -}) -export const TAB_HEADER_TITLE = { +export const TAB_HEADER_TITLE: Component = { functional: true, - render: () => { - return TAB_HEADER_TITLE_VNODE.vnode + props: ['route'], + render: ( + a: any, + b: any, + c: { [key: string]: RouteRecordType & RouteLocationNormalizedLoaded } + ) => { + let route = c.route + let header: any = route.meta?.slots?.header + return h(header) || h('div', route.params?.pathId) // console.log(h) // return h("div", "foo") } diff --git a/ui-vue3/src/components/SearchTable.vue b/ui-vue3/src/components/SearchTable.vue index db40551ba..1474754ea 100644 --- a/ui-vue3/src/components/SearchTable.vue +++ b/ui-vue3/src/components/SearchTable.vue @@ -151,7 +151,6 @@ searchDomain.table.columns.forEach((column: any) => { } }) const pagination = computed(() => { - console.log(pagination) return { pageSize: searchDomain.paged.pageSize, current: searchDomain.paged.curPage, diff --git a/ui-vue3/src/layout/index.vue b/ui-vue3/src/layout/index.vue index 06f919955..82be7052a 100644 --- a/ui-vue3/src/layout/index.vue +++ b/ui-vue3/src/layout/index.vue @@ -70,10 +70,12 @@ router.beforeEach((to, from, next) => { transitionFlag.value = true }, 500) }) -TAB_HEADER_TITLE_VNODE.vnode = h('div', route.params?.pathId) diff --git a/ui-vue3/src/views/resources/applications/index.vue b/ui-vue3/src/views/resources/applications/index.vue index a0f3808d7..e23b0d927 100644 --- a/ui-vue3/src/views/resources/applications/index.vue +++ b/ui-vue3/src/views/resources/applications/index.vue @@ -19,7 +19,7 @@