Browse Source

Merge remote-tracking branch 'origin/develop' into develop

zishan-an 1 year ago
parent
commit
5eb7341406
4 changed files with 598 additions and 180 deletions
  1. 558 167
      package-lock.json
  2. 38 10
      src/views/system/modelModify.vue
  3. 1 1
      src/views/system/otherModel.vue
  4. 1 2
      src/views/system/userinfo.vue

File diff suppressed because it is too large
+ 558 - 167
package-lock.json


+ 38 - 10
src/views/system/modelModify.vue

@@ -52,7 +52,11 @@
                     <el-button round type="success" size="medium" style="margin-right: 10px;" @click="confirmModel">
                         确认修改
                     </el-button>
-                    <el-button round type="primary" size="medium" style="margin-right: 10px;" @click="returnLink">返回
+                    <el-button round type="warning" size="medium" style="margin-right: 10px;" @click="downloadFile">
+                        下载
+                    </el-button>
+                    <el-button round type="primary" size="medium" style="margin-right: 10px;" @click="returnLink">
+                        返回
                     </el-button>
                 </div>
             </el-main>
@@ -69,6 +73,8 @@ import {
 import store from "@/store";
 import request from '@/utils/request.js'
 import Axios, {AxiosResponse} from "axios";
+import axios from "axios";
+import {error} from "vue-resource/src/util";
 // import { randomId } from '../../api';
 export default {
     name: "mxpz",
@@ -106,7 +112,7 @@ export default {
                 },
 
             ],
-            suffix_idx:["jar","py","war"],
+            suffix_idx: ["jar", "py", "war"],
 
             // model_type: this.type_list[this.$route.query.modelType - 1].label,
         }
@@ -115,8 +121,31 @@ export default {
         this.model_type = this.type_list[this.$route.query.modelType - 1].key;
     },
     methods: {
+        downloadFile() {
+            const filename = this.filePath.split('/').pop(); // 要下载的文件名
+            request.get(`/othermodel/download/${filename}`).then(res => {
+                console.log("success");
+                const base64Data = res.data.file;
+                const byteCharacters = atob(base64Data); // 使用atob解码Base64字符串
+                const byteNumbers = new Array(byteCharacters.length);
+                for (let i = 0; i < byteCharacters.length; i++) {
+                    byteNumbers[i] = byteCharacters.charCodeAt(i);
+                }
+                const byteArray = new Uint8Array(byteNumbers)
+                const blob = new Blob([byteArray], {type: 'application/octet-stream'});
+                const downloadUrl = URL.createObjectURL(blob);
+                const link = document.createElement('a');
+                link.href = downloadUrl;
+                link.download = filename; // 替换为你的文件名及扩展名
+                link.click();
+            })
+            .catch(error => {
+                console.error('Error downloading file:', error);
+            });
+
+        },
         confirmModel() {
-            const isModifyName=this.inputValue !== '' && this.inputValue !==this.$route.query.modelName;
+            const isModifyName = this.inputValue !== '' && this.inputValue !== this.$route.query.modelName;
             if (isModifyName) {
                 this.modelName = this.inputValue;
 
@@ -129,7 +158,7 @@ export default {
             }
 
             let myfile = this.$refs.myfile;
-            const isModifyFile=myfile.files.length > 0;
+            const isModifyFile = myfile.files.length > 0;
             if (isModifyFile) {
 
                 if (this.model_type == "") {
@@ -141,13 +170,13 @@ export default {
                 let files = myfile.files;
                 let file = files[0];
                 let fileName = file.name;
-                console.log("filename: %s",fileName);
+                console.log("filename: %s", fileName);
                 let index = fileName.lastIndexOf(".");
                 if (index != -1) {
                     let suffix = fileName.substr(index + 1).toLowerCase();
                     const type = this.type_list.find(item => item.key === this.model_type);
 
-                    if (suffix != this.suffix_idx[type.key-1]) {
+                    if (suffix != this.suffix_idx[type.key - 1]) {
                         this.$alert("请上传正确格式文件!");
                         return;
                     }
@@ -156,14 +185,13 @@ export default {
                 this.handleUpload();
             }
 
-            if(!isModifyName&&!isModifyFile){
+            if (!isModifyName && !isModifyFile) {
                 this.$alert("请输入模型名称或上传文件");
                 return;
             }
 
             // 异步请求,增加一层条件判断
-            if(isModifyName&&!isModifyFile)
-            {
+            if (isModifyName && !isModifyFile) {
                 this.$message.success('修改成功');
                 this.$router.push({
                     path: '/modelEdit',
@@ -303,7 +331,7 @@ export default {
                         }
                     )
                     .then((res) => {
-                        this.filePath=res.data.file_path;
+                        this.filePath = res.data.file_path;
                         this.$message.success('修改成功');
                         console.log(res);
 

+ 1 - 1
src/views/system/otherModel.vue

@@ -119,7 +119,7 @@ export default {
                 {
                     key: 3,
                     label: "http服务"
-                },
+                }
             ],
         }
     },

+ 1 - 2
src/views/system/userinfo.vue

@@ -136,8 +136,7 @@ export default {
                 "自定义模型",
                 "jar模型",
                 "python模型",
-                "http服务",
-                "空模型"
+                "http服务"
             ],
             field_show: false,
             model_show: false,

Some files were not shown because too many files changed in this diff