You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

2 lines
25 KiB

(function(){"use strict";var e={2534:function(e,t,a){var i=a(6848),s=function(){var e=this,t=e._self._c;return t("div",{attrs:{id:"app"}},[t("router-view")],1)},l=[],o={name:"App"},n=o,r=a(1656),c=(0,r.A)(n,s,l,!1,null,null,null),d=c.exports,u=a(9143),p=a.n(u),h=a(6178),m=function(){var e=this,t=e._self._c;return t("div",[t("router-view")],1)},f=[],g={name:"SubWindowLayout"},v=g,b=(0,r.A)(v,m,f,!1,null,"1c7354f3",null),w=b.exports,y=function(){var e=this,t=e._self._c;return t("div",[t("router-view")],1)},F=[],_={name:"BaseLayout"},x=_,C=(0,r.A)(x,y,F,!1,null,"63db3719",null),T=C.exports,S=function(){var e=this;e._self._c;return e._m(0)},D=[function(){var e=this,t=e._self._c;return t("div",{staticClass:"desc"},[t("p",[e._v("这是使用Electron开发的一款集成了多个工具的软件。")]),t("p",[e._v("版本:v1.0")])])}],L={name:"AboutWin"},N=L,$=(0,r.A)(N,S,D,!1,null,"82f773be",null),k=$.exports,P=function(){var e=this,t=e._self._c;return t("div",[t("el-card",{staticClass:"box-card"},[t("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[t("h2",[e._v("大小写转换")])]),e._v(" 输入小写或大写字符,将其转换为大写或小写。 ")]),t("el-input",{staticClass:"common",attrs:{type:"textarea",rows:6,placeholder:"请输入需要转换的内容"},model:{value:e.srcText,callback:function(t){e.srcText=t},expression:"srcText"}}),t("div",{staticClass:"common"},[t("el-button",{attrs:{type:"primary",icon:"el-icon-refresh-right"},on:{click:e.handleTransferToUpper}},[e._v("转大写")]),t("el-button",{attrs:{type:"primary",icon:"el-icon-refresh-left"},on:{click:e.handleTransferToLower}},[e._v("转小写")]),t("el-button",{attrs:{type:"danger",icon:"el-icon-delete-solid"},on:{click:e.handleClear}},[e._v("清空")])],1),t("el-input",{staticClass:"common",attrs:{type:"textarea",rows:6,readonly:"",placeholder:"Console"},model:{value:e.destText,callback:function(t){e.destText=t},expression:"destText"}})],1)},I=[],M={methods:{async copyToClipboard(e){try{await navigator.clipboard.writeText(e),this.$message.success("内容已复制!")}catch(t){this.$message.error("复制失败!")}},async handleTransferToUpper(){this.destText=this.srcText.toUpperCase(),await this.copyToClipboard(this.destText)},async handleTransferToLower(){this.destText=this.srcText.toLowerCase(),await this.copyToClipboard(this.destText)},handleClear(){this.destText="",this.srcText=""}},name:"TransferWin",data(){return{srcText:"",destText:""}}},z=M,O=(0,r.A)(z,P,I,!1,null,"673c0bf5",null),A=O.exports,R=function(){var e=this,t=e._self._c;return t("div",{directives:[{name:"loading",rawName:"v-loading",value:e.tableLoading,expression:"tableLoading"}],staticClass:"hello"},[t("div",[t("el-button",{attrs:{type:"text"},on:{click:function(t){return e.configPage()}}},[e._v("配置文件")])],1),t("div",{staticStyle:{height:"50px","margin-top":"20px"}},[t("div",{staticStyle:{float:"left"}},[e._v(" 订单号: "),t("input",{directives:[{name:"model",rawName:"v-model",value:e.scannedCode,expression:"scannedCode"}],attrs:{type:"text",placeholder:"扫描条码"},domProps:{value:e.scannedCode},on:{keydown:e.handleScan,input:function(t){t.target.composing||(e.scannedCode=t.target.value)}}})]),t("div",{staticStyle:{float:"right"}})]),t("div",[t("el-tabs",{attrs:{height:"500px"},on:{"tab-click":e.handleClick},model:{value:e.activeName,callback:function(t){e.activeName=t},expression:"activeName"}},[t("el-tab-pane",{attrs:{label:"倒计时上传",name:"first"}}),t("el-tab-pane",{attrs:{label:"手动上传",name:"three"}}),t("el-tab-pane",{attrs:{label:"手动选择文件上传",name:"four"}}),t("div",["three"==e.activeName?t("el-button",{attrs:{type:"text"},on:{click:function(t){return e.autoUpload()}}},[e._v("获取最新文件上传")]):e._e(),"four"==e.activeName?t("el-upload",{staticClass:"upload-demo",attrs:{action:"#","auto-upload":!1,multiple:!1,limit:1,"on-exceed":e.handleExceed,"on-success":e.uploadSuccess,"on-error":e.uploadError,"on-change":e.uploadFileChange,"file-list":e.ruleForm.fileList,"before-upload":e.beforeUpload}},[t("el-button",{attrs:{size:"small",type:"primary"}},[e._v("点击上传")])],1):e._e(),t("el-table",{staticStyle:{width:"100%"},attrs:{data:e.savedFileList}},[t("el-table-column",{attrs:{type:"index",width:"50",label:"序号",align:"center"}}),t("el-table-column",{attrs:{prop:"orderNumber",label:"订单号",width:"130","show-overflow-tooltip":"",align:"center"}}),t("el-table-column",{attrs:{prop:"fileName",label:"文件名","show-overflow-tooltip":"",align:"center"}}),t("el-table-column",{attrs:{prop:"deviceId",label:"设备编号","show-overflow-tooltip":"",align:"center"}}),t("el-table-column",{attrs:{prop:"uploadType",label:"上传类型","show-overflow-tooltip":"",align:"center"}}),t("el-table-column",{attrs:{prop:"deviceModel",label:"设备型号","show-overflow-tooltip":"",align:"center"}}),t("el-table-column",{attrs:{prop:"date",label:"上传日期","show-overflow-tooltip":"",align:"center"}}),t("el-table-column",{attrs:{prop:"analysisDate",label:"上传结果",align:"center","show-overflow-tooltip":""}})],1),t("div",{staticStyle:{float:"right","margin-top":"20px"}},[t("el-pagination",{attrs:{"current-page":e.currentPage,"page-sizes":[5,10,20,30,50],"page-size":e.pageSize,layout:"total, sizes, prev, pager, next, jumper",total:e.total},on:{"size-change":e.handleSizeChange,"current-change":e.handleCurrentChange}})],1)],1)],1)],1),"first"==e.activeName?t("div",{directives:[{name:"loading",rawName:"v-loading.fullscreen.lock",value:e.fullscreenLoading,expression:"fullscreenLoading",modifiers:{fullscreen:!0,lock:!0}}],attrs:{"element-loading-text":e.timeLeft+"S"}}):e._e()])},U=[],E=(a(4114),a(8111),a(2489),a(3110),{name:"HelloWorld",props:{msg:String},data(){return{activeName:"first",scannedItems:[],timeLeft:20,fullscreenLoading:!1,configData:{},dialogFileVisible:!1,ruleForm:{orderID:"",fileList:[]},uploadUrl:"",tableLoading:!1,form:{},dialogAnalysisileVisible:!1,resultSixData:{},savedFileList:[],currentPage:1,pageSize:5,total:0,scannedCode:"",allSavedFileList:[],selectedFilePath:"",selectedFileData:null}},async mounted(){this.configData=await window.api.getConfig(),this.configData&&(this.timeLeft=Number(this.configData.device.reconnect_time),this.uploadUrl=this.configData.device.address,this.getSavedFileInfo())},methods:{handleClick(){this.fullscreenLoading=!1,this.timeLeft=Number(this.configData.device.reconnect_time),this.tableLoading=!0,this.savedFileList=[],this.scannedCode="",setTimeout(()=>{this.tableLoading=!1},1e3),this.getSavedFileInfo()},configPage(){this.$router.push("/configFile")},goPage(){this.$router.push("/history")},handleScan(e){"Tab"!==e.key&&"Enter"!==e.key||(this.scannedCode=e.target.value.trim(),"first"==this.activeName&&(this.fullscreenLoading=!0,this.startCountdown()))},startCountdown(){this.interval=setInterval(()=>{if(this.timeLeft>0)this.timeLeft-=1;else{clearInterval(this.interval),this.fullscreenLoading=!1,this.timeLeft=Number(this.configData.device.reconnect_time);const e=this.scannedCode;this.uploadFile(e,"倒计时")}},1e3)},autoUpload(){if(""==this.scannedCode)return this.$message.error("请先扫描订单号"),!1;this.tableLoading=!0;const e=this.scannedCode;this.uploadFile(e,"手动上传")},async uploadFile(e,t){try{this.errorMsg="",this.hasRead=!0,this.tableLoading=!0;const a=await window.api.readCFolder({path:`${this.configData.device.filePathDisc}:/${this.configData.device.file_path}`,orderNum:e});console.log("res",a,`${this.configData.device.filePathDisc}:/${this.configData.device.file_path}`),a.success?(this.fileList=a.data,console.log("获取最新的文件数据",a.data),this.fileUpload1(a.data,e,t)):(this.errorMsg=a.msg,this.tableLoading=!1,this.$message.error(this.errorMsg))}catch(a){this.errorMsg=`读取失败:${a.message}`}},async fileUpload1(e,t,a){try{const i=new AbortController,s=setTimeout(()=>i.abort(),5e3),l=new File([e.fileBuffer],e.fileName,{type:"application/octet-stream"}),o=new FormData;o.append("file",l),o.append("token",this.configData.device.username),o.append("deviceId",this.configData.device.code),o.append("orderNumber",t),o.append("deviceModel",this.configData.device.codeType);const n=await fetch(this.configData.device.address+"/upper/send",{method:"POST",body:o,signal:i.signal});clearTimeout(s);const r=await n.json();console.log("上传结果接口返回:",r.data),0==r.code?(this.tableLoading=!1,this.saveFileInfoToLocal({deviceId:this.configData.device.code,orderNumber:t,deviceModel:this.configData.device.codeType,fileName:e.fileName,analysisDate:JSON.stringify(r.data),type:this.activeName,date:this.getCurrentDateTime(),uploadType:a}),this.ruleForm.fileList=[],this.$message({message:"上传成功",type:"success"}),this.getSavedFileInfo()):(this.ruleForm.fileList=[],this.tableLoading=!1,this.$message({message:r.msg,type:"error"}))}catch(i){this.tableLoading=!1,this.ruleForm.fileList=[],"AbortError"===i.name?this.$message({message:"请求超时,请检查网络或服务器状态",type:"error"}):this.$message({message:i.message||"上传异常",type:"error"}),console.error("上传失败详情:",i)}},beforeUpload(e){return""!=this.scannedCode||(this.$message.error("请先输入或扫描订单号"),!1)},async uploadFileChange(e){if(!this.scannedCode)return this.$message.error("请先输入或扫描订单号"),void this.$nextTick(()=>{this.ruleForm.fileList=[]});console.log("选择文件",e),this.ruleForm.fileList=[e];const t=await window.api.renameFile({file:this.ruleForm.fileList[0],filePath:this.ruleForm.fileList[0].raw.path,orderNumber:this.scannedCode});t.success?(console.log("重命名成功",t),this.fileUpload1(t.data,this.scannedCode,"手动选择上传文件")):this.$message.error("重命名失败",t)},handleExceed(e,t){this.$message.warning("当前限制选择 1 个文件")},beforeRemove(e,t){return this.$confirm(`确定移除 ${e.name}`)},uploadSuccess(e,t,a){console.log("文件上传成功")},uploadError(e,t,a){console.log("文件上传失败")},async saveFileInfoToLocal(e){try{this.tipsMsg="",this.errorMsg="";const t=await window.api.saveFileInfo([e]);t.success?(this.tipsMsg=t.msg,this.getSavedFileInfo()):this.errorMsg=t.msg}catch(t){this.errorMsg=`存储失败:${t.message}`}},async getSavedFileInfo(){try{const e=await window.api.getSavedFileInfo();e.success?("first"==this.activeName&&(this.savedFileList=e.data.filter(e=>"倒计时"==e.uploadType)),"three"==this.activeName&&(this.savedFileList=e.data.filter(e=>"手动上传"==e.uploadType)),"four"==this.activeName&&(this.savedFileList=e.data.filter(e=>"手动选择上传文件"==e.uploadType)),this.allSavedFileList=this.savedFileList,this.total=this.savedFileList.length,this.updateCurrentPageData(),this.tipsMsg=`成功读取本地${e.data.length}条文件信息`):this.errorMsg=e.msg}catch(e){this.errorMsg=`读取本地数据失败:${e.message}`}},getCurrentDateTime(){const e=new Date,t=e.getFullYear(),a=String(e.getMonth()+1).padStart(2,"0"),i=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),l=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0");return`${t}-${a}-${i} ${s}:${l}:${o}`},updateCurrentPageData(){const e=(this.currentPage-1)*this.pageSize,t=e+this.pageSize;this.savedFileList=this.allSavedFileList.slice(e,t)},handleSizeChange(e){this.pageSize=e,this.currentPage=1,this.updateCurrentPageData()},handleCurrentChange(e){this.currentPage=e,this.updateCurrentPageData()}},beforeDestroy(){window.api.removeStoreValue("key")}}),B=E,j=(0,r.A)(B,R,U,!1,null,"6f30a2d4",null),W=j.exports,q=function(){var e=this;e._self._c;return e._m(0)},H=[function(){var e=this,t=e._self._c;return t("div",[t("p",[e._v("Welcome to Utils-Hub.")])])}],V={name:"Dashboard",data(){return{}}},Q=V,J=(0,r.A)(Q,q,H,!1,null,null,null),G=J.exports,K=function(){var e=this,t=e._self._c;return t("div",e._l(e.utilsList,function(a){return t("div",[t("el-card",{staticClass:"box-card",nativeOn:{click:function(t){return e.createUtilsWin(a.flag)}}},[t("div",{staticClass:"clearfix",attrs:{slot:"header"},slot:"header"},[t("h2",[t("i",{class:a.icon}),e._v(" "+e._s(a.title))])]),t("div",{staticClass:"descCls"},[e._v(" "+e._s(a.desc)+" ")])])],1)}),0)},Y=[],X={name:"CommonUtils",methods:{createUtilsWin(e){if("other"===e)return this.$message.warning("暂无更多需求!"),!1;window.api.getConfig()}},data(){return{utilsList:[{id:"1",flag:"transfer",title:"大小写转换",desc:"键入字符,将其转换为大写字符或小写字符",icon:"el-icon-refresh"},{id:"6",flag:"other",title:"Other",desc:"需求加载中...",icon:"el-icon-loading"}]}}},Z=X,ee=(0,r.A)(Z,K,Y,!1,null,"7f6132b8",null),te=ee.exports,ae=function(){var e=this,t=e._self._c;return t("div",[t("el-page-header",{attrs:{content:"历史记录"},on:{back:e.goBack}}),t("el-table",{staticStyle:{width:"100%","margin-top":"20px"},attrs:{data:e.scannedItems,border:"",stripe:""}},[t("el-table-column",{attrs:{prop:"code",label:"订单号",width:"130","show-overflow-tooltip":""}}),t("el-table-column",{attrs:{prop:"deviceId",label:"设备编号","show-overflow-tooltip":""}}),t("el-table-column",{attrs:{prop:"updateDate",label:"上传日期","show-overflow-tooltip":""}}),t("el-table-column",{attrs:{prop:"uploadType",label:"上传类型"}}),t("el-table-column",{attrs:{prop:"uploadPath",label:"上传路径","show-overflow-tooltip":""}}),t("el-table-column",{attrs:{prop:"uploadRes",label:"上传结果"}}),t("el-table-column",{attrs:{prop:"uploadCon",label:"上传内容数据",width:"180","show-overflow-tooltip":""}})],1),t("div",{staticStyle:{float:"right","margin-top":"20px"}},[t("el-pagination",{attrs:{small:"",layout:"prev, pager, next",total:1e4}})],1)],1)},ie=[],se={data(){return{scannedItems:[{code:"0001",deviceId:"23233",updateDate:"2025-04-01",uploadPath:"c:/检测记录",uploadRes:"成功",uploadType:"倒计时",uploadCon:"{'数据1':'内容1','数据1':'内容1','数据1':'内容1'}"},{code:"0001",deviceId:"23233",updateDate:"2025-04-01",uploadPath:"c:/检测记录",uploadRes:"成功",uploadType:"倒计时",uploadCon:"{'数据1':'内容1','数据1':'内容1','数据1':'内容1'}"},{code:"0001",deviceId:"23233",updateDate:"2025-04-01",uploadPath:"c:/检测记录",uploadRes:"成功",uploadType:"倒计时",uploadCon:"{'数据1':'内容1','数据1':'内容1','数据1':'内容1'}"},{code:"0001",deviceId:"23233",updateDate:"2025-04-01",uploadPath:"c:/检测记录",uploadRes:"成功",uploadType:"倒计时",uploadCon:"{'数据1':'内容1','数据1':'内容1','数据1':'内容1'}"}]}},methods:{goBack(){this.$router.go(-1)}}},le=se,oe=(0,r.A)(le,ae,ie,!1,null,null,null),ne=(oe.exports,function(){var e=this,t=e._self._c;return t("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"loading"}],staticStyle:{float:"left"}},[t("el-page-header",{attrs:{content:"配置文件"},on:{back:e.goBack}}),t("el-form",{ref:"device",staticStyle:{"margin-top":"20px"},attrs:{model:e.device,"label-width":"150px"}},[t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"token"}},[t("el-input",{attrs:{size:"mini"},model:{value:e.device.username,callback:function(t){e.$set(e.device,"username",t)},expression:"device.username"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"设备编号"}},[t("el-input",{attrs:{size:"mini"},model:{value:e.device.code,callback:function(t){e.$set(e.device,"code",t)},expression:"device.code"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"设备型号"}},[t("el-input",{attrs:{size:"mini"},model:{value:e.device.codeType,callback:function(t){e.$set(e.device,"codeType",t)},expression:"device.codeType"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"上传文件间隔时间"}},[t("el-input",{attrs:{size:"mini"},model:{value:e.device.reconnect_time,callback:function(t){e.$set(e.device,"reconnect_time",t)},expression:"device.reconnect_time"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"上传服务器地址"}},[t("el-input",{attrs:{size:"mini"},model:{value:e.device.address,callback:function(t){e.$set(e.device,"address",t)},expression:"device.address"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"文件检索目录"}},[t("el-input",{attrs:{size:"mini"},model:{value:e.device.filePathDisc,callback:function(t){e.$set(e.device,"filePathDisc",t)},expression:"device.filePathDisc"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"文件检索文件目录"}},[t("el-input",{attrs:{size:"mini"},model:{value:e.device.file_path,callback:function(t){e.$set(e.device,"file_path",t)},expression:"device.file_path"}})],1)],1),t("el-col",{attrs:{span:12}},[t("el-form-item",{attrs:{label:"是否修改文件名字"}},[t("el-radio-group",{model:{value:e.device.updateFileName,callback:function(t){e.$set(e.device,"updateFileName",t)},expression:"device.updateFileName"}},[t("el-radio",{attrs:{label:"1"}},[e._v("是")]),t("el-radio",{attrs:{label:"2"}},[e._v("否")])],1)],1)],1)],1),t("div",{staticStyle:{float:"right",position:"fixed",bottom:"10px",right:"10px"}},[t("el-button",{attrs:{type:"primary",size:"small"},on:{click:function(t){return e.save()}}},[e._v("确定")])],1)],1)}),re=[],ce=(a(7588),{data(){return{loading:!1,device:{username:"",code:"0P0123",codeType:"ER-HUIN",reconnect_time:"10",address:'http://10.1.19.126:8765/file/send"',filePathDisc:"C",file_path:"检索目录",no_report_path:"未上报目录"},mqttInfo:{address:"tcp://127.0.0.1:1883/",username:"admin",password:'123456"',client_id:"mqttx_addd134",path:"/mgtt",reconnect_time:"10",status_reporting_time:"10",topic:'v1/telemetry/device/v1"'},configData:{}}},methods:{async init(){this.configData=await window.api.getConfig(),this.configData&&(this.configData.device&&Object.keys(this.device).forEach(e=>{this.configData.device.hasOwnProperty(e)&&(this.device[e]=this.configData.device[e])}),this.configData.MQTT&&Object.keys(this.mqttInfo).forEach(e=>{this.configData.MQTT.hasOwnProperty(e)&&(this.mqttInfo[e]=this.configData.MQTT[e])}))},goBack(){this.$router.go(-1)},save(){let e={MQTT:this.mqttInfo,device:this.device};console.log("提交前的配置信息:",JSON.stringify(e,null,2)),console.log("device:",this.device),console.log("mqttInfo:",this.mqttInfo),this.loading=!0,window.api.updateConfig(e),setTimeout(()=>{this.loading=!1,this.$message({message:"配置成功",type:"success"})},1e3)}},mounted(){this.init()}}),de=ce,ue=(0,r.A)(de,ne,re,!1,null,null,null),pe=ue.exports,he=function(){var e=this,t=e._self._c;return t("div",{staticClass:"file-upload"},[t("div",{staticClass:"upload-area",on:{click:e.selectFile}},[e._m(0)]),e.selectedFile?t("div",{staticClass:"file-info"},[t("div",{staticClass:"file-item"},[t("div",{staticClass:"file-name"},[e._v(e._s(e.selectedFile.name))]),t("div",{staticClass:"file-path"},[e._v(e._s(e.selectedFile.path))]),t("div",{staticClass:"file-size"},[e._v(e._s(e.formatFileSize(e.selectedFile.size)))])]),t("div",{staticClass:"rename-section"},[t("el-input",{attrs:{placeholder:"输入新文件名(不含扩展名)",clearable:""},scopedSlots:e._u([{key:"append",fn:function(){return[t("span",{staticClass:"file-ext"},[e._v("."+e._s(e.selectedFile.extension))])]},proxy:!0}],null,!1,3270550684),model:{value:e.newFileName,callback:function(t){e.newFileName=t},expression:"newFileName"}}),t("div",{staticClass:"action-buttons"},[t("el-button",{attrs:{type:"primary",loading:e.renaming,disabled:!e.newFileName},on:{click:e.handleRename}},[e._v(" 重命名文件 ")]),t("el-button",{attrs:{type:"success",loading:e.uploading,disabled:!e.renamedFile},on:{click:e.handleUpload}},[e._v(" 上传文件 ")]),t("el-button",{on:{click:e.clearSelection}},[e._v(" 取消选择 ")])],1)],1),e.renamedFile?t("div",{staticClass:"renamed-info"},[t("el-alert",{attrs:{title:"文件已重命名",type:"success",closable:!1}},[t("p",[e._v("新路径:"+e._s(e.renamedFile.path))])])],1):e._e()]):e._e(),e.uploadResult?t("div",{staticClass:"upload-result"},[t("el-alert",{attrs:{title:e.uploadResult.success?"上传成功":"上传失败",type:e.uploadResult.success?"success":"error",closable:!0},on:{close:function(t){e.uploadResult=null}}},[e.uploadResult.success?t("p",[e._v("文件已成功上传到服务器")]):t("p",[e._v(e._s(e.uploadResult.error))])])],1):e._e()])},me=[function(){var e=this,t=e._self._c;return t("div",{staticClass:"upload-content"},[t("i",{staticClass:"el-icon-upload"}),t("div",{staticClass:"upload-text"},[e._v("点击选择文件")])])}],fe={name:"FileUpload",components:{},data(){return{selectedFile:null,newFileName:"",renamedFile:null,renaming:!1,uploading:!1,uploadResult:null}},methods:{async selectFile(){try{const e=await window.electronAPI.openFileDialog();if(e){const t=await window.electronAPI.getFileInfo(e);this.selectedFile={path:e,name:this.getFileNameWithoutExt(e),extension:this.getFileExtension(e),size:t.size,...t},this.newFileName=this.selectedFile.name,this.renamedFile=null,this.uploadResult=null}}catch(e){this.$message.error("选择文件失败:"+e.message)}},async handleRename(){if(this.selectedFile&&this.newFileName.trim()){this.renaming=!0;try{const e=await window.electronAPI.renameFile({oldPath:this.selectedFile.path,newName:this.newFileName.trim()});e.success?(this.renamedFile={path:e.newPath,name:this.newFileName.trim()+"."+this.selectedFile.extension},this.$message.success("文件重命名成功")):this.$message.error("重命名失败:"+e.error)}catch(e){this.$message.error("重命名失败:"+e.message)}finally{this.renaming=!1}}},async handleUpload(){if(this.renamedFile){this.uploading=!0,this.uploadResult=null;try{const e=await this.uploadFileViaFetch(this.renamedFile.path);this.uploadResult=e,e.success?this.$message.success("文件上传成功"):this.$message.error("文件上传失败")}catch(e){this.uploadResult={success:!1,error:e.message},this.$message.error("上传失败:"+e.message)}finally{this.uploading=!1}}},async uploadFileViaFetch(e){const t=new FormData,a=await window.electronAPI.readFileAsBuffer(e),i=this.getFileNameFromPath(e),s=new Blob([a]);t.append("file",s,i),t.append("originalName",this.selectedFile.name),t.append("renamedName",this.newFileName);const l=await fetch("http://your-api-endpoint/upload",{method:"POST",body:t});if(!l.ok)throw new Error(`HTTP error! status: ${l.status}`);const o=await l.json();return{success:!0,data:o}},getFileNameWithoutExt(e){const t=this.getFileNameFromPath(e),a=t.lastIndexOf(".");return-1===a?t:t.substring(0,a)},getFileExtension(e){const t=this.getFileNameFromPath(e),a=t.lastIndexOf(".");return-1===a?"":t.substring(a+1)},getFileNameFromPath(e){return e.split("\\").pop().split("/").pop()},formatFileSize(e){if(0===e)return"0 Bytes";const t=1024,a=["Bytes","KB","MB","GB","TB"],i=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,i)).toFixed(2))+" "+a[i]},clearSelection(){this.selectedFile=null,this.renamedFile=null,this.uploadResult=null,this.newFileName=""}}},ge=fe,ve=(0,r.A)(ge,he,me,!1,null,"4d46612a",null),be=ve.exports;i["default"].use(h.Ay);const we=[{path:"/",component:T,children:[{path:"",component:W},{path:"dashboard",component:G},{path:"common-utils",component:te},{path:"history",component:be},{path:"configFile",component:pe}]},{path:"/sub-win",component:w,children:[{path:"about-win",component:k},{path:"transfer-win",component:A}]}],ye=new h.Ay({mode:"hash",routes:we});var Fe=ye;i["default"].config.productionTip=!1,i["default"].use(p()),new i["default"]({router:Fe,render:e=>e(d)}).$mount("#app")}},t={};function a(i){var s=t[i];if(void 0!==s)return s.exports;var l=t[i]={id:i,loaded:!1,exports:{}};return e[i].call(l.exports,l,l.exports,a),l.loaded=!0,l.exports}a.m=e,function(){a.amdO={}}(),function(){var e=[];a.O=function(t,i,s,l){if(!i){var o=1/0;for(d=0;d<e.length;d++){i=e[d][0],s=e[d][1],l=e[d][2];for(var n=!0,r=0;r<i.length;r++)(!1&l||o>=l)&&Object.keys(a.O).every(function(e){return a.O[e](i[r])})?i.splice(r--,1):(n=!1,l<o&&(o=l));if(n){e.splice(d--,1);var c=s();void 0!==c&&(t=c)}}return t}l=l||0;for(var d=e.length;d>0&&e[d-1][2]>l;d--)e[d]=e[d-1];e[d]=[i,s,l]}}(),function(){a.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return a.d(t,{a:t}),t}}(),function(){a.d=function(e,t){for(var i in t)a.o(t,i)&&!a.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})}}(),function(){a.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()}(),function(){a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){a.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}}(),function(){a.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e}}(),function(){var e={524:0};a.O.j=function(t){return 0===e[t]};var t=function(t,i){var s,l,o=i[0],n=i[1],r=i[2],c=0;if(o.some(function(t){return 0!==e[t]})){for(s in n)a.o(n,s)&&(a.m[s]=n[s]);if(r)var d=r(a)}for(t&&t(i);c<o.length;c++)l=o[c],a.o(e,l)&&e[l]&&e[l][0](),e[l]=0;return a.O(d)},i=self["webpackChunkutils_hub_demo"]=self["webpackChunkutils_hub_demo"]||[];i.forEach(t.bind(null,0)),i.push=t.bind(null,i.push.bind(i))}();var i=a.O(void 0,[504],function(){return a(2534)});i=a.O(i)})();
//# sourceMappingURL=app.4109ee0c.js.map