| | |
| | | "name": "my-project", |
| | | "version": "0.0.0", |
| | | "dependencies": { |
| | | "@zxing/library": "^0.21.3", |
| | | "echarts": "^5.6.0", |
| | | "element-plus": "^2.9.2", |
| | | "event-source-polyfill": "^1.0.31", |
| | | "jsqr": "^1.4.0", |
| | | "vue": "^3.5.13", |
| | | "vue-router": "^4.0.13" |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "node_modules/@zxing/library": { |
| | | "version": "0.21.3", |
| | | "resolved": "https://registry.npmmirror.com/@zxing/library/-/library-0.21.3.tgz", |
| | | "integrity": "sha512-hZHqFe2JyH/ZxviJZosZjV+2s6EDSY0O24R+FQmlWZBZXP9IqMo7S3nb3+2LBWxodJQkSurdQGnqE7KXqrYgow==", |
| | | "license": "MIT", |
| | | "dependencies": { |
| | | "ts-custom-error": "^3.2.1" |
| | | }, |
| | | "engines": { |
| | | "node": ">= 10.4.0" |
| | | }, |
| | | "optionalDependencies": { |
| | | "@zxing/text-encoding": "~0.9.0" |
| | | } |
| | | }, |
| | | "node_modules/@zxing/text-encoding": { |
| | | "version": "0.9.0", |
| | | "resolved": "https://registry.npmmirror.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", |
| | | "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", |
| | | "license": "(Unlicense OR Apache-2.0)", |
| | | "optional": true |
| | | }, |
| | | "node_modules/alien-signals": { |
| | | "version": "0.4.14", |
| | | "resolved": "https://registry.npmmirror.com/alien-signals/-/alien-signals-0.4.14.tgz", |
| | |
| | | "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", |
| | | "dev": true, |
| | | "license": "MIT" |
| | | }, |
| | | "node_modules/jsqr": { |
| | | "version": "1.4.0", |
| | | "resolved": "https://registry.npmmirror.com/jsqr/-/jsqr-1.4.0.tgz", |
| | | "integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A==", |
| | | "license": "Apache-2.0" |
| | | }, |
| | | "node_modules/less": { |
| | | "version": "4.2.1", |
| | |
| | | "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", |
| | | "engines": { |
| | | "node": ">=0.10.0" |
| | | } |
| | | }, |
| | | "node_modules/ts-custom-error": { |
| | | "version": "3.3.1", |
| | | "resolved": "https://registry.npmmirror.com/ts-custom-error/-/ts-custom-error-3.3.1.tgz", |
| | | "integrity": "sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==", |
| | | "license": "MIT", |
| | | "engines": { |
| | | "node": ">=14.0.0" |
| | | } |
| | | }, |
| | | "node_modules/tslib": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "@zxing/library": { |
| | | "version": "0.21.3", |
| | | "resolved": "https://registry.npmmirror.com/@zxing/library/-/library-0.21.3.tgz", |
| | | "integrity": "sha512-hZHqFe2JyH/ZxviJZosZjV+2s6EDSY0O24R+FQmlWZBZXP9IqMo7S3nb3+2LBWxodJQkSurdQGnqE7KXqrYgow==", |
| | | "requires": { |
| | | "@zxing/text-encoding": "~0.9.0", |
| | | "ts-custom-error": "^3.2.1" |
| | | } |
| | | }, |
| | | "@zxing/text-encoding": { |
| | | "version": "0.9.0", |
| | | "resolved": "https://registry.npmmirror.com/@zxing/text-encoding/-/text-encoding-0.9.0.tgz", |
| | | "integrity": "sha512-U/4aVJ2mxI0aDNI8Uq0wEhMgY+u4CNtEb0om3+y3+niDAsoTCOB33UF0sxpzqzdqXLqmvc+vZyAt4O8pPdfkwA==", |
| | | "optional": true |
| | | }, |
| | | "alien-signals": { |
| | | "version": "0.4.14", |
| | | "resolved": "https://registry.npmmirror.com/alien-signals/-/alien-signals-0.4.14.tgz", |
| | |
| | | "resolved": "https://registry.npmmirror.com/is-what/-/is-what-3.14.1.tgz", |
| | | "integrity": "sha512-sNxgpk9793nzSs7bA6JQJGeIuRBQhAaNGG77kzYQgMkrID+lS6SlK07K5LaptscDlSaIgH+GPFzf+d75FVxozA==", |
| | | "dev": true |
| | | }, |
| | | "jsqr": { |
| | | "version": "1.4.0", |
| | | "resolved": "https://registry.npmmirror.com/jsqr/-/jsqr-1.4.0.tgz", |
| | | "integrity": "sha512-dxLob7q65Xg2DvstYkRpkYtmKm2sPJ9oFhrhmudT1dZvNFFTlroai3AWSpLey/w5vMcLBXRgOJsbXpdN9HzU/A==" |
| | | }, |
| | | "less": { |
| | | "version": "4.2.1", |
| | |
| | | "resolved": "https://registry.npmmirror.com/source-map-js/-/source-map-js-1.2.1.tgz", |
| | | "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==" |
| | | }, |
| | | "ts-custom-error": { |
| | | "version": "3.3.1", |
| | | "resolved": "https://registry.npmmirror.com/ts-custom-error/-/ts-custom-error-3.3.1.tgz", |
| | | "integrity": "sha512-5OX1tzOjxWEgsr/YEUWSuPrQ00deKLh6D7OTWcvNHm12/7QPyRh8SYpyWvA4IZv8H/+GQWQEh/kwo95Q9OVW1A==" |
| | | }, |
| | | "tslib": { |
| | | "version": "2.3.0", |
| | | "resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.3.0.tgz", |
| | |
| | | "preview": "vite preview" |
| | | }, |
| | | "dependencies": { |
| | | "@zxing/library": "^0.21.3", |
| | | "echarts": "^5.6.0", |
| | | "element-plus": "^2.9.2", |
| | | "event-source-polyfill": "^1.0.31", |
| | | "jsqr": "^1.4.0", |
| | | "vue": "^3.5.13", |
| | | "vue-router": "^4.0.13" |
| | | }, |
| | |
| | | |
| | | </template> |
| | | <script lang="ts" setup> |
| | | import { BrowserMultiFormatReader, NotFoundException, ChecksumException, FormatException } from '@zxing/library'; |
| | | import TQS88 from "../img/TQS88.png"; |
| | | import shezhi from '../img/shezhi.png' |
| | | import xinlv from '../img/xinlv.png' |
| | |
| | | import cljd from '../img/cljd.png' |
| | | import tizhong from '../img/tizhong.png' |
| | | import {EventSourcePolyfill} from 'event-source-polyfill'; |
| | | import jsQR from 'jsqr'; |
| | | import { computed, getCurrentInstance, onBeforeMount, onMounted, ref, watch, watchEffect } from "vue"; |
| | | import { Local } from '../utils/storage'; |
| | | import * as echarts from "echarts"; |
| | |
| | | ElMessage.warning('请先输入设备编号') |
| | | } |
| | | } |
| | | const onFileChange=(event: Event) =>{ |
| | | const onFileChange=async(event: Event)=> { |
| | | const inputElement = event.target as HTMLInputElement; |
| | | if (!inputElement.files || inputElement.files.length === 0) return; |
| | | |
| | | const file = inputElement.files[0]; |
| | | const reader = new FileReader(); |
| | | |
| | | reader.onload = function(e) { |
| | | reader.onload = async (e) => { |
| | | if (e.target && typeof e.target.result === 'string') { |
| | | const img = document.createElement('img'); |
| | | img.src = e.target.result; |
| | | img.onload = function() { |
| | | const canvas = document.createElement('canvas'); |
| | | canvas.width = img.width; |
| | | canvas.height = img.height; |
| | | const ctx = canvas.getContext('2d'); |
| | | if (ctx) { |
| | | ctx.drawImage(img, 0, 0); |
| | | const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); |
| | | const code = jsQR(imageData.data, imageData.width, imageData.height); |
| | | if (code) { |
| | | codeResult.value = code.data; |
| | | } |
| | | try { |
| | | const codeReader = new BrowserMultiFormatReader(); |
| | | const result = await codeReader.decodeFromImage(undefined, e.target.result); |
| | | codeResult.value = result.text; |
| | | } catch (err) { |
| | | if (err instanceof NotFoundException) { |
| | | console.error("未找到二维码"); |
| | | } else if (err instanceof ChecksumException) { |
| | | console.error("校验错误"); |
| | | } else if (err instanceof FormatException) { |
| | | console.error("格式错误"); |
| | | } else { |
| | | console.error(err); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | | }; |
| | | |