浏览代码

图片请求

natasha 2 周之前
父节点
当前提交
e227d44b4f
共有 2 个文件被更改,包括 91 次插入55 次删除
  1. 90 55
      src/views/bookShelf/articleDetail.vue
  2. 1 0
      src/views/bookStore/index.vue

+ 90 - 55
src/views/bookShelf/articleDetail.vue

@@ -1420,17 +1420,63 @@ export default {
                       items.indexOf('src="') + 5,
                       indexS + 5
                     );
-                    let MethodNames =
-                      "/FileServer/FilePackManager/GetFileBytesBase64TextByURL";
-                    let datas = {
-                      url: oldSrc,
-                    };
-                    getLogin(MethodNames, datas)
-                      .then((res) => {
-                        if (res.status === 1) {
+                    if (oldSrc.indexOf("http") > -1) {
+                      let MethodNames =
+                        "/FileServer/FilePackManager/GetFileBytesBase64TextByURL";
+                      let datas = {
+                        url: oldSrc,
+                      };
+                      getLogin(MethodNames, datas)
+                        .then((res) => {
+                          if (res.status === 1) {
+                            let imgobj = {
+                              src: oldSrc,
+                              newSrc:
+                                "data:image/jpeg;base64," + res.base64_text,
+                              width:
+                                items.indexOf('width="') > -1
+                                  ? items.substring(
+                                      items.indexOf('width="') + 7,
+                                      items.indexOf('width="') + indexW + 7
+                                    )
+                                  : items.indexOf("width: ") > -1
+                                  ? items.substring(
+                                      items.indexOf("width: ") + 7,
+                                      items.indexOf("width: ") + indexW + 7
+                                    )
+                                  : null,
+                              height:
+                                items.indexOf('height="') > -1
+                                  ? items.substring(
+                                      items.indexOf('height="') + 8,
+                                      items.indexOf('height="') + indexH + 8
+                                    )
+                                  : items.indexOf("height: ") > -1
+                                  ? items.substring(
+                                      items.indexOf("height: ") + 8,
+                                      items.indexOf('height="') + indexH + 8
+                                    )
+                                  : null,
+                            };
+                            imgArr.push(imgobj);
+                            let newItems = items.replace(
+                              oldSrc,
+                              "data:image/jpeg;base64," + res.base64_text
+                            );
+                            this.articleInfo.art_content =
+                              this.articleInfo.art_content.replace(
+                                oldSrc,
+                                "data:image/jpeg;base64," + res.base64_text
+                              );
+                            items = newItems;
+                          }
+                        })
+                        .catch(() => {
                           let imgobj = {
-                            src: oldSrc,
-                            newSrc: "data:image/jpeg;base64," + res.base64_text,
+                            src: items.substring(
+                              items.indexOf('src="') + 5,
+                              indexS + 5
+                            ),
                             width:
                               items.indexOf('width="') > -1
                                 ? items.substring(
@@ -1457,51 +1503,40 @@ export default {
                                 : null,
                           };
                           imgArr.push(imgobj);
-                          let newItems = items.replace(
-                            oldSrc,
-                            "data:image/jpeg;base64," + res.base64_text
-                          );
-                          this.articleInfo.art_content =
-                            this.articleInfo.art_content.replace(
-                              oldSrc,
-                              "data:image/jpeg;base64," + res.base64_text
-                            );
-                          items = newItems;
-                        }
-                      })
-                      .catch(() => {
-                        let imgobj = {
-                          src: items.substring(
-                            items.indexOf('src="') + 5,
-                            indexS + 5
-                          ),
-                          width:
-                            items.indexOf('width="') > -1
-                              ? items.substring(
-                                  items.indexOf('width="') + 7,
-                                  items.indexOf('width="') + indexW + 7
-                                )
-                              : items.indexOf("width: ") > -1
-                              ? items.substring(
-                                  items.indexOf("width: ") + 7,
-                                  items.indexOf("width: ") + indexW + 7
-                                )
-                              : null,
-                          height:
-                            items.indexOf('height="') > -1
-                              ? items.substring(
-                                  items.indexOf('height="') + 8,
-                                  items.indexOf('height="') + indexH + 8
-                                )
-                              : items.indexOf("height: ") > -1
-                              ? items.substring(
-                                  items.indexOf("height: ") + 8,
-                                  items.indexOf('height="') + indexH + 8
-                                )
-                              : null,
-                        };
-                        imgArr.push(imgobj);
-                      });
+                        });
+                    } else {
+                      let imgobj = {
+                        src: items.substring(
+                          items.indexOf('src="') + 5,
+                          indexS + 5
+                        ),
+                        width:
+                          items.indexOf('width="') > -1
+                            ? items.substring(
+                                items.indexOf('width="') + 7,
+                                items.indexOf('width="') + indexW + 7
+                              )
+                            : items.indexOf("width: ") > -1
+                            ? items.substring(
+                                items.indexOf("width: ") + 7,
+                                items.indexOf("width: ") + indexW + 7
+                              )
+                            : null,
+                        height:
+                          items.indexOf('height="') > -1
+                            ? items.substring(
+                                items.indexOf('height="') + 8,
+                                items.indexOf('height="') + indexH + 8
+                              )
+                            : items.indexOf("height: ") > -1
+                            ? items.substring(
+                                items.indexOf("height: ") + 8,
+                                items.indexOf('height="') + indexH + 8
+                              )
+                            : null,
+                      };
+                      imgArr.push(imgobj);
+                    }
                   }
                 });
                 this.$set(this.articleImg, pno, imgArr);

+ 1 - 0
src/views/bookStore/index.vue

@@ -512,6 +512,7 @@ export default {
   },
   //生命周期 - 创建完成(可以访问当前this实例)
   created() {
+    console.log("2025-12-02");
     const regExp = /Android|webOS|iPhone|BlackBerry|IEMobile|Opera Mini/i;
     this.isPhone = regExp.test(navigator.userAgent) && window.innerWidth < 860;
     // 如果是开发环境 提示正式环境地址