feat: add display of directory information

This commit is contained in:
hayden
2024-11-06 13:51:38 +08:00
parent 0a8c532506
commit 288f026d47
3 changed files with 20 additions and 3 deletions

View File

@@ -29,11 +29,13 @@
<col /> <col />
</colgroup> </colgroup>
<tbody> <tbody>
<tr v-for="item in information" class="h-8 border-b"> <tr v-for="item in information" class="h-8 whitespace-nowrap border-b">
<td class="border-r bg-gray-300 px-4 dark:bg-gray-800"> <td class="border-r bg-gray-300 px-4 dark:bg-gray-800">
{{ $t(`info.${item.key}`) }} {{ $t(`info.${item.key}`) }}
</td> </td>
<td class="break-all px-4">{{ item.display }}</td> <td class="overflow-hidden text-ellipsis break-all px-4">
{{ item.display }}
</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@@ -81,7 +83,8 @@ const pathOptions = computed(() => {
const information = computed(() => { const information = computed(() => {
return Object.values(baseInfo.value).filter((row) => { return Object.values(baseInfo.value).filter((row) => {
if (editable.value) { if (editable.value) {
return row.key !== 'fullname' const hiddenKeys = ['fullname', 'pathIndex']
return !hiddenKeys.includes(row.key)
} }
return true return true
}) })

View File

@@ -1,3 +1,4 @@
import { useConfig } from 'hooks/config'
import { useLoading } from 'hooks/loading' import { useLoading } from 'hooks/loading'
import { useMarkdown } from 'hooks/markdown' import { useMarkdown } from 'hooks/markdown'
import { request, useRequest } from 'hooks/request' import { request, useRequest } from 'hooks/request'
@@ -203,6 +204,8 @@ const baseInfoKey = Symbol('baseInfo') as InjectionKey<
export const useModelBaseInfoEditor = (formInstance: ModelFormInstance) => { export const useModelBaseInfoEditor = (formInstance: ModelFormInstance) => {
const { formData: model, modelData } = formInstance const { formData: model, modelData } = formInstance
const { modelFolders } = useConfig()
const type = computed({ const type = computed({
get: () => { get: () => {
return model.value.type return model.value.type
@@ -251,6 +254,15 @@ export const useModelBaseInfoEditor = (formInstance: ModelFormInstance) => {
key: 'type', key: 'type',
formatter: () => modelData.value.type, formatter: () => modelData.value.type,
}, },
{
key: 'pathIndex',
formatter: () => {
const modelType = modelData.value.type
const pathIndex = modelData.value.pathIndex
const folders = modelFolders.value[modelType] ?? []
return `${folders[pathIndex]}`
},
},
{ {
key: 'fullname', key: 'fullname',
formatter: (val) => val, formatter: (val) => val,

View File

@@ -32,6 +32,7 @@ const messages = {
}, },
info: { info: {
type: 'Model Type', type: 'Model Type',
pathIndex: 'Directory',
fullname: 'File Name', fullname: 'File Name',
sizeBytes: 'File Size', sizeBytes: 'File Size',
createdAt: 'Created At', createdAt: 'Created At',
@@ -69,6 +70,7 @@ const messages = {
}, },
info: { info: {
type: '类型', type: '类型',
pathIndex: '目录',
fullname: '文件名', fullname: '文件名',
sizeBytes: '文件大小', sizeBytes: '文件大小',
createdAt: '创建时间', createdAt: '创建时间',