From 3c34888959fccc5937dd037880fbe0aae307c1b1 Mon Sep 17 00:00:00 2001 From: xingyu Date: Wed, 20 Jul 2022 13:05:09 +0800 Subject: [PATCH] fix: upload --- yudao-ui-admin-vue3/src/components/Editor/src/Editor.vue | 31 ++++++++++++++++++++++++++++++- yudao-ui-admin-vue3/src/views/infra/file/fileList.data.ts | 53 ----------------------------------------------------- yudao-ui-admin-vue3/src/views/infra/file/index.vue | 192 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-ui-admin-vue3/src/views/infra/fileList/index.vue | 192 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-ui-admin-vue3/src/views/system/user/index.vue | 7 +++---- 6 files changed, 278 insertions(+), 250 deletions(-) delete mode 100644 yudao-ui-admin-vue3/src/views/infra/file/fileList.data.ts delete mode 100644 yudao-ui-admin-vue3/src/views/infra/file/index.vue create mode 100644 yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts create mode 100644 yudao-ui-admin-vue3/src/views/infra/fileList/index.vue diff --git a/yudao-ui-admin-vue3/src/components/Editor/src/Editor.vue b/yudao-ui-admin-vue3/src/components/Editor/src/Editor.vue index 6a02791..f623b73 100644 --- a/yudao-ui-admin-vue3/src/components/Editor/src/Editor.vue +++ b/yudao-ui-admin-vue3/src/components/Editor/src/Editor.vue @@ -6,6 +6,7 @@ import { propTypes } from '@/utils/propTypes' import { isNumber } from '@/utils/is' import { ElMessage } from 'element-plus' import { useLocaleStore } from '@/store/modules/locale' +import { getAccessToken, getTenantId } from '@/utils/auth' const localeStore = useLocaleStore() @@ -80,12 +81,40 @@ const editorConfig = computed((): IEditorConfig => { }, autoFocus: false, scroll: true, + MENU_CONF: { + ['uploadImage']: { + server: import.meta.env.VITE_UPLOAD_URL, + // 单个文件的最大体积限制,默认为 2M + maxFileSize: 2 * 1024 * 1024, + // 最多可上传几个文件,默认为 100 + maxNumberOfFiles: 10, + // 选择文件时的类型限制,默认为 ['image/*'] 。如不想限制,则设置为 [] + allowedFileTypes: ['image/*'], + + // 自定义上传参数,例如传递验证的 token 等。参数会被添加到 formData 中,一起上传到服务端。 + meta: {}, + // 将 meta 拼接到 url 参数中,默认 false + metaWithUrl: false, + + // 自定义增加 http header + headers: { + Accept: 'image/*', + Authorization: 'Bearer ' + getAccessToken(), + 'tenant-id': getTenantId() + }, + + // 跨域是否传递 cookie ,默认为 false + withCredentials: false, + + // 超时时间,默认为 10 秒 + timeout: 5 * 1000 // 5 秒 + } + }, uploadImgShowBase64: true }, props.editorConfig || {} ) }) - const editorStyle = computed(() => { return { height: isNumber(props.height) ? `${props.height}px` : props.height diff --git a/yudao-ui-admin-vue3/src/views/infra/file/fileList.data.ts b/yudao-ui-admin-vue3/src/views/infra/file/fileList.data.ts deleted file mode 100644 index 6984e69..0000000 --- a/yudao-ui-admin-vue3/src/views/infra/file/fileList.data.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { reactive } from 'vue' -import { useI18n } from '@/hooks/web/useI18n' -import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' -const { t } = useI18n() // 国际化 - -// CrudSchema -const crudSchemas = reactive([ - { - label: t('common.index'), - field: 'id', - type: 'index', - form: { - show: false - }, - detail: { - show: false - } - }, - { - label: '文件名', - field: 'path', - search: { - show: true - } - }, - { - label: 'URL', - field: 'url' - }, - { - label: '文件类型', - field: 'type' - }, - { - label: t('common.createTime'), - field: 'createTime', - form: { - show: false - } - }, - { - label: t('table.action'), - field: 'action', - width: '300px', - form: { - show: false - }, - detail: { - show: false - } - } -]) -export const { allSchemas } = useCrudSchemas(crudSchemas) diff --git a/yudao-ui-admin-vue3/src/views/infra/file/index.vue b/yudao-ui-admin-vue3/src/views/infra/file/index.vue deleted file mode 100644 index d7b93f7..0000000 --- a/yudao-ui-admin-vue3/src/views/infra/file/index.vue +++ /dev/null @@ -1,192 +0,0 @@ - - - diff --git a/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts b/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts new file mode 100644 index 0000000..6984e69 --- /dev/null +++ b/yudao-ui-admin-vue3/src/views/infra/fileList/fileList.data.ts @@ -0,0 +1,53 @@ +import { reactive } from 'vue' +import { useI18n } from '@/hooks/web/useI18n' +import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas' +const { t } = useI18n() // 国际化 + +// CrudSchema +const crudSchemas = reactive([ + { + label: t('common.index'), + field: 'id', + type: 'index', + form: { + show: false + }, + detail: { + show: false + } + }, + { + label: '文件名', + field: 'path', + search: { + show: true + } + }, + { + label: 'URL', + field: 'url' + }, + { + label: '文件类型', + field: 'type' + }, + { + label: t('common.createTime'), + field: 'createTime', + form: { + show: false + } + }, + { + label: t('table.action'), + field: 'action', + width: '300px', + form: { + show: false + }, + detail: { + show: false + } + } +]) +export const { allSchemas } = useCrudSchemas(crudSchemas) diff --git a/yudao-ui-admin-vue3/src/views/infra/fileList/index.vue b/yudao-ui-admin-vue3/src/views/infra/fileList/index.vue new file mode 100644 index 0000000..67f227b --- /dev/null +++ b/yudao-ui-admin-vue3/src/views/infra/fileList/index.vue @@ -0,0 +1,192 @@ + + + diff --git a/yudao-ui-admin-vue3/src/views/system/user/index.vue b/yudao-ui-admin-vue3/src/views/system/user/index.vue index 21db798..482925d 100644 --- a/yudao-ui-admin-vue3/src/views/system/user/index.vue +++ b/yudao-ui-admin-vue3/src/views/system/user/index.vue @@ -30,9 +30,8 @@ import { listSimplePostsApi } from '@/api/system/post' import { rules, allSchemas } from './user.data' import * as UserApi from '@/api/system/user' import download from '@/utils/download' -import { useCache } from '@/hooks/web/useCache' import { CommonStatusEnum } from '@/utils/constants' -const { wsCache } = useCache() +import { getAccessToken, getTenantId } from '@/utils/auth' interface Tree { id: number name: string @@ -216,8 +215,8 @@ const beforeExcelUpload = (file: UploadRawFile) => { const uploadRef = ref() const submitFileForm = () => { uploadHeaders.value = { - Authorization: 'Bearer ' + wsCache.get('ACCESS_TOKEN'), - 'tenant-id': wsCache.get('tenantId') + Authorization: 'Bearer ' + getAccessToken(), + 'tenant-id': getTenantId() } uploadDisabled.value = true uploadRef.value!.submit() -- libgit2 0.21.4