提交 b2314956 作者: 龚洪江

修复:富文本,商品自定义编辑

上级 6572b83c
......@@ -10,7 +10,6 @@ const { VITE_REQUEST_BASE_URL } = import.meta.env;
export const uploadImgURL = `${VITE_REQUEST_BASE_URL}/pms/upload/imgOsses`;
export const uploadVideoURL = `${VITE_REQUEST_BASE_URL}/ossservlet/upload/videoOss`;
export const uploadFileURL = `${VITE_REQUEST_BASE_URL}/ossservlet/upload/oss`;
console.log('数据-->', VITE_REQUEST_BASE_URL);
// 创建服务
const service = axios.create({
baseURL: VITE_REQUEST_BASE_URL,
......
......@@ -380,7 +380,7 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
specImage: i.specImage,
productSpecCPQVO: i.productSpecCPQVO,
fileList: i.fileList,
id: i.id,
id: i.productSpec || i.id,
productSkuId: curtRowData && curtRowData.skuId,
};
});
......
import '@wangeditor/editor/dist/css/style.css'; // 引入 css
import React, { useState, useEffect } from 'react';
import { Editor, Toolbar } from '@wangeditor/editor-for-react';
import { IDomEditor, IEditorConfig, IToolbarConfig, InsertFnType } from '@wangeditor/editor';
import { IDomEditor, IEditorConfig, IToolbarConfig } from '@wangeditor/editor';
import { message } from 'antd';
import { CommonAPI } from '~/api';
......@@ -25,9 +25,6 @@ const RichText: React.FC<PropsType> = ({
// editor 实例
const [editor, setEditor] = useState<IDomEditor | null>(null);
// 编辑器内容
const [html, setHtml] = useState<string>('');
// 工具栏配置
const toolbarConfig: Partial<IToolbarConfig> = {};
......@@ -38,7 +35,7 @@ const RichText: React.FC<PropsType> = ({
MENU_CONF: {
uploadImage: {
// 自定义上传
async customUpload(file: File, insertFn: InsertFnType) {
async customUpload(file: File, insertFn: any) {
if (file.size / 1024 / 1024 > (imgSize || 5)) {
return message.warning(`上传文件大小最大${imgSize || 5}M`);
}
......@@ -54,7 +51,7 @@ const RichText: React.FC<PropsType> = ({
},
uploadVideo: {
// 自定义上传
async customUpload(file: File, insertFn: InsertFnType) {
async customUpload(file: File, insertFn: any) {
if (file.size / 1024 / 1024 > (videoSize || 5)) {
return message.warning(`上传文件大小最大${videoSize || 5}M`);
}
......@@ -72,7 +69,6 @@ const RichText: React.FC<PropsType> = ({
};
//富文本修改
const richTextChange = (editor: IDomEditor) => {
setHtml(editor.getHtml());
if (onChange) {
onChange(editor.getHtml() || '');
}
......@@ -87,7 +83,7 @@ const RichText: React.FC<PropsType> = ({
}, [editor]);
useEffect(() => {
setHtml(value || '');
editor?.setHtml(value || '');
}, [value]);
useEffect(() => {
......@@ -107,7 +103,6 @@ const RichText: React.FC<PropsType> = ({
/>
<Editor
defaultConfig={editorConfig}
value={html}
onCreated={setEditor}
onChange={richTextChange}
mode='default'
......
......@@ -58,6 +58,9 @@ const AddOrEditNewsModal: FC<ModalProps & selfProps> = ({
}).then(({ code }) => {
if (code === '200') {
message.success(currentIndustryNews ? '编辑成功' : '新增成功');
form.resetFields();
setSurfaceImgList([]);
setRichTextValue('');
handleOk();
}
});
......
......@@ -13,5 +13,9 @@
}
&-content{
margin-top: 10px;
img,video{
max-width: 100%;
height: auto;
}
}
}
......@@ -25,7 +25,7 @@ const PreviewNewsModal: FC<ModalProps & selfProps> = ({ open, onCancel, currentI
});
};
useEffect(() => {
if (currentIndustryNews) {
if (currentIndustryNews && open) {
getIndustryNewsDetail(currentIndustryNews.id);
}
}, [currentIndustryNews]);
......
......@@ -42,7 +42,7 @@ const TagManage = () => {
),
},
];
const [tableData, setTableData] = useState<any>([{ id: 1 }]);
const [tableData] = useState<any>([{ id: 1 }]);
const [addOrEditTagModalShow, setAddOrEditTagModalShow] = useState<boolean>(false);
const addOrEditTagClick = () => {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论