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.
- package/dist/{f8c2008a.esm.es5.development.js → 100c4e1e.esm.es5.development.js} +2992 -2025
- package/dist/{256789e0.esm.es5.production.js → a4d5ce04.esm.es5.production.js} +10 -10
- package/dist/index.esm.es5.development.css +1899 -1580
- package/dist/index.esm.es5.development.js +6909 -221
- package/dist/index.esm.es5.production.css +1 -1
- package/dist/index.esm.es5.production.js +1 -1
- package/es2017/bhdDatePicker/index.d.ts +0 -1
- package/es2017/bhdDatePicker/index.js +238 -171
- package/es2017/bhdDatePicker/index.module.less +81 -46
- package/es2017/customerService/index.js +122 -23
- package/es2017/customerService/screenShotPlugin.esm.js +6515 -0
- package/es2017/customerService/screenshotTool.d.ts +1 -0
- package/es2017/customerService/screenshotTool.js +23 -15
- package/es2017/theme/variable.less +27 -0
- package/esm/bhdDatePicker/index.d.ts +0 -1
- package/esm/bhdDatePicker/index.js +242 -175
- package/esm/bhdDatePicker/index.module.less +81 -46
- package/esm/customerService/index.js +127 -27
- package/esm/customerService/screenShotPlugin.esm.js +6516 -0
- package/esm/customerService/screenshotTool.d.ts +1 -0
- package/esm/customerService/screenshotTool.js +21 -13
- package/esm/theme/variable.less +27 -0
- package/package.json +20 -2
|
@@ -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
|
-
|
|
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(
|
|
39
|
-
var context = canvas.getContext(
|
|
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:
|
|
123
|
-
top:
|
|
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",
|