Skip to content

Commit

Permalink
fix: 修复编辑器问题
Browse files Browse the repository at this point in the history
  • Loading branch information
JackySoft authored and jianbing.chen committed Dec 18, 2024
1 parent 068253e commit 837dfdd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
10 changes: 6 additions & 4 deletions packages/editor/src/packages/FeedBack/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const AntdModal = forwardRef(({ id, type, config, elements, onLoad, onOk, onCanc
const [visible, setVisible] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(config.props.confirmLoading || false);
const [loading, setLoading] = useState(false);
const addChildElements = usePageStore((state) => state.addChildElements);
const { mode, addChildElements } = usePageStore((state) => ({ mode: state.mode, addChildElements: state.addChildElements }));
// 拖拽接收
const [, drop] = useDrop({
accept: 'MENU_ITEM',
Expand Down Expand Up @@ -111,9 +111,11 @@ const AntdModal = forwardRef(({ id, type, config, elements, onLoad, onOk, onCanc
return (
<>
{/* 虚拟一个按钮,来模拟弹框,生产模式下,需要删除 */}
<div>
<Button onClick={() => setVisible(true)}>{config.props.title}</Button>
</div>
{mode === 'edit' ? (
<div>
<Button onClick={() => setVisible(true)}>{config.props.title}</Button>
</div>
) : null}
<Modal
{...config.props}
data-id={id}
Expand Down
2 changes: 1 addition & 1 deletion packages/editor/src/packages/FeedBack/Modal/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default {
name: 'title',
},
{
type: 'InputNumber',
type: 'InputPx',
label: '弹框宽度',
name: 'width',
},
Expand Down
9 changes: 7 additions & 2 deletions packages/editor/src/packages/Scene/MarsTable/MarsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const MarsTable = ({ id, type, config, elements, onCheckedChange }: ComponentTyp
const [selectedRows, setSelectedRows] = useState<any[]>([]);
const [visible, setVisible] = useState(true);

const { addChildElements, variableData, updateToolbar } = usePageStore((state) => ({
const { mode, addChildElements, variableData, updateToolbar } = usePageStore((state) => ({
mode: state.mode,
addChildElements: state.addChildElements,
variableData: state.page.variableData,
updateToolbar: state.updateToolbar,
Expand Down Expand Up @@ -411,7 +412,11 @@ const MarsTable = ({ id, type, config, elements, onCheckedChange }: ComponentTyp
<div className={styles.toolbar}>
{config.props.leftTitle && <div className={styles.title}>{config.props.leftTitle}</div>}
<div className={styles.action} ref={drop}>
{elements?.length ? <MarsRender elements={elements} /> : <div className="slots">拖拽子元素到这里,一般用来放表单</div>}
{elements?.length ? (
<MarsRender elements={elements} />
) : mode === 'edit' ? (
<div className="slots">拖拽子元素到这里,一般用来放表单</div>
) : null}
{bulkActionList?.map((item) => {
return (
<Button
Expand Down
6 changes: 3 additions & 3 deletions packages/editor/src/pages/editor/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ const Editor = () => {
// 如果没有父组件,在页面最外层先复制一个元素
if (!parentId) {
const current = getElement(elements, id);
const newId = createId(id.split('-')[0]);
const newId = createId(id.split('_')[0]);
addElement({
...elementsMap[id],
elements: [],
Expand All @@ -230,7 +230,7 @@ const Editor = () => {
deepCopy(current?.elements || [], newId);
} else {
const current = getElement(elements, id);
const newId = createId(id.split('-')[0]);
const newId = createId(id.split('_')[0]);
addChildElements({
...elementsMap[id],
elements: [],
Expand All @@ -245,7 +245,7 @@ const Editor = () => {
// 深度递归复制
function deepCopy(list: any[], parentId: string) {
for (let i = 0; i < list.length; i++) {
const pId = createId(list[i].id.split('-')[0]);
const pId = createId(list[i].id.split('_')[0]);
addChildElements({
...elementsMap[list[i].id],
parentId,
Expand Down

0 comments on commit 837dfdd

Please sign in to comment.