@pisell/materials 1.0.664 → 1.0.665
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +2 -2
- package/build/lowcode/preview.js +7 -7
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +11 -11
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +11 -11
- package/es/components/dataSourceComponents/fields/Input/WithMode.d.ts +1 -4
- package/es/components/dataSourceComponents/fields/Input/WithMode.js +563 -192
- package/es/components/dataSourceComponents/fields/Input/WithMode.less +96 -0
- package/es/components/dataSourceComponents/fields/Upload/BaseUpload.d.ts +5 -0
- package/es/components/iconfont/index.d.ts +8 -0
- package/es/components/iconfont/index.js +1 -1
- package/es/components/pisellAlert/index.d.ts +24 -0
- package/es/components/pisellAvatar/index.d.ts +19 -0
- package/es/components/pisellHeaderProgressBar/index.d.ts +29 -0
- package/es/components/pisellImageCarousels/index.d.ts +18 -0
- package/es/components/pisellInformationEntry/index.d.ts +33 -0
- package/es/components/pisellStatisticList/index.d.ts +21 -0
- package/es/components/pisellWalletPassCard/index.d.ts +55 -0
- package/es/components/productCard/components/Header/DeleteButton/index.d.ts +3 -0
- package/es/components/productCard/components/Header/index.d.ts +3 -0
- package/es/components/walletCard/index.d.ts +71 -0
- package/lib/components/dataSourceComponents/fields/Input/WithMode.d.ts +1 -4
- package/lib/components/dataSourceComponents/fields/Input/WithMode.js +358 -91
- package/lib/components/dataSourceComponents/fields/Input/WithMode.less +96 -0
- package/lib/components/dataSourceComponents/fields/Upload/BaseUpload.d.ts +5 -0
- package/lib/components/iconfont/index.d.ts +8 -0
- package/lib/components/iconfont/index.js +1 -1
- package/lib/components/pisellAlert/index.d.ts +24 -0
- package/lib/components/pisellAvatar/index.d.ts +19 -0
- package/lib/components/pisellHeaderProgressBar/index.d.ts +29 -0
- package/lib/components/pisellImageCarousels/index.d.ts +18 -0
- package/lib/components/pisellInformationEntry/index.d.ts +33 -0
- package/lib/components/pisellStatisticList/index.d.ts +21 -0
- package/lib/components/pisellWalletPassCard/index.d.ts +55 -0
- package/lib/components/productCard/components/Header/DeleteButton/index.d.ts +3 -0
- package/lib/components/productCard/components/Header/index.d.ts +3 -0
- package/lib/components/walletCard/index.d.ts +71 -0
- package/lowcode/form-item-input/snippets.ts +1 -1
- package/package.json +1 -1
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +0 -98
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +0 -98
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _excluded = ["enableQRScanner", "
|
|
2
|
+
var _excluded = ["enableQRScanner", "value", "onChange"];
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
5
5
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -12,232 +12,603 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
14
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
|
-
import { Input as AntInput } from 'antd';
|
|
16
|
-
import React, { useRef,
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
15
|
+
import { Input as AntInput, message } from 'antd';
|
|
16
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
17
|
+
import { BrowserMultiFormatReader } from '@zxing/library';
|
|
18
|
+
import IconFont from "./../../../../components/iconfont";
|
|
19
19
|
import ReadPretty from "./ReadPretty";
|
|
20
20
|
import { withMode } from "../../dataSourceForm/utils";
|
|
21
|
-
|
|
22
|
-
* 判断当前设备是否为移动设备或平板电脑
|
|
23
|
-
*
|
|
24
|
-
* 使用UserAgent检测方法判断设备类型,在非浏览器环境返回false
|
|
25
|
-
* 仅在移动设备上启用扫码功能,因为PC端通常没有摄像头或扫码需求
|
|
26
|
-
*
|
|
27
|
-
* @returns {boolean} 是否为移动设备
|
|
28
|
-
*/
|
|
29
|
-
var isMobileOrTablet = function isMobileOrTablet() {
|
|
30
|
-
if (typeof window === 'undefined') return false;
|
|
31
|
-
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* 输入框组件,支持扫码功能
|
|
36
|
-
*
|
|
37
|
-
* 在移动设备上,当启用扫码功能时,输入框右侧会显示一个扫码图标
|
|
38
|
-
* 点击图标可以唤起设备的相机进行二维码扫描,将扫描结果自动填入输入框
|
|
39
|
-
*
|
|
40
|
-
* @param {InputProps} props - 组件属性
|
|
41
|
-
*/
|
|
21
|
+
import "./WithMode.less";
|
|
42
22
|
var Input = function Input(props) {
|
|
43
|
-
// 解构属性,提取扫码相关的配置和其他Input属性
|
|
44
23
|
var enableQRScanner = props.enableQRScanner,
|
|
24
|
+
propValue = props.value,
|
|
45
25
|
onChange = props.onChange,
|
|
46
|
-
suffix = props.suffix,
|
|
47
26
|
restProps = _objectWithoutProperties(props, _excluded);
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var _useState = useState(false),
|
|
27
|
+
|
|
28
|
+
// 使用内部状态来管理输入值
|
|
29
|
+
var _useState = useState(propValue || ''),
|
|
52
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
31
|
+
inputValue = _useState2[0],
|
|
32
|
+
setInputValue = _useState2[1];
|
|
33
|
+
|
|
34
|
+
// 当props.value变化时更新内部状态
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
if (propValue !== undefined && propValue !== inputValue) {
|
|
37
|
+
setInputValue(propValue);
|
|
38
|
+
}
|
|
39
|
+
}, [propValue]);
|
|
40
|
+
var _useState3 = useState(false),
|
|
41
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
42
|
+
scanVisible = _useState4[0],
|
|
43
|
+
setScanVisible = _useState4[1];
|
|
44
|
+
var _useState5 = useState(false),
|
|
45
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
46
|
+
uploading = _useState6[0],
|
|
47
|
+
setUploading = _useState6[1];
|
|
48
|
+
var videoRef = useRef(null);
|
|
49
|
+
var fileInputRef = useRef(null);
|
|
50
|
+
var codeReaderRef = useRef(null);
|
|
51
|
+
|
|
52
|
+
// 创建一个用于设置输入框值的函数
|
|
53
|
+
var setValue = function setValue(value) {
|
|
54
|
+
console.log('设置输入框值:', value);
|
|
55
|
+
|
|
56
|
+
// 1. 更新内部状态
|
|
57
|
+
setInputValue(value);
|
|
58
|
+
|
|
59
|
+
// 2. 通知父组件值已变化
|
|
60
|
+
if (typeof onChange === 'function') {
|
|
61
|
+
try {
|
|
62
|
+
// 创建模拟事件
|
|
63
|
+
var syntheticEvent = {
|
|
64
|
+
target: {
|
|
65
|
+
value: value
|
|
66
|
+
},
|
|
67
|
+
currentTarget: {
|
|
68
|
+
value: value
|
|
69
|
+
},
|
|
70
|
+
preventDefault: function preventDefault() {},
|
|
71
|
+
stopPropagation: function stopPropagation() {}
|
|
72
|
+
};
|
|
73
|
+
onChange(syntheticEvent);
|
|
74
|
+
} catch (err) {
|
|
75
|
+
console.error('调用onChange失败:', err);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// 处理输入变化
|
|
81
|
+
var handleInputChange = function handleInputChange(e) {
|
|
82
|
+
var newValue = e.target.value;
|
|
83
|
+
|
|
84
|
+
// 更新内部状态
|
|
85
|
+
setInputValue(newValue);
|
|
86
|
+
|
|
87
|
+
// 调用原始onChange
|
|
88
|
+
if (typeof onChange === 'function') {
|
|
89
|
+
onChange(e);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// 处理扫码按钮点击
|
|
94
|
+
var handleScanClick = function handleScanClick() {
|
|
95
|
+
setScanVisible(true);
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// 处理关闭扫码界面
|
|
99
|
+
var handleScanClose = function handleScanClose() {
|
|
100
|
+
var _codeReaderRef$curren;
|
|
101
|
+
setScanVisible(false);
|
|
102
|
+
// 关闭摄像头
|
|
103
|
+
(_codeReaderRef$curren = codeReaderRef.current) === null || _codeReaderRef$curren === void 0 || _codeReaderRef$curren.reset();
|
|
104
|
+
|
|
105
|
+
// 停止视频流
|
|
106
|
+
if (videoRef.current && videoRef.current.srcObject) {
|
|
107
|
+
var stream = videoRef.current.srcObject;
|
|
108
|
+
var tracks = stream.getTracks();
|
|
109
|
+
tracks.forEach(function (track) {
|
|
110
|
+
track.stop();
|
|
111
|
+
});
|
|
112
|
+
videoRef.current.srcObject = null;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
// 清理资源
|
|
117
|
+
useEffect(function () {
|
|
118
|
+
return function () {
|
|
119
|
+
var _codeReaderRef$curren2;
|
|
120
|
+
(_codeReaderRef$curren2 = codeReaderRef.current) === null || _codeReaderRef$curren2 === void 0 || _codeReaderRef$curren2.reset();
|
|
121
|
+
};
|
|
122
|
+
}, []);
|
|
123
|
+
|
|
124
|
+
// 处理上传按钮点击
|
|
125
|
+
var handleUploadClick = function handleUploadClick() {
|
|
126
|
+
var _fileInputRef$current;
|
|
127
|
+
(_fileInputRef$current = fileInputRef.current) === null || _fileInputRef$current === void 0 || _fileInputRef$current.click();
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// 处理文件上传
|
|
67
131
|
var handleFileChange = /*#__PURE__*/function () {
|
|
68
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
69
|
-
var
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
while (1) switch (_context.prev = _context.next) {
|
|
132
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(event) {
|
|
133
|
+
var files, file, reader;
|
|
134
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
135
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
73
136
|
case 0:
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
_context.next = 3;
|
|
137
|
+
files = event.target.files;
|
|
138
|
+
if (!(!files || files.length === 0)) {
|
|
139
|
+
_context2.next = 3;
|
|
78
140
|
break;
|
|
79
141
|
}
|
|
80
|
-
return
|
|
142
|
+
return _context2.abrupt("return");
|
|
81
143
|
case 3:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return
|
|
144
|
+
setUploading(true);
|
|
145
|
+
_context2.prev = 4;
|
|
146
|
+
file = files[0]; // 检查文件类型
|
|
147
|
+
if (file.type.startsWith('image/')) {
|
|
148
|
+
_context2.next = 10;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
message.error('请上传图片文件');
|
|
152
|
+
setUploading(false);
|
|
153
|
+
return _context2.abrupt("return");
|
|
154
|
+
case 10:
|
|
155
|
+
reader = new FileReader();
|
|
156
|
+
reader.onload = /*#__PURE__*/function () {
|
|
157
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(e) {
|
|
158
|
+
var img, canvas, hints, result, width, height, ctx, imageData, data, i, dataUrl, canvasImg, newImg, text;
|
|
159
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
160
|
+
while (1) switch (_context.prev = _context.next) {
|
|
161
|
+
case 0:
|
|
162
|
+
if (!(!e.target || !e.target.result)) {
|
|
163
|
+
_context.next = 2;
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
return _context.abrupt("return");
|
|
167
|
+
case 2:
|
|
168
|
+
_context.prev = 2;
|
|
169
|
+
// 创建一个img元素并添加到DOM中(使用隐藏样式)
|
|
170
|
+
img = document.createElement('img');
|
|
171
|
+
img.style.position = 'absolute';
|
|
172
|
+
img.style.top = '-9999px';
|
|
173
|
+
img.style.left = '-9999px';
|
|
174
|
+
|
|
175
|
+
// 创建canvas用于图像处理
|
|
176
|
+
canvas = document.createElement('canvas');
|
|
177
|
+
canvas.style.position = 'absolute';
|
|
178
|
+
canvas.style.top = '-9999px';
|
|
179
|
+
canvas.style.left = '-9999px';
|
|
180
|
+
document.body.appendChild(img);
|
|
181
|
+
document.body.appendChild(canvas);
|
|
182
|
+
|
|
183
|
+
// 等待图片加载完成
|
|
184
|
+
_context.next = 15;
|
|
185
|
+
return new Promise(function (resolve, reject) {
|
|
186
|
+
var _e$target;
|
|
187
|
+
img.onload = resolve;
|
|
188
|
+
img.onerror = reject;
|
|
189
|
+
img.src = ((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.result) || '';
|
|
190
|
+
});
|
|
191
|
+
case 15:
|
|
192
|
+
_context.prev = 15;
|
|
193
|
+
// 创建多种解码器配置,提高成功率
|
|
194
|
+
hints = new Map();
|
|
195
|
+
hints.set(2, true); // 尝试较慢但更强大的算法 (TRY_HARDER)
|
|
196
|
+
|
|
197
|
+
if (!codeReaderRef.current) {
|
|
198
|
+
// 创建解码器实例
|
|
199
|
+
codeReaderRef.current = new BrowserMultiFormatReader(hints, 500);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// 尝试直接从图像元素解码
|
|
203
|
+
_context.prev = 19;
|
|
204
|
+
_context.next = 22;
|
|
205
|
+
return codeReaderRef.current.decodeFromImageElement(img);
|
|
206
|
+
case 22:
|
|
207
|
+
result = _context.sent;
|
|
208
|
+
_context.next = 63;
|
|
209
|
+
break;
|
|
210
|
+
case 25:
|
|
211
|
+
_context.prev = 25;
|
|
212
|
+
_context.t0 = _context["catch"](19);
|
|
213
|
+
console.log('直接解码失败,尝试预处理图像...');
|
|
214
|
+
|
|
215
|
+
// 获取图像尺寸
|
|
216
|
+
width = img.naturalWidth || img.width;
|
|
217
|
+
height = img.naturalHeight || img.height; // 设置canvas尺寸
|
|
218
|
+
canvas.width = width;
|
|
219
|
+
canvas.height = height;
|
|
220
|
+
|
|
221
|
+
// 获取上下文
|
|
222
|
+
ctx = canvas.getContext('2d');
|
|
223
|
+
if (ctx) {
|
|
224
|
+
_context.next = 35;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
throw new Error('无法创建Canvas上下文');
|
|
228
|
+
case 35:
|
|
229
|
+
// 绘制原始图像
|
|
230
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
231
|
+
|
|
232
|
+
// 尝试提高对比度
|
|
233
|
+
imageData = ctx.getImageData(0, 0, width, height);
|
|
234
|
+
data = imageData.data; // 简单对比度增强
|
|
235
|
+
for (i = 0; i < data.length; i += 4) {
|
|
236
|
+
data[i] = data[i] < 128 ? 0 : 255; // R
|
|
237
|
+
data[i + 1] = data[i + 1] < 128 ? 0 : 255; // G
|
|
238
|
+
data[i + 2] = data[i + 2] < 128 ? 0 : 255; // B
|
|
239
|
+
}
|
|
240
|
+
ctx.putImageData(imageData, 0, 0);
|
|
241
|
+
|
|
242
|
+
// 从处理后的canvas尝试解码
|
|
243
|
+
_context.prev = 40;
|
|
244
|
+
// 将canvas转为dataURL,创建新的image元素
|
|
245
|
+
dataUrl = canvas.toDataURL('image/png');
|
|
246
|
+
canvasImg = document.createElement('img');
|
|
247
|
+
document.body.appendChild(canvasImg);
|
|
248
|
+
|
|
249
|
+
// 等待图像加载
|
|
250
|
+
_context.next = 46;
|
|
251
|
+
return new Promise(function (resolve, reject) {
|
|
252
|
+
canvasImg.onload = resolve;
|
|
253
|
+
canvasImg.onerror = reject;
|
|
254
|
+
canvasImg.src = dataUrl;
|
|
255
|
+
});
|
|
256
|
+
case 46:
|
|
257
|
+
_context.next = 48;
|
|
258
|
+
return codeReaderRef.current.decodeFromImageElement(canvasImg);
|
|
259
|
+
case 48:
|
|
260
|
+
result = _context.sent;
|
|
261
|
+
// 清理
|
|
262
|
+
document.body.removeChild(canvasImg);
|
|
263
|
+
_context.next = 63;
|
|
264
|
+
break;
|
|
265
|
+
case 52:
|
|
266
|
+
_context.prev = 52;
|
|
267
|
+
_context.t1 = _context["catch"](40);
|
|
268
|
+
console.log('Canvas增强解码失败,尝试最后方法...');
|
|
269
|
+
|
|
270
|
+
// 创建新的Image实例,尝试不同的图像加载方式
|
|
271
|
+
newImg = document.createElement('img');
|
|
272
|
+
document.body.appendChild(newImg);
|
|
273
|
+
|
|
274
|
+
// 等待新图像加载
|
|
275
|
+
_context.next = 59;
|
|
276
|
+
return new Promise(function (resolve, reject) {
|
|
277
|
+
newImg.onload = resolve;
|
|
278
|
+
newImg.onerror = reject;
|
|
279
|
+
// 使用canvas的dataURL
|
|
280
|
+
newImg.src = canvas.toDataURL('image/png');
|
|
281
|
+
});
|
|
282
|
+
case 59:
|
|
283
|
+
_context.next = 61;
|
|
284
|
+
return codeReaderRef.current.decodeFromImageElement(newImg);
|
|
285
|
+
case 61:
|
|
286
|
+
result = _context.sent;
|
|
287
|
+
// 清理
|
|
288
|
+
document.body.removeChild(newImg);
|
|
289
|
+
case 63:
|
|
290
|
+
if (!(result && result.getText)) {
|
|
291
|
+
_context.next = 70;
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
text = result.getText(); // 使用setValue函数设置值
|
|
295
|
+
setValue(text);
|
|
296
|
+
message.success('识别成功');
|
|
297
|
+
handleScanClose();
|
|
298
|
+
_context.next = 71;
|
|
299
|
+
break;
|
|
300
|
+
case 70:
|
|
301
|
+
throw new Error('未能获取有效的二维码文本');
|
|
302
|
+
case 71:
|
|
303
|
+
_context.next = 77;
|
|
304
|
+
break;
|
|
305
|
+
case 73:
|
|
306
|
+
_context.prev = 73;
|
|
307
|
+
_context.t2 = _context["catch"](15);
|
|
308
|
+
console.error('二维码识别失败', _context.t2);
|
|
309
|
+
message.error('无法识别二维码,请上传清晰的二维码图片');
|
|
310
|
+
case 77:
|
|
311
|
+
_context.prev = 77;
|
|
312
|
+
// 移除临时创建的DOM元素
|
|
313
|
+
if (document.body.contains(img)) {
|
|
314
|
+
document.body.removeChild(img);
|
|
315
|
+
}
|
|
316
|
+
if (document.body.contains(canvas)) {
|
|
317
|
+
document.body.removeChild(canvas);
|
|
318
|
+
}
|
|
319
|
+
return _context.finish(77);
|
|
320
|
+
case 81:
|
|
321
|
+
_context.next = 87;
|
|
322
|
+
break;
|
|
323
|
+
case 83:
|
|
324
|
+
_context.prev = 83;
|
|
325
|
+
_context.t3 = _context["catch"](2);
|
|
326
|
+
console.error('图片加载失败', _context.t3);
|
|
327
|
+
message.error('图片加载失败');
|
|
328
|
+
case 87:
|
|
329
|
+
_context.prev = 87;
|
|
330
|
+
setUploading(false);
|
|
331
|
+
// 重置文件输入以允许再次选择相同文件
|
|
332
|
+
if (fileInputRef.current) {
|
|
333
|
+
fileInputRef.current.value = '';
|
|
334
|
+
}
|
|
335
|
+
return _context.finish(87);
|
|
336
|
+
case 91:
|
|
337
|
+
case "end":
|
|
338
|
+
return _context.stop();
|
|
339
|
+
}
|
|
340
|
+
}, _callee, null, [[2, 83, 87, 91], [15, 73, 77, 81], [19, 25], [40, 52]]);
|
|
341
|
+
}));
|
|
342
|
+
return function (_x2) {
|
|
343
|
+
return _ref2.apply(this, arguments);
|
|
344
|
+
};
|
|
345
|
+
}();
|
|
346
|
+
reader.onerror = function () {
|
|
347
|
+
message.error('读取文件失败');
|
|
348
|
+
setUploading(false);
|
|
349
|
+
};
|
|
350
|
+
reader.readAsDataURL(file);
|
|
351
|
+
_context2.next = 21;
|
|
352
|
+
break;
|
|
353
|
+
case 16:
|
|
354
|
+
_context2.prev = 16;
|
|
355
|
+
_context2.t0 = _context2["catch"](4);
|
|
356
|
+
console.error('处理图片出错', _context2.t0);
|
|
357
|
+
setUploading(false);
|
|
358
|
+
message.error('处理图片时出错');
|
|
359
|
+
case 21:
|
|
360
|
+
case "end":
|
|
361
|
+
return _context2.stop();
|
|
362
|
+
}
|
|
363
|
+
}, _callee2, null, [[4, 16]]);
|
|
364
|
+
}));
|
|
365
|
+
return function handleFileChange(_x) {
|
|
366
|
+
return _ref.apply(this, arguments);
|
|
367
|
+
};
|
|
368
|
+
}();
|
|
369
|
+
useEffect(function () {
|
|
370
|
+
if (scanVisible && videoRef.current) {
|
|
371
|
+
initCamera();
|
|
372
|
+
}
|
|
373
|
+
}, [scanVisible]);
|
|
374
|
+
var initCamera = /*#__PURE__*/function () {
|
|
375
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
376
|
+
var constraints, stream;
|
|
377
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
378
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
379
|
+
case 0:
|
|
380
|
+
_context3.prev = 0;
|
|
381
|
+
// 停止之前的实例
|
|
382
|
+
if (codeReaderRef.current) {
|
|
383
|
+
try {
|
|
384
|
+
codeReaderRef.current.reset();
|
|
385
|
+
} catch (err) {
|
|
386
|
+
console.log('重置之前的实例出错', err);
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// 创建新的BrowserMultiFormatReader实例,使用100ms的扫描间隔(更频繁扫描)
|
|
391
|
+
codeReaderRef.current = new BrowserMultiFormatReader(undefined, 100);
|
|
392
|
+
console.log('创建二维码阅读器实例成功');
|
|
393
|
+
|
|
394
|
+
// 最简单的相机约束
|
|
395
|
+
constraints = {
|
|
396
|
+
video: {
|
|
397
|
+
facingMode: 'environment'
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
console.log('正在请求摄像头权限...');
|
|
401
|
+
|
|
402
|
+
// 获取视频流
|
|
403
|
+
_context3.next = 8;
|
|
404
|
+
return navigator.mediaDevices.getUserMedia(constraints);
|
|
92
405
|
case 8:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
406
|
+
stream = _context3.sent;
|
|
407
|
+
console.log('获取摄像头流成功');
|
|
408
|
+
if (!videoRef.current) {
|
|
409
|
+
_context3.next = 18;
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
// 设置视频源
|
|
413
|
+
videoRef.current.srcObject = stream;
|
|
97
414
|
|
|
98
|
-
//
|
|
99
|
-
|
|
415
|
+
// 等待视频加载
|
|
416
|
+
_context3.next = 14;
|
|
100
417
|
return new Promise(function (resolve) {
|
|
101
|
-
|
|
418
|
+
if (!videoRef.current) {
|
|
419
|
+
resolve();
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
videoRef.current.onloadedmetadata = function () {
|
|
423
|
+
if (!videoRef.current) return;
|
|
424
|
+
console.log('视频元数据加载完成');
|
|
425
|
+
videoRef.current.play().then(function () {
|
|
426
|
+
console.log('视频开始播放成功');
|
|
427
|
+
resolve();
|
|
428
|
+
}).catch(function (err) {
|
|
429
|
+
console.error('视频播放失败', err);
|
|
430
|
+
message.error('摄像头播放失败');
|
|
431
|
+
resolve();
|
|
432
|
+
});
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// 设置超时,防止卡住
|
|
436
|
+
setTimeout(resolve, 3000);
|
|
102
437
|
});
|
|
103
438
|
case 14:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (
|
|
108
|
-
|
|
109
|
-
|
|
439
|
+
console.log('准备开始扫描...');
|
|
440
|
+
|
|
441
|
+
// 最简单的解码方式
|
|
442
|
+
if (codeReaderRef.current && videoRef.current) {
|
|
443
|
+
try {
|
|
444
|
+
// 基础解码
|
|
445
|
+
codeReaderRef.current.decodeFromVideoDevice(null, videoRef.current, function (result, error) {
|
|
446
|
+
if (result) {
|
|
447
|
+
var text = result.getText();
|
|
448
|
+
console.log('扫描成功:', text);
|
|
449
|
+
|
|
450
|
+
// 使用更简单直接的方式更新输入
|
|
451
|
+
try {
|
|
452
|
+
// 直接通知组件
|
|
453
|
+
setValue(text);
|
|
454
|
+
|
|
455
|
+
// 给用户反馈
|
|
456
|
+
message.success('识别成功');
|
|
457
|
+
setTimeout(function () {
|
|
458
|
+
return handleScanClose();
|
|
459
|
+
}, 500);
|
|
460
|
+
} catch (e) {
|
|
461
|
+
console.error('设置值出错', e);
|
|
462
|
+
message.error('识别成功但设置失败');
|
|
463
|
+
handleScanClose();
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
});
|
|
467
|
+
console.log('扫描器初始化完成,等待二维码...');
|
|
468
|
+
} catch (e) {
|
|
469
|
+
console.error('初始化扫描器失败', e);
|
|
470
|
+
message.error('初始化二维码扫描失败');
|
|
471
|
+
handleScanClose();
|
|
472
|
+
}
|
|
110
473
|
}
|
|
111
|
-
|
|
474
|
+
_context3.next = 19;
|
|
475
|
+
break;
|
|
112
476
|
case 18:
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// 获取图像数据并创建亮度源
|
|
118
|
-
imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
|
119
|
-
luminanceSource = new RGBLuminanceSource(imageData.data, imageData.width, imageData.height); // 创建二进制位图并设置解码提示
|
|
120
|
-
binaryBitmap = new BinaryBitmap(new HybridBinarizer(luminanceSource));
|
|
121
|
-
hints = new Map(); // 设置解码格式为QR_CODE,提高识别精度
|
|
122
|
-
hints.set(DecodeHintType.POSSIBLE_FORMATS, [BarcodeFormat.QR_CODE]);
|
|
123
|
-
|
|
124
|
-
// 创建多格式读取器并解码
|
|
125
|
-
reader = new MultiFormatReader();
|
|
126
|
-
reader.setHints(hints);
|
|
127
|
-
|
|
128
|
-
// 执行解码操作
|
|
129
|
-
result = reader.decode(binaryBitmap);
|
|
130
|
-
scannedText = result.getText(); // 移除加载提示
|
|
131
|
-
message.destroy();
|
|
132
|
-
|
|
133
|
-
// 将解码结果更新到输入框,触发onChange事件
|
|
134
|
-
if (onChange) {
|
|
135
|
-
// 创建类似于输入事件的对象
|
|
136
|
-
onChange({
|
|
137
|
-
target: {
|
|
138
|
-
value: scannedText
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
message.success('扫码成功');
|
|
142
|
-
}
|
|
143
|
-
_context.next = 39;
|
|
477
|
+
throw new Error('视频元素不存在');
|
|
478
|
+
case 19:
|
|
479
|
+
_context3.next = 26;
|
|
144
480
|
break;
|
|
145
|
-
case
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
message.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
case 39:
|
|
153
|
-
_context.prev = 39;
|
|
154
|
-
// 无论成功或失败,都重置处理状态
|
|
155
|
-
setIsProcessing(false);
|
|
156
|
-
|
|
157
|
-
// 重置文件输入,允许重复选择同一文件
|
|
158
|
-
if (fileInputRef.current) {
|
|
159
|
-
fileInputRef.current.value = '';
|
|
160
|
-
}
|
|
161
|
-
return _context.finish(39);
|
|
162
|
-
case 43:
|
|
481
|
+
case 21:
|
|
482
|
+
_context3.prev = 21;
|
|
483
|
+
_context3.t0 = _context3["catch"](0);
|
|
484
|
+
console.error('摄像头初始化错误', _context3.t0);
|
|
485
|
+
message.error('无法启动摄像头,请确保已授权');
|
|
486
|
+
handleScanClose();
|
|
487
|
+
case 26:
|
|
163
488
|
case "end":
|
|
164
|
-
return
|
|
489
|
+
return _context3.stop();
|
|
165
490
|
}
|
|
166
|
-
},
|
|
491
|
+
}, _callee3, null, [[0, 21]]);
|
|
167
492
|
}));
|
|
168
|
-
return function
|
|
169
|
-
return
|
|
493
|
+
return function initCamera() {
|
|
494
|
+
return _ref3.apply(this, arguments);
|
|
170
495
|
};
|
|
171
496
|
}();
|
|
172
497
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
498
|
+
// 仅在启用扫码功能时显示扫码图标,不再限制设备类型
|
|
499
|
+
var scanSuffix = enableQRScanner ? /*#__PURE__*/React.createElement(IconFont, {
|
|
500
|
+
type: "pisell2-scan1",
|
|
501
|
+
className: "scan-button-icon",
|
|
502
|
+
style: {
|
|
503
|
+
fontSize: 24,
|
|
504
|
+
color: '#722ED1',
|
|
505
|
+
cursor: 'pointer'
|
|
506
|
+
},
|
|
507
|
+
onClick: handleScanClick
|
|
508
|
+
}) : null;
|
|
509
|
+
|
|
510
|
+
// 全屏容器样式
|
|
511
|
+
var fullscreenStyle = {
|
|
512
|
+
position: 'fixed',
|
|
513
|
+
top: 0,
|
|
514
|
+
left: 0,
|
|
515
|
+
width: '100vw',
|
|
516
|
+
height: '100vh',
|
|
517
|
+
backgroundColor: '#000',
|
|
518
|
+
zIndex: 9999,
|
|
519
|
+
overflow: 'hidden',
|
|
520
|
+
display: 'flex',
|
|
521
|
+
justifyContent: 'center',
|
|
522
|
+
alignItems: 'center'
|
|
183
523
|
};
|
|
184
524
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
525
|
+
// 视频容器样式
|
|
526
|
+
var videoContainerStyle = {
|
|
527
|
+
position: 'relative',
|
|
528
|
+
width: '100%',
|
|
529
|
+
height: '100%',
|
|
530
|
+
overflow: 'hidden'
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
// 视频样式
|
|
534
|
+
var videoStyle = {
|
|
535
|
+
width: '100%',
|
|
536
|
+
height: '100%',
|
|
537
|
+
objectFit: 'cover'
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
// 关闭按钮样式
|
|
541
|
+
var closeButtonStyle = {
|
|
542
|
+
position: 'fixed',
|
|
543
|
+
top: 20,
|
|
544
|
+
left: 20,
|
|
545
|
+
zIndex: 9999,
|
|
546
|
+
fontSize: 24,
|
|
547
|
+
color: '#fff',
|
|
548
|
+
cursor: 'pointer',
|
|
549
|
+
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
550
|
+
width: 44,
|
|
551
|
+
height: 44,
|
|
552
|
+
display: 'flex',
|
|
553
|
+
alignItems: 'center',
|
|
554
|
+
justifyContent: 'center',
|
|
555
|
+
borderRadius: '50%'
|
|
556
|
+
};
|
|
557
|
+
|
|
558
|
+
// 上传按钮样式
|
|
559
|
+
var uploadButtonStyle = {
|
|
560
|
+
position: 'fixed',
|
|
561
|
+
right: 30,
|
|
562
|
+
bottom: 60,
|
|
563
|
+
width: 88,
|
|
564
|
+
height: 88,
|
|
565
|
+
display: 'flex',
|
|
566
|
+
alignItems: 'center',
|
|
567
|
+
justifyContent: 'center',
|
|
568
|
+
zIndex: 9999,
|
|
569
|
+
fontSize: 48,
|
|
570
|
+
color: '#fff',
|
|
571
|
+
backgroundColor: 'rgba(255, 255, 255, 0.15)',
|
|
572
|
+
borderRadius: '50%',
|
|
573
|
+
cursor: 'pointer'
|
|
574
|
+
};
|
|
219
575
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(AntInput, _extends({}, restProps, {
|
|
220
|
-
ref: props.innerRef,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
/*#__PURE__*/
|
|
225
|
-
|
|
226
|
-
|
|
576
|
+
ref: props.innerRef || undefined,
|
|
577
|
+
addonAfter: scanSuffix,
|
|
578
|
+
value: inputValue,
|
|
579
|
+
onChange: handleInputChange
|
|
580
|
+
})), scanVisible && /*#__PURE__*/React.createElement("div", {
|
|
581
|
+
className: "pisell-scan-fullscreen",
|
|
582
|
+
style: fullscreenStyle
|
|
583
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
584
|
+
style: videoContainerStyle
|
|
585
|
+
}, /*#__PURE__*/React.createElement("video", {
|
|
586
|
+
ref: videoRef,
|
|
587
|
+
className: "scan-video",
|
|
588
|
+
style: videoStyle,
|
|
589
|
+
autoPlay: true,
|
|
590
|
+
playsInline: true,
|
|
591
|
+
muted: true
|
|
592
|
+
})), /*#__PURE__*/React.createElement(IconFont, {
|
|
593
|
+
type: "pisell2-arrow-left",
|
|
594
|
+
className: "scan-close-left",
|
|
595
|
+
style: closeButtonStyle,
|
|
596
|
+
onClick: handleScanClose
|
|
597
|
+
}), /*#__PURE__*/React.createElement(IconFont, {
|
|
598
|
+
type: "pisell2-image-01",
|
|
599
|
+
className: "scan-upload",
|
|
600
|
+
style: uploadButtonStyle,
|
|
601
|
+
onClick: handleUploadClick
|
|
602
|
+
}), /*#__PURE__*/React.createElement("input", {
|
|
227
603
|
type: "file",
|
|
228
|
-
accept: "image/*",
|
|
229
|
-
capture: "environment",
|
|
230
604
|
ref: fileInputRef,
|
|
231
605
|
onChange: handleFileChange,
|
|
606
|
+
accept: "image/*",
|
|
607
|
+
className: "scan-file-input",
|
|
232
608
|
style: {
|
|
233
609
|
display: 'none'
|
|
234
610
|
}
|
|
235
|
-
}));
|
|
611
|
+
})));
|
|
236
612
|
};
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* 应用withMode高阶组件,支持不同的展示模式
|
|
240
|
-
* ReadPretty模式用于只读展示
|
|
241
|
-
*/
|
|
242
613
|
var InputWithMode = withMode(Input, ReadPretty);
|
|
243
614
|
export default InputWithMode;
|