Skip to content

Commit

Permalink
fix: 修复富文本编辑器图片上传报错的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
greper committed Sep 16, 2023
1 parent cd42bff commit fa18d93
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
Expand Up @@ -2,7 +2,6 @@
<div class="fs-editor-wang">
<div :id="uniqueId"></div>
<textarea v-model="currentValue" class="fs-editor-wang-preview" readonly></textarea>
<fs-uploader ref="uploaderImplRef" :type="uploader?.type" />
</div>
</template>

Expand All @@ -12,6 +11,7 @@ import wangConfig from "./utils/config";
import { defaultConfig } from "../../type/config";
import _ from "lodash-es";
import { defineComponent } from "vue";
import { useUploader } from "../../../uploader";
export default defineComponent({
name: "FsEditorWang",
props: {
Expand Down Expand Up @@ -150,9 +150,10 @@ export default defineComponent({
},
async doUpload(option: any) {
option.options = this.uploader;
let uploaderImplRef: any = this.$refs.uploaderImplRef;
let uploaderRef = uploaderImplRef.getUploaderRef();
const { getUploaderImpl } = useUploader();
let uploaderRef = await getUploaderImpl(option.options.type);
if (uploaderRef == null) {
ui.message.warn("Sorry,The uploader component is not ready yet");
throw new Error("Sorry,The component is not ready yet");
}
return await uploaderRef?.upload(option);
Expand Down
Expand Up @@ -15,7 +15,6 @@
@onChange="onChange"
@onCreated="handleCreated"
/>
<fs-uploader ref="uploaderImplRef" :type="uploader?.type" />
</div>
</template>

Expand All @@ -29,6 +28,7 @@ import { defaultConfig } from "../../type/config.js";
import _ from "lodash-es";
import { FsUploaderDoUploadOptions } from "../../../uploader/d/type";
import { useUi } from "@fast-crud/fast-crud";
import { useUploader } from "../../../uploader";
type InsertFnType = (url: string, alt?: string, href?: string) => void;
/**
* wangEditor5组件封装
Expand Down Expand Up @@ -134,10 +134,14 @@ export default defineComponent({
if (props.uploader) {
async function doUpload(option: FsUploaderDoUploadOptions) {
option.options = props.uploader;
let uploaderRef = uploaderImplRef.value.getUploaderRef();
const { getUploaderImpl } = useUploader();
let uploaderRef = await getUploaderImpl(option.options.type);
if (uploaderRef == null) {
ui.message.warn("Sorry,The uploader component is not ready yet");
throw new Error("Sorry,The component is not ready yet");
}
return await uploaderRef?.upload(option);
}
Expand Down
1 change: 0 additions & 1 deletion packages/fast-extends/src/uploader/type/config.ts
Expand Up @@ -67,7 +67,6 @@ export const defaultConfig: FsUploaderOptions = {
// }
},
async buildKey(context) {
debugger;
const { fileName } = context;
// 文件key的构建规则
const date = new Date();
Expand Down

0 comments on commit fa18d93

Please sign in to comment.