mirror of
https://github.com/MrXujiang/h5-Dooring.git
synced 2026-02-07 18:55:33 +00:00
feat; add drag and card
This commit is contained in:
parent
ae19fce77a
commit
22af8b3fb2
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Carousel',
|
type: 'Carousel',
|
||||||
h: 82,
|
h: 82,
|
||||||
|
displayName: '轮播图组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Footer',
|
type: 'Footer',
|
||||||
h: 24,
|
h: 24,
|
||||||
|
displayName: '页脚组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Form',
|
type: 'Form',
|
||||||
h: 172,
|
h: 172,
|
||||||
|
displayName: '表格组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Header',
|
type: 'Header',
|
||||||
h: 28,
|
h: 28,
|
||||||
|
displayName: '页头组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Icon',
|
type: 'Icon',
|
||||||
h: 23,
|
h: 23,
|
||||||
|
displayName: '图标组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Image',
|
type: 'Image',
|
||||||
h: 80,
|
h: 80,
|
||||||
|
displayName: '图片组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'List',
|
type: 'List',
|
||||||
h: 110,
|
h: 110,
|
||||||
|
displayName: '列表组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'LongText',
|
type: 'LongText',
|
||||||
h: 36,
|
h: 36,
|
||||||
|
displayName: '长文本组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Notice',
|
type: 'Notice',
|
||||||
h: 20,
|
h: 20,
|
||||||
|
displayName: '通知组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Qrcode',
|
type: 'Qrcode',
|
||||||
h: 150,
|
h: 150,
|
||||||
|
displayName: '二维码组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Tab',
|
type: 'Tab',
|
||||||
h: 130,
|
h: 130,
|
||||||
|
displayName: '切换页组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Text',
|
type: 'Text',
|
||||||
h: 20,
|
h: 20,
|
||||||
|
displayName: '文本组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'WhiteTpl',
|
type: 'WhiteTpl',
|
||||||
h: 20,
|
h: 20,
|
||||||
|
displayName: '空白组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Video',
|
type: 'Video',
|
||||||
h: 107,
|
h: 107,
|
||||||
|
displayName: '视频组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Area',
|
type: 'Area',
|
||||||
h: 108,
|
h: 108,
|
||||||
|
displayName: '面积图组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Chart',
|
type: 'Chart',
|
||||||
h: 102,
|
h: 102,
|
||||||
|
displayName: '柱状图组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Line',
|
type: 'Line',
|
||||||
h: 104,
|
h: 104,
|
||||||
|
displayName: '折线图组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'Pie',
|
type: 'Pie',
|
||||||
h: 106,
|
h: 106,
|
||||||
|
displayName: '饼图组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
const template = {
|
const template = {
|
||||||
type: 'XProgress',
|
type: 'XProgress',
|
||||||
h: 102,
|
h: 102,
|
||||||
|
displayName: '圆型进度条组件',
|
||||||
};
|
};
|
||||||
export default template;
|
export default template;
|
||||||
|
|||||||
@ -1,9 +1,10 @@
|
|||||||
.calibration{
|
.calibration {
|
||||||
width: calc(200% - 50px);
|
width: calc(200% - 50px);
|
||||||
height: 200%;
|
height: 200%;
|
||||||
position: relative;
|
position: relative;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
:global(.calibrationNumber){
|
pointer-events: none;
|
||||||
|
:global(.calibrationNumber) {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,4 +64,9 @@ body {
|
|||||||
.ant-tabs-left.editorTabclass .ant-tabs-content-holder{
|
.ant-tabs-left.editorTabclass .ant-tabs-content-holder{
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
padding:8px;
|
padding:8px;
|
||||||
|
}
|
||||||
|
.ant-tabs-left.editorTabclass .ant-tabs-tabpane{
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
padding-left: 12px!important;
|
||||||
}
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useState, useEffect, useMemo, useContext } from 'react';
|
import React, { useState, useEffect, useMemo, useContext, useRef } from 'react';
|
||||||
import { Slider, Result, Tabs, Alert } from 'antd';
|
import { Slider, Result, Tabs } from 'antd';
|
||||||
import {
|
import {
|
||||||
PieChartOutlined,
|
PieChartOutlined,
|
||||||
ExpandOutlined,
|
ExpandOutlined,
|
||||||
@ -9,7 +9,6 @@ import {
|
|||||||
DoubleRightOutlined,
|
DoubleRightOutlined,
|
||||||
DoubleLeftOutlined,
|
DoubleLeftOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import TextLoop from 'react-text-loop';
|
|
||||||
import { connect } from 'dva';
|
import { connect } from 'dva';
|
||||||
import HeaderComponent from './components/Header';
|
import HeaderComponent from './components/Header';
|
||||||
import SourceBox from './SourceBox';
|
import SourceBox from './SourceBox';
|
||||||
@ -33,6 +32,7 @@ import { StateWithHistory } from 'redux-undo';
|
|||||||
import styles from './index.less';
|
import styles from './index.less';
|
||||||
import { useGetBall } from 'react-draggable-ball';
|
import { useGetBall } from 'react-draggable-ball';
|
||||||
import { dooringContext } from '@/layouts';
|
import { dooringContext } from '@/layouts';
|
||||||
|
import { throttle } from '@/utils/tool';
|
||||||
|
|
||||||
const { TabPane } = Tabs;
|
const { TabPane } = Tabs;
|
||||||
|
|
||||||
@ -128,13 +128,15 @@ const Container = (props: {
|
|||||||
setScale(prev => (v >= 150 ? 1.5 : v / 100));
|
setScale(prev => (v >= 150 ? 1.5 : v / 100));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSlider = (type: any) => {
|
const handleSlider = useMemo(() => {
|
||||||
if (type) {
|
return (type: any) => {
|
||||||
setScale(prev => (prev >= 1.5 ? 1.5 : prev + 0.1));
|
if (type) {
|
||||||
} else {
|
setScale(prev => (prev >= 1.5 ? 1.5 : prev + 0.1));
|
||||||
setScale(prev => (prev <= 0.5 ? 0.5 : prev - 0.1));
|
} else {
|
||||||
}
|
setScale(prev => (prev <= 0.5 ? 0.5 : prev - 0.1));
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
|
||||||
const handleFormSave = useMemo(() => {
|
const handleFormSave = useMemo(() => {
|
||||||
if (context.theme === 'h5') {
|
if (context.theme === 'h5') {
|
||||||
@ -180,12 +182,16 @@ const Container = (props: {
|
|||||||
}
|
}
|
||||||
}, [context.theme, dispatch]);
|
}, [context.theme, dispatch]);
|
||||||
|
|
||||||
const redohandler = () => {
|
const redohandler = useMemo(() => {
|
||||||
dispatch(ActionCreators.redo());
|
return () => {
|
||||||
};
|
dispatch(ActionCreators.redo());
|
||||||
const undohandler = () => {
|
};
|
||||||
dispatch(ActionCreators.undo());
|
}, [dispatch]);
|
||||||
};
|
const undohandler = useMemo(() => {
|
||||||
|
return () => {
|
||||||
|
dispatch(ActionCreators.undo());
|
||||||
|
};
|
||||||
|
}, [dispatch]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (window.innerWidth < 1024) {
|
if (window.innerWidth < 1024) {
|
||||||
props.history.push('/mobileTip');
|
props.history.push('/mobileTip');
|
||||||
@ -346,6 +352,71 @@ const Container = (props: {
|
|||||||
}
|
}
|
||||||
}, [canvasId, collapsed, generateHeader, graphTpl, mediaTpl, schema, template]);
|
}, [canvasId, collapsed, generateHeader, graphTpl, mediaTpl, schema, template]);
|
||||||
|
|
||||||
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
|
const [diffmove, setDiffMove] = useState({
|
||||||
|
start: { x: 0, y: 0 },
|
||||||
|
move: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const mousedownfn = useMemo(() => {
|
||||||
|
return (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (e.target === containerRef.current) {
|
||||||
|
setDiffMove({
|
||||||
|
start: {
|
||||||
|
x: e.clientX,
|
||||||
|
y: e.clientY,
|
||||||
|
},
|
||||||
|
move: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, []);
|
||||||
|
const mousemovefn = useMemo(() => {
|
||||||
|
return (e: React.MouseEvent<HTMLDivElement>) => {
|
||||||
|
if (diffmove.move) {
|
||||||
|
let diffx: number;
|
||||||
|
let diffy: number;
|
||||||
|
const d = 5;
|
||||||
|
const newX = e.clientX;
|
||||||
|
const newY = e.clientY;
|
||||||
|
newX - diffmove.start.x > 0 ? (diffx = d) : (diffx = -d);
|
||||||
|
newY - diffmove.start.y > 0 ? (diffy = d) : (diffy = -d);
|
||||||
|
setDiffMove({
|
||||||
|
start: {
|
||||||
|
x: newX,
|
||||||
|
y: newY,
|
||||||
|
},
|
||||||
|
move: true,
|
||||||
|
});
|
||||||
|
setDragState(prev => {
|
||||||
|
return {
|
||||||
|
x: prev.x + diffx,
|
||||||
|
y: prev.y + diffy,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [diffmove.move, diffmove.start.x, diffmove.start.y]);
|
||||||
|
|
||||||
|
const mouseupfn = useMemo(() => {
|
||||||
|
return () => {
|
||||||
|
if (diffmove.move) {
|
||||||
|
setDiffMove({
|
||||||
|
start: { x: 0, y: 0 },
|
||||||
|
move: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, [diffmove.move]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (diffmove.move && containerRef.current) {
|
||||||
|
containerRef.current.style.cursor = 'move';
|
||||||
|
} else {
|
||||||
|
containerRef.current!.style.cursor = 'default';
|
||||||
|
}
|
||||||
|
}, [diffmove.move]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.editorWrap}>
|
<div className={styles.editorWrap}>
|
||||||
<HeaderComponent
|
<HeaderComponent
|
||||||
@ -391,7 +462,15 @@ const Container = (props: {
|
|||||||
}}
|
}}
|
||||||
></div>
|
></div>
|
||||||
|
|
||||||
<div className={styles.tickMark} id="calibration">
|
<div
|
||||||
|
className={styles.tickMark}
|
||||||
|
id="calibration"
|
||||||
|
ref={containerRef}
|
||||||
|
onMouseDown={mousedownfn}
|
||||||
|
onMouseMove={throttle(mousemovefn, 500)}
|
||||||
|
onMouseUp={mouseupfn}
|
||||||
|
onMouseLeave={mouseupfn}
|
||||||
|
>
|
||||||
<div className={styles.tickMarkTop}>
|
<div className={styles.tickMarkTop}>
|
||||||
<Calibration direction="up" id="calibrationUp" multiple={scaleNum} />
|
<Calibration direction="up" id="calibrationUp" multiple={scaleNum} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { useMemo, memo, ReactNode, useContext } from 'react';
|
import React, { useMemo, memo, ReactNode, useContext, CSSProperties } from 'react';
|
||||||
import { useDrag } from 'react-dnd';
|
import { useDrag } from 'react-dnd';
|
||||||
import schemaH5 from 'components/BasicShop/schema';
|
import schemaH5 from 'components/BasicShop/schema';
|
||||||
import schemaPc from 'components/BasicPcShop/schema';
|
import schemaPc from 'components/BasicPcShop/schema';
|
||||||
@ -35,18 +35,44 @@ const TargetBox = memo((props: TargetBoxProps) => {
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
const containerStyle = useMemo(
|
const containerStyle: CSSProperties = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
opacity: isDragging ? 0.4 : 1,
|
opacity: isDragging ? 0.4 : 1,
|
||||||
cursor: 'move',
|
cursor: 'move',
|
||||||
|
height: '140px',
|
||||||
}),
|
}),
|
||||||
[isDragging],
|
[isDragging],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.module} style={{ ...containerStyle }} ref={drag}>
|
<>
|
||||||
{props.children}
|
<div style={{ width: '50%', padding: '10px' }}>
|
||||||
</div>
|
<div className={styles.module} style={{ ...containerStyle }} ref={drag}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '110px',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
flexDirection: 'column',
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
height: '30px',
|
||||||
|
lineHeight: '30px',
|
||||||
|
textAlign: 'center',
|
||||||
|
backgroundColor: 'rgba(245, 245, 245, 1)',
|
||||||
|
color: 'rgba(118, 118, 118, 1)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{props.item.displayName}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,7 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
line-height: 50px;
|
line-height: 50px;
|
||||||
font-family: PingFangSC-Medium, PingFang SC;
|
font-family: PingFangSC-Medium, PingFang SC;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
.collapsed {
|
.collapsed {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -52,7 +53,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
border: 2px solid transparent;
|
border: 2px solid #9e9e9e3d;
|
||||||
transition: border 0.3s;
|
transition: border 0.3s;
|
||||||
&:hover {
|
&:hover {
|
||||||
border: 2px solid #06c;
|
border: 2px solid #06c;
|
||||||
|
|||||||
@ -91,3 +91,16 @@ export function unParams(params = '?a=1&b=2&c=3') {
|
|||||||
});
|
});
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function throttle(fn: Function, delay: number) {
|
||||||
|
let flag = true;
|
||||||
|
return (...args: any) => {
|
||||||
|
if (flag) {
|
||||||
|
flag = false;
|
||||||
|
fn(...args);
|
||||||
|
setTimeout(() => {
|
||||||
|
flag = true;
|
||||||
|
}, delay);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user