瀏覽代碼

fix: 修复附件路径以/app/路径匹配错误的bug

lanjianrong 4 年之前
父節點
當前提交
3d5e83ff35
共有 3 個文件被更改,包括 4 次插入4 次删除
  1. 1 1
      app/controller/stage_controller.js
  2. 1 1
      app/service/change_att.js
  3. 2 2
      app/service/stage_att.js

+ 1 - 1
app/controller/stage_controller.js

@@ -1407,7 +1407,7 @@ module.exports = app => {
                         if (!ctx.helper.canPreview(fileInfo.fileext)) {
                             filepath = `/tender/${ctx.tender.id}/measure/stage/${ctx.params.order}/download/file/${fileInfo.id}`;
                         } else {
-                            filepath = filepath.replace(/^app/, '');
+                            filepath = filepath.replace(/^app|\/app/, '');
                         }
                         fileInfo.filepath && (responseData.data = { filepath });
                     }

+ 1 - 1
app/service/change_att.js

@@ -65,7 +65,7 @@ module.exports = app => {
                 if (!ctx.helper.canPreview(item.fileext)) {
                     item.filepath = `/change/download/file/${item.id}`;
                 } else {
-                    item.filepath = item.filepath.replace(/^app/, '');
+                    item.filepath = item.filepath.replace(/^app|\/app/, '');
                 }
                 return item;
             });

+ 2 - 2
app/service/stage_att.js

@@ -73,7 +73,7 @@ module.exports = app => {
                 if (!ctx.helper.canPreview(item.fileext)) {
                     item.filepath = `/tender/${ctx.tender.id}/measure/stage/${ctx.params.order}/download/file/${item.id}`;
                 } else {
-                    item.filepath = '/' + item.filepath;
+                    item.filepath = item.filepath.replace(/^app|\/app/, '');
                 }
                 return item;
             });
@@ -94,7 +94,7 @@ module.exports = app => {
             const sqlParam = [this.tableName, this.ctx.service.projectAccount.tableName, this.ctx.service.ledger.tableName, id];
             const result = await this.db.queryOne(sql, sqlParam);
             if (!ctx.helper.canPreview(result.fileext)) result.filepath = `/tender/${ctx.tender.id}/measure/stage/${ctx.params.order}/download/file/${result.id}`;
-            else result.filepath = '/' + result.filepath;
+            else result.filepath = result.filepath.replace(/^app|\/app/, '');
             return result;
         }
     }