Kaynağa Gözat

Merge branch 'iteration-20231220'

lex 1 yıl önce
ebeveyn
işleme
58198a33a9

+ 20 - 3
src/pc/component/upload-file/index.tsx

@@ -5,6 +5,7 @@ import iconUpload from "../upload-to-tasks/images/icon-upload.png";
 import { getUploadSign, onFileUpload, onOnlyFileUpload } from "/src/utils/oss-file-upload";
 import { api_musicalScoreConversionRecordSave } from "../../api";
 import { uploadState, eventGlobal } from "../upload-to-tasks/state";
+import requestOrigin from "umi-request";
 
 export default defineComponent({
   name: "upload-file",
@@ -77,9 +78,25 @@ export default defineComponent({
             file: file,
           };
           onOnlyFileUpload("action", fileParams).then(async (res: any) => {
-            console.log(res, "res");
-            const result = await api_musicalScoreConversionRecordSave([{ fileName, fileUrl: res }]);
-
+            let status = true;
+            const type = file.type.includes("png") || file.type.includes("jpg") || file.type.includes("jpeg") ? "IMG" : file.type.includes("xml") ? "XML" : file.type.includes("application/pdf") ? "pdf" : "other";
+            if (type === "XML") {
+              console.log(file, "files");
+              try {
+                const result = await requestOrigin.get(res, {
+                  mode: "cors",
+                });
+                // console.log(result, "result");
+                let abc: any = new DOMParser().parseFromString(result, "text/xml");
+                const title = abc.querySelector("parsererror");
+                console.log(abc, "abc", title);
+                status = title ? false : true;
+              } catch {
+                //
+              }
+            }
+            // 判断xml是否生成失败
+            const result = await api_musicalScoreConversionRecordSave([{ fileName, fileUrl: res, status: status ? null : "FAIL" }]);
             uploadState.uploadList.push({
               fileName,
               fileUrl: res,

+ 7 - 0
src/pc/component/upload-to-tasks/state.ts

@@ -17,6 +17,13 @@ export const uploadState = reactive({
 
 /** 保存缓存 */
 export const saveUploadCatch = (list?: any[]) => {
+  // const tempList: any = uploadState.uploadList
+  // if(list && list.length > 0) {
+  //   tempList.forEach((item: any) => {
+  //     const findItem = list.find((l: any) => l.id === item.id)
+
+  //   })
+  // }
   sessionStorage.setItem(UPLOADKEY, JSON.stringify(list || uploadState.uploadList));
 };
 

+ 10 - 1
src/pc/create/index.tsx

@@ -177,6 +177,13 @@ export default defineComponent({
                               mode: "cors",
                             });
                             let abc: any = new DOMParser().parseFromString(result, "text/xml");
+                            const title = abc.querySelector("movement-title");
+                            // xmlParse.getElementsByTagName("words");
+                            // const title = abc.getElementsByTagName("movement-title");
+                            if (title && title.textContent.trim() !== item?.name) {
+                              title.textContent = item.name;
+                            }
+
                             abc = (window as any).vertaal(abc, { p: "f", t: 1, u: 0, v: 3, mnum: 0 });
                             const r: any = ABCJS.renderAbc("importRef", abc[0], { responsive: "resize" }); //ABCJS.renderAbc("item_" + index, abc[0], { selectTypes: false, add_classes: true })[0];
                             const abcd = formateAbc(r[0], { subjectCode: "acoustic_grand_piano" });
@@ -186,7 +193,9 @@ export default defineComponent({
                               showCreator: true,
                             });
                             item.visualObj = productSvg(config, "item_" + index);
-                          } catch {}
+                          } catch (e) {
+                            console.log(e, "1222222");
+                          }
                         } else {
                           item.visualObj = productSvg(item.creationConfig, "item_" + index);
                         }