bhd-components 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,7 @@
2
2
  import "react-image-crop/dist/ReactCrop.css";
3
3
  interface data {
4
4
  imgBese64: string;
5
+ screenShotType: number;
5
6
  saveScreenshotBese64: (bese64: string) => void;
6
7
  cancelScreenshot: () => void;
7
8
  }
@@ -1,29 +1,36 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "@ice/jsx-runtime/jsx-runtime";
2
- import React, { useState, forwardRef } from "react";
2
+ import React, { useState, forwardRef, useEffect } from "react";
3
3
  import ReactCrop, { centerCrop, makeAspectCrop } from "react-image-crop";
4
4
  import { CloseOutlined } from "@ant-design/icons";
5
5
  import { CustomDuihao } from "../icons/index";
6
6
  import "react-image-crop/dist/ReactCrop.css";
7
7
  import styles from "./index.module.less";
8
8
  const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
9
- let { imgBese64 , saveScreenshotBese64 , cancelScreenshot } = props;
9
+ let { imgBese64 , screenShotType , saveScreenshotBese64 , cancelScreenshot } = props;
10
10
  const [crop, setCrop] = useState();
11
11
  const [completedCrop, setCompletedCrop] = useState();
12
12
  const [aspect, setAspect] = useState(16 / 9);
13
+ const [devicePixelRatio, setDevicePixelRatio] = useState(1);
14
+ const [isFirst, setIsFirst] = useState(true);
13
15
  const [btnPosition, setBtnPosition] = useState({
14
16
  top: 0,
15
17
  left: 0
16
18
  });
17
19
  const [showBtn, setShowBtn] = useState(false);
20
+ useEffect(()=>{
21
+ setDevicePixelRatio(screenShotType === 1 ? window.devicePixelRatio || 1 : 1);
22
+ }, [
23
+ screenShotType
24
+ ]);
18
25
  function centerAspectCrop(mediaWidth, mediaHeight, aspect) {
19
26
  return centerCrop(makeAspectCrop({
20
- unit: '%',
27
+ unit: "%",
21
28
  width: 30
22
29
  }, aspect, mediaWidth, mediaHeight), mediaWidth, mediaHeight);
23
30
  }
24
31
  function onImageLoad(e) {
25
32
  if (aspect) {
26
- // console.log(aspect,e,'dlvkdfmvlkdfmvdfkl');
33
+ console.log(aspect, e, "dlvkdfmvlkdfmvdfkl");
27
34
  // const { width, height } = e.currentTarget
28
35
  const width = 100;
29
36
  const height = 100 * (9 / 16);
@@ -35,17 +42,17 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
35
42
  }
36
43
  function saveImage() {
37
44
  // 创建一个新的canvas元素
38
- var canvas = document.createElement('canvas');
39
- var context = canvas.getContext('2d');
45
+ var canvas = document.createElement("canvas");
46
+ var context = canvas.getContext("2d");
40
47
  // 加载要操作的图片
41
48
  var image = new Image();
42
49
  image.src = imgBese64; // 将'your_image_url'替换为你自己的图片URL
43
50
  // 等待图片加载完成后再进行操作
44
51
  image.onload = function() {
45
- var x = completedCrop.x; // 起始点x坐标
46
- var y = completedCrop.y; // 起始点y坐标
47
- var width = completedCrop.width; // 需要裁剪的区域宽度
48
- var height = completedCrop.height; // 需要裁剪的区域高度
52
+ var x = parseInt((completedCrop.x * devicePixelRatio).toString()); // 起始点x坐标
53
+ var y = parseInt((completedCrop.y * devicePixelRatio).toString()); // 起始点y坐标
54
+ var width = parseInt((completedCrop.width * devicePixelRatio).toString()); // 需要裁剪的区域宽度
55
+ var height = parseInt((completedCrop.height * devicePixelRatio).toString()); // 需要裁剪的区域高度
49
56
  // 设置canvas大小与裁剪区域相同
50
57
  canvas.width = width;
51
58
  canvas.height = height;
@@ -66,6 +73,8 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
66
73
  let y = e.y;
67
74
  let h = e.height;
68
75
  let w = e.width;
76
+ // 新方案使用
77
+ //旧方案改成 let top = y + h + (isFirst ? 21 : 8);
69
78
  let top = y + h + 8;
70
79
  let left = x + w - 88;
71
80
  if (top + 42 > window.innerHeight) {
@@ -76,6 +85,7 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
76
85
  left
77
86
  });
78
87
  setShowBtn(true);
88
+ setIsFirst(false);
79
89
  };
80
90
  return /*#__PURE__*/ _jsxs("div", {
81
91
  className: styles.screenshot_Modal,
@@ -101,9 +111,7 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
101
111
  minWidth: 100,
102
112
  children: /*#__PURE__*/ _jsx("img", {
103
113
  alt: "Crop me",
104
- style: {
105
- display: 'none'
106
- },
114
+ // style={{display:'none'}}
107
115
  src: imgBese64,
108
116
  onLoad: onImageLoad
109
117
  })
@@ -119,8 +127,8 @@ const ScreenshotTool = /*#__PURE__*/ forwardRef((props, ref)=>{
119
127
  onClick: cancelScreenshot,
120
128
  children: /*#__PURE__*/ _jsx(CloseOutlined, {
121
129
  style: {
122
- position: 'relative',
123
- top: '1px'
130
+ position: "relative",
131
+ top: "1px"
124
132
  }
125
133
  })
126
134
  }),
@@ -76,6 +76,8 @@
76
76
  @Gray-09: #262626;
77
77
  @Gray-10: #000000;
78
78
 
79
+
80
+
79
81
  /* 变量色值 */
80
82
 
81
83
  /* "color-background-layout": {
@@ -143,6 +145,16 @@
143
145
 
144
146
  @color-background-quinary: @Gray-01;
145
147
 
148
+
149
+ /*
150
+ "color-background-Mask-Tr": {
151
+ "value": "{Gray-Tr-06}",
152
+ "type": "color",
153
+ "description": "蒙层颜色"
154
+ },
155
+ */
156
+
157
+ @color-background-Mask-Tr:@Gray-Tr-06;
146
158
  /*
147
159
  "color-background-primary-base": {
148
160
  "value": "{Red-06}",
@@ -246,6 +258,13 @@
246
258
  "description": "二级边框色"
247
259
  }, */
248
260
  @color-border-secondary-Tr: @Gray-Tr-04;
261
+
262
+ /* "color-border-tertiary": {
263
+ "value": "{Gray-01}",
264
+ "type": "color",
265
+ "description": "三级边框色"
266
+ }, */
267
+ @color-border-tertiary:@Gray-01;
249
268
  /* "color-border-primary": {
250
269
  "value": "{Red-06}",
251
270
  "type": "color",
@@ -525,6 +544,14 @@
525
544
  }
526
545
  */
527
546
  @color-icon-error: @Orange-06;
547
+ /*
548
+ "color-icon-base": {
549
+ "value": "$Blue-06",
550
+ "type": "color",
551
+ "description": "图标,一级填充色"
552
+ }
553
+ */
554
+ @color-icon-base: @Blue-06;
528
555
  /*
529
556
  "color-icon-fill": {
530
557
  "value": "$Gray-08",
@@ -9,7 +9,6 @@ interface BhdDatePickerProps {
9
9
  [key: string]: any;
10
10
  kind: "single" | "range" | "extra";
11
11
  useType?: string;
12
- label?: React.ReactNode;
13
12
  extraItems?: BhdDateExtraPicker[];
14
13
  extraReadonly?: boolean;
15
14
  }