fix: editor upload
parent
ed37ee6011
commit
2a6d032f4b
|
@ -8,6 +8,7 @@ import { join } from 'lodash-es'
|
||||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { buildShortUUID } from '@/utils/uuid'
|
import { buildShortUUID } from '@/utils/uuid'
|
||||||
|
import { getAccessToken, getTenantId } from '@/utils/auth'
|
||||||
import { isArray, isNotEmpty, isUrl } from '@/utils/is'
|
import { isArray, isNotEmpty, isUrl } from '@/utils/is'
|
||||||
import { useRuleFormItem } from '@/hooks/component/useFormItem'
|
import { useRuleFormItem } from '@/hooks/component/useFormItem'
|
||||||
import { useAttrs } from '@/hooks/core/useAttrs'
|
import { useAttrs } from '@/hooks/core/useAttrs'
|
||||||
|
@ -53,7 +54,10 @@ const props = defineProps({
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['change', 'update:value'])
|
const emit = defineEmits(['change', 'update:value'])
|
||||||
|
const headers = reactive({
|
||||||
|
'Authorization': `Bearer ${getAccessToken()}`,
|
||||||
|
'tenant-id': getTenantId(),
|
||||||
|
})
|
||||||
const attrs = useAttrs()
|
const attrs = useAttrs()
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const previewOpen = ref(false)
|
const previewOpen = ref(false)
|
||||||
|
@ -189,6 +193,7 @@ function getBase64(file: File) {
|
||||||
v-model:file-list="fileList"
|
v-model:file-list="fileList"
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
v-model:value="state"
|
v-model:value="state"
|
||||||
|
:headers="headers"
|
||||||
:list-type="listType"
|
:list-type="listType"
|
||||||
:multiple="multiple"
|
:multiple="multiple"
|
||||||
:max-count="maxCount"
|
:max-count="maxCount"
|
||||||
|
|
|
@ -35,11 +35,7 @@ function genType() {
|
||||||
return [...DATE_TYPE, 'RangePicker']
|
return [...DATE_TYPE, 'RangePicker']
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setComponentRuleType(
|
export function setComponentRuleType(rule: ValidationRule, component: ComponentType, valueFormat: string) {
|
||||||
rule: ValidationRule,
|
|
||||||
component: ComponentType,
|
|
||||||
valueFormat: string,
|
|
||||||
) {
|
|
||||||
if (Reflect.has(rule, 'type'))
|
if (Reflect.has(rule, 'type'))
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from 'vue'
|
import { computed, reactive } from 'vue'
|
||||||
import { Upload } from 'ant-design-vue'
|
import { Upload } from 'ant-design-vue'
|
||||||
import { useDesign } from '@/hooks/web/useDesign'
|
import { useDesign } from '@/hooks/web/useDesign'
|
||||||
import { useGlobSetting } from '@/hooks/setting'
|
import { useGlobSetting } from '@/hooks/setting'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
import { getAccessToken, getTenantId } from '@/utils/auth'
|
||||||
|
|
||||||
defineOptions({ name: 'TinymceImageUpload' })
|
defineOptions({ name: 'TinymceImageUpload' })
|
||||||
|
|
||||||
|
@ -17,6 +18,10 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const emit = defineEmits(['uploading', 'done', 'error'])
|
const emit = defineEmits(['uploading', 'done', 'error'])
|
||||||
|
const headers = reactive({
|
||||||
|
'Authorization': `Bearer ${getAccessToken()}`,
|
||||||
|
'tenant-id': getTenantId(),
|
||||||
|
})
|
||||||
let uploading = false
|
let uploading = false
|
||||||
|
|
||||||
const { uploadUrl } = useGlobSetting()
|
const { uploadUrl } = useGlobSetting()
|
||||||
|
@ -55,7 +60,7 @@ function handleChange(info: Recordable) {
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="[prefixCls, { fullscreen }]">
|
<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 }">
|
<a-button type="primary" v-bind="{ ...getButtonProps }">
|
||||||
{{ t('component.upload.imgUpload') }}
|
{{ t('component.upload.imgUpload') }}
|
||||||
</a-button>
|
</a-button>
|
||||||
|
|
Loading…
Reference in New Issue