当前位置: 首页 > wzjs >正文

龙岗网站建设公司百度推广优化怎么做的

龙岗网站建设公司,百度推广优化怎么做的,深圳品牌床垫,视频外链在线生成屏幕录制2025-03-10 10.16.06 以下代码仅提供左侧可视化区域 右侧数据根据你们的存储数据来 大家直接看Rnd标签设置的属性即可!!!!! /*** 用户拖拽水印的最终位置信息*/ export interface ProductWatermarkValue {wat…

屏幕录制2025-03-10 10.16.06

以下代码仅提供左侧可视化区域
右侧数据根据你们的存储数据来
大家直接看Rnd标签设置的属性即可!!!!!

/*** 用户拖拽水印的最终位置信息*/
export interface ProductWatermarkValue {watermark?: ProductWatermarkManagerValue;position: {x: number; // 水印在图片上的水平位置y: number; // 水印在图片上的垂直位置};size: {width: number; // 水印的宽度(相对于商品图片的宽度)height: number; // 水印的高度(相对于商品图片的高度)};
}
/*** 用户上传的水印详细信息,比如路径,宽高*/
export interface ProductWatermarkManagerValue {id: string;name: string;fileUrl: string;width: number;height: number;type: ProductWatermarkManagerValueType;
}
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { Rnd } from 'react-rnd';
import { Dispatch } from 'redux';
import { actions } from '@comall-backend-builder/core';
import { Entity } from '@comall-backend-builder/core/lib/parser';
import './index.less';const prefix = 'product-main-image-watermark-preview';
interface Props {dispatch: Dispatch;entity: Entity;componentId: any;preview: any;
}
interface State {/*** 正在操作中*/isDragging: boolean;
}
export class productMainImageWatermarkRulePreview extends Component<Props, State> {constructor(props: Props) {super(props);this.state = {isDragging: false,};}getWatermarkRule = () => {const { preview } = this.props;return preview?.baseInfo?.watermarkRule;};getPreviewProduct = () => {const { preview } = this.props;const goods = preview?.baseInfo?.goods || [];const isPreviewGoods = goods.find((item: any) => {return item.isPreview;});return isPreviewGoods;};onChangeWatermarkRule = (ruleWatermark: any) => {const { dispatch, componentId } = this.props;dispatch(actions.formChangeAction(componentId, 'baseInfo.watermarkRule', ruleWatermark));};handleDragStart = (e: any) => {e.preventDefault();e.stopPropagation();this.setState({isDragging: true,});};handleDragStop = (e: any, d: any) => {e.preventDefault();e.stopPropagation();this.setState({isDragging: false,});const watermarkRule = this.getWatermarkRule();watermarkRule.position = {x: d.x > 0 ? d.x * 2 : 0,y: d.y > 0 ? d.y * 2 : 0,};this.onChangeWatermarkRule({ ...watermarkRule });};handleResizeStart = (e: any) => {e.preventDefault();e.stopPropagation();this.setState({isDragging: true,});};handleResizeStop = (e: any, direction: any, ref: any, delta: any, position: any) => {e.preventDefault();e.stopPropagation();this.setState({isDragging: false,});const watermarkRule = this.getWatermarkRule();const sizeWidth = ref.style.width.replace('px', '');const sizeHeight = ref.style.height.replace('px', '');//因为左侧模拟器是375px,后端存储的是750px的,所以Rnd数据需要乘以2watermarkRule.size = {width: `${sizeWidth * 2}px`,height: `${sizeHeight * 2}px`,};watermarkRule.position = {x: position.x > 0 ? position.x * 2 : 0,y: position.y > 0 ? position.y * 2 : 0,};this.onChangeWatermarkRule({ ...watermarkRule });};render() {const watermarkRule = this.getWatermarkRule();if (!watermarkRule) {return null;}const { position, size, watermark } = watermarkRule;const previewGoods = this.getPreviewProduct();const pic = previewGoods?.productPic || '';const { isDragging } = this.state;const style = {backgroundImage: pic ? `url(${pic})` : undefined,};const sizeWidth = size && size.width ? size.width.replace('px', '') : 0;const sizeHeight = size && size.height ? size.height.replace('px', '') : 0;//因为后端存储的是750px的,左侧模拟器是375px,所以页面渲染数据需要除2const rndSize = {width: `${sizeWidth / 2}px`,height: `${sizeHeight / 2}px`,};const rndPosition = {x: position.x / 2,y: position.y / 2,};console.log('存储大小size,position', size, position);console.log('展示大小rndSize,rndPosition', rndSize, rndPosition);const isDraggingStyle = {opacity: isDragging ? 0.8 : 1,border: isDragging ? '2px solid #1890ff' : undefined,};return (<div className={prefix}><div className={`${prefix}__bg`} style={style}><RndmaxHeight={375}maxWidth={375}size={rndSize}position={rndPosition}bounds="parent"onDragStart={this.handleDragStart}onDragStop={this.handleDragStop}onResizeStart={this.handleResizeStart}onResizeStop={this.handleResizeStop}resizeParentMore={true} // 如果需要阻止父容器跟随大小变化,可以设置为falseenableResizing={{top: true,right: true,bottom: true,left: true,topRight: true,bottomRight: true,bottomLeft: true,topLeft: true,}}resizeHandles={['se', 'sw', 'ne', 'nw']}style={isDraggingStyle}onClick={(e: any) => e.stopPropagation()}lockAspectRatio={true}><imgsrc={watermark?.fileUrl}alt=""style={{ width: '100%', height: '100%' }}/></Rnd></div></div>);}
}const mapStateToProps = (_state: any, props: any) => {let preview = null;let componentId = null;const entityId = props.entity.id;for (var compId in _state.components) {const comp = _state.components[compId];if ((comp.type === 'CreateForm' || comp.type === 'EditForm') &&comp.entityId === entityId) {preview = comp.fields;componentId = compId;}}return { preview: preview, componentId: componentId };
};export const ProductMainImageWatermarkRulePreview = connect(mapStateToProps)(productMainImageWatermarkRulePreview
);
.product-main-image-watermark-preview{&__bg{margin-right: 10px;overflow: hidden;width: 375px ;min-width: 375px;height: 375px;position: relative;border: 1px solid #ccc;background-position: center;background-repeat: no-repeat;background-size: cover;}
}

开发过程中遇到的问题
1.在使用过程中,火狐浏览器出现一拖拽,就打开了浏览器新标签页
解决方案:在方法调用处理中新增以下两个代码

e.preventDefault();
e.stopPropagation();

2.在使用过程中,用户需要自己上传的水印在左侧渲染中,拉伸时,是等比例放大或缩小的,而不是用户自己控制拉伸大小
解决方案:Rnd标签设置属性

  lockAspectRatio={true}

希望以上代码对大家有帮助❤️

http://www.dtcms.com/wzjs/445860.html

相关文章:

  • 物联网技术应用专业是学什么的学seo网络推广
  • 自己怎么做农好产品网站seo自动工具
  • 怎么查看网站disallowaso推广优化
  • 连云港网站建设方案国际时事新闻
  • 有口碑的徐州网站建设搜索引擎技术
  • 南宁疫情封路最新消息官网优化哪家专业
  • 网站做301重定向怎么做2024年1月新冠高峰期
  • 一家做土产网站西点培训学校
  • 如何优化移动端网站口碑营销什么意思
  • 免费网站建设阿里云合肥seo培训
  • 最讨厌网站网站结构优化的内容和方法
  • 宁波网站建设推广公司重庆百度快照优化排名
  • 网站桥页怎么找郑州网站建设制作公司
  • 做网站要费用多少网站seo基本流程
  • 网站开发 动易友情链接平台广告
  • 山东电力建设河北分公司网站在线培训
  • 做照片书的网站好谷歌浏览器搜索引擎入口
  • 自己做网站转发新闻违法么网络运营推广是做什么的
  • 单位做网站的目的设计个人网站
  • 自定义wordpress维护页面当阳seo外包
  • 青岛网站建设市场自己做一个网站需要什么
  • 互站网官网海外网站建站
  • 怎样建个人网站百度北京总部电话
  • 网站评论区怎么做阳江网站建设
  • 企业网站营销解决方案seo关键词的选择步骤
  • wordpress发不出注册邮件广州网站优化方案
  • 个人备案的域名拿来做别的网站百度商城官网
  • 工信局网站备案查询网站按天扣费优化推广
  • 做购物网站小图标百度怎么推广广告
  • 好网站目录seo课程培训机构