diff --git a/ui/src/api/dataset.ts b/ui/src/api/dataset.ts index caee05921..a5de294f0 100644 --- a/ui/src/api/dataset.ts +++ b/ui/src/api/dataset.ts @@ -67,14 +67,26 @@ const postDateset: (data: any) => Promise> = (data) => { * @param 参数 file:file,limit:number,patterns:array,with_filter:boolean */ const postSplitDocument: (data: any) => Promise> = (data) => { - console.log(data) return post(`${prefix}/document/split`, data) } +/** + * 文档列表 + * @param 参数 dataset_id, name + */ + +const getDocument: (dataset_id: string, name?: string) => Promise> = ( + dataset_id, + name +) => { + return get(`${prefix}/${dataset_id}/document`, name && { name }) +} + export default { getDateset, getAllDateset, delDateset, postDateset, - postSplitDocument + postSplitDocument, + getDocument } diff --git a/ui/src/layout/components/app-main/index.vue b/ui/src/layout/components/app-main/index.vue index 61cb19886..c37ef497c 100644 --- a/ui/src/layout/components/app-main/index.vue +++ b/ui/src/layout/components/app-main/index.vue @@ -13,10 +13,11 @@ import { ref, onBeforeUpdate } from 'vue' import { useRoute } from 'vue-router' const route = useRoute() + const cachedViews: any = ref([]) onBeforeUpdate(() => { - let isCached = route.meta?.cache - let name = route.name + const { name, meta } = route + let isCached = meta?.cache if (isCached && name && !cachedViews.value.includes(name)) { cachedViews.value.push(name) } diff --git a/ui/src/layout/components/sidebar/index.vue b/ui/src/layout/components/sidebar/index.vue index 2c7ad35b6..2a999da10 100644 --- a/ui/src/layout/components/sidebar/index.vue +++ b/ui/src/layout/components/sidebar/index.vue @@ -23,7 +23,8 @@ import SidebarItem from './SidebarItem.vue' const route = useRoute() const subMenuList = computed(() => { - return getChildRouteListByPathAndName(route.meta.parentPath, route.meta.parentName) + const { meta } = route + return getChildRouteListByPathAndName(meta.parentPath, meta.parentName) }) const activeMenu = computed(() => { diff --git a/ui/src/layout/components/top-bar/top-menu/MenuItem.vue b/ui/src/layout/components/top-bar/top-menu/MenuItem.vue index d4021956b..317147f66 100644 --- a/ui/src/layout/components/top-bar/top-menu/MenuItem.vue +++ b/ui/src/layout/components/top-bar/top-menu/MenuItem.vue @@ -15,15 +15,14 @@ import { useRouter, useRoute, type RouteRecordRaw } from 'vue-router' import { computed } from 'vue' const router = useRouter() const route = useRoute() + const props = defineProps<{ menu: RouteRecordRaw }>() const isActive = computed(() => { - return ( - (route.name == props.menu.name && route.path == props.menu.path) || - route?.meta?.activeMenu == props.menu.path - ) + const { name, path, meta } = route + return (name == props.menu.name && path == props.menu.path) || meta?.activeMenu == props.menu.path }) diff --git a/ui/src/router/modules/dataset.ts b/ui/src/router/modules/dataset.ts index 65fd18cdf..43f1a507a 100644 --- a/ui/src/router/modules/dataset.ts +++ b/ui/src/router/modules/dataset.ts @@ -18,23 +18,23 @@ const datasetRouter = { hidden: true }, { - path: '/dataset/:id', + path: '/dataset/:datasetId', name: 'DatasetDetail', meta: { title: '文档', activeMenu: '/dataset' }, component: Layout, hidden: true, children: [ { - path: 'doc', - name: 'DatasetDoc', + path: 'document', + name: 'DatasetDocument', meta: { icon: 'Document', title: '文档', - active: 'doc', - parentPath: '/dataset/:id', + active: 'document', + parentPath: '/dataset/:datasetId', parentName: 'DatasetDetail' }, - component: () => import('@/views/dataset/DatasetDoc.vue') + component: () => import('@/views/dataset/DatasetDocument.vue') }, { path: 'setting', @@ -43,7 +43,7 @@ const datasetRouter = { icon: 'Setting', title: '设置', active: 'setting', - parentPath: '/dataset/:id', + parentPath: '/dataset/:datasetId', parentName: 'DatasetDetail' }, component: () => import('@/views/dataset/DatasetSetting.vue') diff --git a/ui/src/styles/app.scss b/ui/src/styles/app.scss index 113630a66..286683648 100644 --- a/ui/src/styles/app.scss +++ b/ui/src/styles/app.scss @@ -100,6 +100,9 @@ h4 { .h-full { height: 100%; } +.w-240 { + width: 240px; +} .mt-8 { margin-top: 8px; @@ -249,3 +252,24 @@ h4 { background: var(--app-layout-bg-color); border: none; } + +// 表格第一行插入自定义行 +.table-custom-append { + .el-table__append-wrapper { + position: absolute; + top: 0; + border-bottom: var(--el-table-border); + width: 100%; + height: 49px; + box-sizing: border-box; + align-items: center; + display: flex; + padding: 0 12px; + &:hover { + background: var(--el-color-primary-light-9); + } + } + .el-table__body { + margin-top: 49px; + } +} diff --git a/ui/src/styles/element-plus.scss b/ui/src/styles/element-plus.scss index 8fe0f580d..beada60bc 100644 --- a/ui/src/styles/element-plus.scss +++ b/ui/src/styles/element-plus.scss @@ -8,6 +8,14 @@ .el-button { padding: 5px 12px; + &.is-text { + padding: 4px !important; + font-size: 16px; + max-height: 24px; + &:not(.is-disabled):hover { + background: var(--app-text-color-primary-light-1); + } + } } .el-avatar { --el-avatar-bg-color: var(--el-color-primary); @@ -92,15 +100,24 @@ } .el-table { --el-table-header-bg-color: var(--app-layout-bg-color); -} -.el-table { --el-table-text-color: var(--app-text-color-primary); + font-weight: 400; thead { color: var(--app-text-color-secondary); + th { + font-weight: 500; + } } + th.el-table__cell { border-top: var(--el-table-border); } + .el-table__cell { + padding: 12px 0; + } + .el-checkbox { + height: 23px; + } } // el-steps @@ -124,7 +141,6 @@ } } -.el-scrollbar { - overflow-x: hidden; - +.el-switch { + height: auto; } diff --git a/ui/src/utils/time.ts b/ui/src/utils/time.ts new file mode 100644 index 000000000..1a0ebc18a --- /dev/null +++ b/ui/src/utils/time.ts @@ -0,0 +1,30 @@ +const getCheckDate = (timestamp: any) => { + if (!timestamp) return false + const dt = new Date(timestamp) + if (isNaN(dt.getTime())) return false + return dt +} +export const datetimeFormat = (timestamp: any) => { + const dt = getCheckDate(timestamp) + if (!dt) return timestamp + + const y = dt.getFullYear() + const m = (dt.getMonth() + 1 + '').padStart(2, '0') + const d = (dt.getDate() + '').padStart(2, '0') + const hh = (dt.getHours() + '').padStart(2, '0') + const mm = (dt.getMinutes() + '').padStart(2, '0') + const ss = (dt.getSeconds() + '').padStart(2, '0') + + return `${y}-${m}-${d} ${hh}:${mm}:${ss}` +} + +export const dateFormat = (timestamp: any) => { + const dt = getCheckDate(timestamp) + if (!dt) return timestamp + + const y = dt.getFullYear() + const m = (dt.getMonth() + 1 + '').padStart(2, '0') + const d = (dt.getDate() + '').padStart(2, '0') + + return `${y}-${m}-${d}` +} diff --git a/ui/src/utils/utils.ts b/ui/src/utils/utils.ts index 8e63cb86e..b6229faba 100644 --- a/ui/src/utils/utils.ts +++ b/ui/src/utils/utils.ts @@ -1,4 +1,4 @@ -function toThousands(num: any) { +export function toThousands(num: any) { return num.toString().replace(/\d+/, function (n: any) { return n.replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') }) diff --git a/ui/src/views/dataset/DatasetDoc.vue b/ui/src/views/dataset/DatasetDoc.vue deleted file mode 100644 index f5eb41f56..000000000 --- a/ui/src/views/dataset/DatasetDoc.vue +++ /dev/null @@ -1,14 +0,0 @@ - - - diff --git a/ui/src/views/dataset/DatasetDocument.vue b/ui/src/views/dataset/DatasetDocument.vue new file mode 100644 index 000000000..216e3601b --- /dev/null +++ b/ui/src/views/dataset/DatasetDocument.vue @@ -0,0 +1,100 @@ + + + diff --git a/ui/src/views/dataset/index.vue b/ui/src/views/dataset/index.vue index 0d9b3664b..f78b0e708 100644 --- a/ui/src/views/dataset/index.vue +++ b/ui/src/views/dataset/index.vue @@ -2,12 +2,7 @@

数据集

- +