Ver Fonte

添加设备烧录按钮

一只小菜杨 há 2 meses atrás
pai
commit
731793da5f
2 ficheiros alterados com 23 adições e 8 exclusões
  1. 22 8
      src/views/ProjectInfo.vue
  2. 1 0
      vite.config.ts

+ 22 - 8
src/views/ProjectInfo.vue

@@ -33,14 +33,15 @@
     <van-popup v-model:show="showMorePopup" position="right" :style="{ width: '50%', height: '100%' }">
       <van-cell-group :style="{ marginTop: '16px' }">
         <van-cell title="编辑工程名称" clickable @click="handleEditName" />
-        <van-cell title="下载到设备" @click="getXMLFile" clickable />
-        <van-cell title="删除工程" @click="delProject" clickable />
+        <van-cell title="编译文件" @click="getXMLFile" clickable />
+        <van-cell title="设备烧录" @click="burnToDevice" clickable />
         <wx-open-launch-weapp username="小程序的原始ID(gh_开头)" path="pages/index/index?param1=xxx&param2=xxx">
           <template>
             <!-- 自定义跳转按钮样式 -->
             <button style="padding: 10px; background: #07c160; color: white">点击跳转小程序</button>
           </template>
         </wx-open-launch-weapp>
+        <van-cell title="删除工程" @click="delProject" clickable />
       </van-cell-group>
     </van-popup>
 
@@ -165,6 +166,7 @@ const handleAddCommond = () => {
   })
 }
 
+// 文件编译
 const getXMLFile = () => {
   if (!crtProject.value) return
   let xml = ''
@@ -1359,15 +1361,27 @@ const getXMLFile = () => {
   console.log(xml)
   // 生成文件下载
   const blob = new Blob([xml], { type: 'text/plain;charset=utf-8' })
+  const formdata = new FormData()
+  formdata.append('file', blob, 'project.xml')
+  fetch('http://192.168.88.1:8080/api/upload', {
+    method: 'POST',
+    body: formdata
+  }).then((res) => res.json()).then((res) => {
+    console.log(res)
+  })
 
-  const link = document.createElement('a')
-  link.href = URL.createObjectURL(blob)
-  link.download = 'project.xml'
-  link.click()
-  URL.revokeObjectURL(link.href)
-  link.remove()
+  // const link = document.createElement('a')
+  // link.href = URL.createObjectURL(blob)
+  // link.download = 'project.xml'
+  // link.click()
+  // URL.revokeObjectURL(link.href)
+  // link.remove()
 }
 
+// 设备烧录
+const burnToDevice = () => {}
+
+// 删除工程
 const delProject = () => {
   if (crtProject.value) {
     showConfirmDialog({

+ 1 - 0
vite.config.ts

@@ -43,6 +43,7 @@ export default defineConfig({
   server: {
     host: '0.0.0.0',
     cors: true,
+    port: 8080,
     proxy: {
       '/api': {
         target: 'http://smartelectric.worldflying.cn',