ydb-components-material 0.1.20 → 0.1.21

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.
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import './index.scss';
2
3
  export interface QRCodeImgProps {
3
4
  /**
4
5
  * 类型
@@ -1,11 +1,24 @@
1
1
  import * as React from 'react';
2
2
  import { useEffect, useRef } from 'react';
3
3
  import QRCode from 'qrcode';
4
+ import "./index.scss";
4
5
  var QRCodeImg = function QRCodeImg(_ref) {
5
6
  var url = _ref.url,
6
7
  _ref$style = _ref.style,
7
8
  style = _ref$style === void 0 ? {} : _ref$style;
8
9
  var canvasRef = useRef(null);
10
+
11
+ // 保存为PNG
12
+ var saveAsPNG = function saveAsPNG() {
13
+ var canvas = canvasRef.current;
14
+ if (!canvas) return;
15
+
16
+ // 创建临时链接
17
+ var link = document.createElement('a');
18
+ link.download = 'qrcode.png';
19
+ link.href = canvas.toDataURL('image/png');
20
+ link.click();
21
+ };
9
22
  useEffect(function () {
10
23
  if (canvasRef.current) {
11
24
  QRCode.toCanvas(canvasRef.current, url, function (error) {
@@ -13,10 +26,17 @@ var QRCodeImg = function QRCodeImg(_ref) {
13
26
  });
14
27
  }
15
28
  }, [url]);
16
- return /*#__PURE__*/React.createElement("canvas", {
17
- ref: canvasRef,
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ className: "qrcode",
18
31
  style: style
19
- });
32
+ }, /*#__PURE__*/React.createElement("canvas", {
33
+ ref: canvasRef
34
+ }), /*#__PURE__*/React.createElement("div", {
35
+ className: "text"
36
+ }, "\u4F7F\u7528\u4E09\u664B\u901A\u5C0F\u7A0B\u5E8F\u626B\u7801\u67E5\u770B\u529E\u4EF6"), /*#__PURE__*/React.createElement("div", {
37
+ className: "btn",
38
+ onClick: saveAsPNG
39
+ }, "\u4FDD\u5B58\u4E8C\u7EF4\u7801"));
20
40
  };
21
41
  QRCodeImg.displayName = 'QRCodeImg';
22
42
  export default QRCodeImg;
@@ -0,0 +1,18 @@
1
+ .qrcode {
2
+ display: flex;
3
+ flex-direction: column;
4
+ justify-content: center;
5
+ align-items: center;
6
+ .text {
7
+ width: 100%;
8
+ text-align: center;
9
+ color: #666666;
10
+ font-size: 14px;
11
+ }
12
+ .btn {
13
+ color: #1678FF;
14
+ margin-top: 8px;
15
+ font-size: 14px;
16
+ }
17
+ }
18
+
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react';
2
+ import './index.scss';
2
3
  export interface QRCodeImgProps {
3
4
  /**
4
5
  * 类型
@@ -6,12 +6,25 @@ exports["default"] = void 0;
6
6
  var _react = _interopRequireWildcard(require("react"));
7
7
  var React = _react;
8
8
  var _qrcode = _interopRequireDefault(require("qrcode"));
9
+ require("./index.scss");
9
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
10
11
  var QRCodeImg = function QRCodeImg(_ref) {
11
12
  var url = _ref.url,
12
13
  _ref$style = _ref.style,
13
14
  style = _ref$style === void 0 ? {} : _ref$style;
14
15
  var canvasRef = (0, _react.useRef)(null);
16
+
17
+ // 保存为PNG
18
+ var saveAsPNG = function saveAsPNG() {
19
+ var canvas = canvasRef.current;
20
+ if (!canvas) return;
21
+
22
+ // 创建临时链接
23
+ var link = document.createElement('a');
24
+ link.download = 'qrcode.png';
25
+ link.href = canvas.toDataURL('image/png');
26
+ link.click();
27
+ };
15
28
  (0, _react.useEffect)(function () {
16
29
  if (canvasRef.current) {
17
30
  _qrcode["default"].toCanvas(canvasRef.current, url, function (error) {
@@ -19,10 +32,17 @@ var QRCodeImg = function QRCodeImg(_ref) {
19
32
  });
20
33
  }
21
34
  }, [url]);
22
- return /*#__PURE__*/React.createElement("canvas", {
23
- ref: canvasRef,
35
+ return /*#__PURE__*/React.createElement("div", {
36
+ className: "qrcode",
24
37
  style: style
25
- });
38
+ }, /*#__PURE__*/React.createElement("canvas", {
39
+ ref: canvasRef
40
+ }), /*#__PURE__*/React.createElement("div", {
41
+ className: "text"
42
+ }, "\u4F7F\u7528\u4E09\u664B\u901A\u5C0F\u7A0B\u5E8F\u626B\u7801\u67E5\u770B\u529E\u4EF6"), /*#__PURE__*/React.createElement("div", {
43
+ className: "btn",
44
+ onClick: saveAsPNG
45
+ }, "\u4FDD\u5B58\u4E8C\u7EF4\u7801"));
26
46
  };
27
47
  QRCodeImg.displayName = 'QRCodeImg';
28
48
  var _default = exports["default"] = QRCodeImg;
@@ -0,0 +1,18 @@
1
+ .qrcode {
2
+ display: flex;
3
+ flex-direction: column;
4
+ justify-content: center;
5
+ align-items: center;
6
+ .text {
7
+ width: 100%;
8
+ text-align: center;
9
+ color: #666666;
10
+ font-size: 14px;
11
+ }
12
+ .btn {
13
+ color: #1678FF;
14
+ margin-top: 8px;
15
+ font-size: 14px;
16
+ }
17
+ }
18
+
@@ -89,7 +89,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
89
89
  packageName = 'ydb-components-material';
90
90
  }
91
91
  if (version === void 0) {
92
- version = '0.1.20';
92
+ version = '0.1.21';
93
93
  }
94
94
  if (basicLibraryVersion === void 0) {
95
95
  basicLibraryVersion = {
@@ -94,7 +94,7 @@ function fillRealVersion(meta, packageName, version, basicLibraryVersion) {
94
94
  packageName = 'ydb-components-material';
95
95
  }
96
96
  if (version === void 0) {
97
- version = '0.1.20';
97
+ version = '0.1.21';
98
98
  }
99
99
  if (basicLibraryVersion === void 0) {
100
100
  basicLibraryVersion = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ydb-components-material",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "ydb-components-material",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -95,10 +95,10 @@
95
95
  },
96
96
  "componentConfig": {
97
97
  "isComponentLibrary": true,
98
- "materialSchema": "https://unpkg.com/ydb-components-material@0.1.20/build/lowcode/assets-prod.json"
98
+ "materialSchema": "https://unpkg.com/ydb-components-material@0.1.21/build/lowcode/assets-prod.json"
99
99
  },
100
100
  "lcMeta": {
101
101
  "type": "component"
102
102
  },
103
- "homepage": "https://unpkg.com/ydb-components-material@0.1.20/build/index.html"
103
+ "homepage": "https://unpkg.com/ydb-components-material@0.1.21/build/index.html"
104
104
  }