Browse Source

fix: editor upload

main
xingyu 2 years ago
parent
commit
2a6d032f4b
  1. 7
      src/components/Form/src/components/ImageUpload.vue
  2. 6
      src/components/Form/src/helper.ts
  3. 9
      src/components/Tinymce/src/ImgUpload.vue

7
src/components/Form/src/components/ImageUpload.vue

@ -8,6 +8,7 @@ import { join } from 'lodash-es'
import { PlusOutlined } from '@ant-design/icons-vue'
import { useI18n } from '@/hooks/web/useI18n'
import { buildShortUUID } from '@/utils/uuid'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { isArray, isNotEmpty, isUrl } from '@/utils/is'
import { useRuleFormItem } from '@/hooks/component/useFormItem'
import { useAttrs } from '@/hooks/core/useAttrs'
@ -53,7 +54,10 @@ const props = defineProps({
})
const emit = defineEmits(['change', 'update:value'])
const headers = reactive({
'Authorization': `Bearer ${getAccessToken()}`,
'tenant-id': getTenantId(),
})
const attrs = useAttrs()
const { t } = useI18n()
const previewOpen = ref(false)
@ -189,6 +193,7 @@ function getBase64(file: File) {
v-model:file-list="fileList"
v-bind="attrs"
v-model:value="state"
:headers="headers"
:list-type="listType"
:multiple="multiple"
:max-count="maxCount"

6
src/components/Form/src/helper.ts

@ -35,11 +35,7 @@ function genType() {
return [...DATE_TYPE, 'RangePicker']
}
export function setComponentRuleType(
rule: ValidationRule,
component: ComponentType,
valueFormat: string,
) {
export function setComponentRuleType(rule: ValidationRule, component: ComponentType, valueFormat: string) {
if (Reflect.has(rule, 'type'))
return

9
src/components/Tinymce/src/ImgUpload.vue

@ -1,9 +1,10 @@
<script lang="ts" setup>
import { computed } from 'vue'
import { computed, reactive } from 'vue'
import { Upload } from 'ant-design-vue'
import { useDesign } from '@/hooks/web/useDesign'
import { useGlobSetting } from '@/hooks/setting'
import { useI18n } from '@/hooks/web/useI18n'
import { getAccessToken, getTenantId } from '@/utils/auth'
defineOptions({ name: 'TinymceImageUpload' })
@ -17,6 +18,10 @@ const props = defineProps({
},
})
const emit = defineEmits(['uploading', 'done', 'error'])
const headers = reactive({
'Authorization': `Bearer ${getAccessToken()}`,
'tenant-id': getTenantId(),
})
let uploading = false
const { uploadUrl } = useGlobSetting()
@ -55,7 +60,7 @@ function handleChange(info: Recordable) {
<template>
<div :class="[prefixCls, { fullscreen }]">
<Upload name="file" multiple :action="uploadUrl" :show-upload-list="false" accept=".jpg,.jpeg,.gif,.png,.webp" @change="handleChange">
<Upload name="file" :headers="headers" multiple :action="uploadUrl" :show-upload-list="false" accept=".jpg,.jpeg,.gif,.png,.webp" @change="handleChange">
<a-button type="primary" v-bind="{ ...getButtonProps }">
{{ t('component.upload.imgUpload') }}
</a-button>

Loading…
Cancel
Save