111117.29

This commit is contained in:
zoujiandong
2025-07-29 15:39:33 +08:00
parent 071ab8de73
commit 4ca1b9cf42
71 changed files with 4259 additions and 652 deletions
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
{"version":3,"file":"sv-choose-file.js","sources":["uni_modules/sv-editor/components/sv-editor/sv-choose-file.vue","../../software/HBuilderX.4.23.2024070804/HBuilderX/plugins/uniapp-cli-vite/uniComponent:/RDovR2l0V29ya1BsYWNlL2Nhc2VEYXRhQmFzZS91bmlfbW9kdWxlcy9zdi1lZGl0b3IvY29tcG9uZW50cy9zdi1lZGl0b3Ivc3YtY2hvb3NlLWZpbGUudnVl"],"sourcesContent":["<template>\r\n <text :data=\"flag\" :props=\"config\" :change:data=\"fileManager.watchData\" :change:props=\"fileManager.watchProps\"></text>\r\n</template>\r\n\r\n<script>\r\n/**\r\n * 文件选择 - APP端\r\n * @author sonve\r\n * @version 1.0.0\r\n * @date 2024-12-04\r\n */\r\n\r\nexport default {\r\n props: {\r\n /**\r\n * 配置项\r\n * @tutorial https://developer.mozilla.org/zh-CN/docs/Web/HTML/Element/input/file\r\n */\r\n config: {\r\n type: Object,\r\n default: () => {\r\n return {\r\n accept: `.doc,.docx,.xls,.xlsx,.pdf,.zip,.rar,\r\n application/msword,\r\n application/vnd.openxmlformats-officedocument.wordprocessingml.document,\r\n application/vnd.ms-excel,\r\n application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,\r\n application/pdf,\r\n application/zip,\r\n application/x-rar-compressed`,\r\n multiple: false\r\n }\r\n }\r\n }\r\n },\r\n data() {\r\n return {\r\n flag: 0 // 监听标志\r\n }\r\n },\r\n methods: {\r\n chooseFile() {\r\n this.flag++ // 修改监听标志\r\n },\r\n rawFile(file) {\r\n this.$emit('confirm', file)\r\n }\r\n }\r\n}\r\n</script>\r\n\r\n<script module=\"fileManager\" lang=\"renderjs\">\r\nimport { base64ToPath } from '../common/file-handler.js';\r\nexport default {\r\n data() {\r\n return {\r\n configCopy: {}, // 跟随vue中props的配置\r\n }\r\n },\r\n methods: {\r\n watchData(newValue, oldValue, ownerInstance, instance) {\r\n if (newValue) {\r\n this.openFileManager()\r\n }\r\n },\r\n watchProps(newValue, oldValue, ownerInstance, instance) {\r\n if (newValue) {\r\n this.configCopy = newValue\r\n }\r\n },\r\n openFileManager() {\r\n try {\r\n const { accept, multiple } = this.configCopy\r\n // 创建文件选择器input\r\n let fileInput = document.createElement('input')\r\n fileInput.setAttribute('type', 'file')\r\n fileInput.setAttribute('accept', accept)\r\n // 注:是否多选不要直接赋值multiple,应当是为false时不添加multiple属性\r\n if(multiple) fileInput.setAttribute('multiple', multiple)\r\n fileInput.click()\r\n\r\n // 封装为Promise的FileReader读取文件\r\n const readFileAsDataURL = (file) => {\r\n return new Promise((resolve, reject) => {\r\n let reader = new FileReader();\r\n reader.readAsDataURL(file);\r\n\r\n reader.onload = async (event) => {\r\n const base64 = event.target.result\r\n const path = await base64ToPath(base64)\r\n resolve({\r\n name: file.name,\r\n type: file.type,\r\n size: file.size,\r\n base64,\r\n path\r\n });\r\n };\r\n reader.onerror = (error) => {\r\n reject(error);\r\n };\r\n });\r\n }\r\n\r\n fileInput.addEventListener('change', async (e) => {\r\n let files = e.target.files // 注:此处为FileList对象,并非常规数组\r\n\r\n let results = await Promise.all(\r\n // Array.from 方法可以将类数组对象转换为真正的数组\r\n Array.from(files).map(item => readFileAsDataURL(item))\r\n );\r\n\r\n // callMethod不支持流数据,无法直接传递文件流对象\r\n this.$ownerInstance.callMethod('rawFile', results)\r\n })\r\n } catch (err) {\r\n console.warn('==== openFileManager catch error :', err);\r\n }\r\n }\r\n }\r\n}\r\n</script>\r\n","import Component from 'D:/GitWorkPlace/caseDataBase/uni_modules/sv-editor/components/sv-editor/sv-choose-file.vue'\nwx.createComponent(Component)"],"names":[],"mappings":";;;AAYA,MAAK,YAAU;AAAA,EACb,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA,IAKL,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,SAAS,MAAM;AACb,eAAO;AAAA,UACL,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAQR,UAAU;AAAA,QACZ;AAAA,MACF;AAAA,IACF;AAAA,EACD;AAAA,EACD,OAAO;AACL,WAAO;AAAA,MACL,MAAM;AAAA;AAAA,IACR;AAAA,EACD;AAAA,EACD,SAAS;AAAA,IACP,aAAa;AACX,WAAK;AAAA,IACN;AAAA,IACD,QAAQ,MAAM;AACZ,WAAK,MAAM,WAAW,IAAI;AAAA,IAC5B;AAAA,EACF;AACF;;;;;;;;;;;;AC/CA,GAAG,gBAAgB,SAAS;"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long