wjx 11 uur geleden
bovenliggende
commit
28c818a1e2
1 gewijzigde bestanden met toevoegingen van 29 en 0 verwijderingen
  1. 29 0
      src/views/accounts/corpWechat/index.vue

+ 29 - 0
src/views/accounts/corpWechat/index.vue

@@ -77,6 +77,15 @@
                     <el-tag type="danger" v-else>配置失败</el-tag>
                 </template>
             </el-table-column>
+            <el-table-column label="域名备案截图" prop="configStatus" align="center" width="120">
+                <template slot-scope="scope">
+                    <div v-if="!!scope.row.domainBeianImgUrl" style="display: flex; flex-direction: row; align-items: flex-end; justify-content: center; gap: 5px;">
+                        <el-image :src="scope.row.domainBeianImgUrl" fit="fill" :preview-src-list="[scope.row.domainBeianImgUrl]" style="width: 70px; height: 70px; cursor: pointer;" />
+                        <el-link type="primary" :underline="false" style="font-size: 12px;" @click="downloadImg(scope.row.domainBeianImgUrl, scope.row.corpName)">下载</el-link>
+                    </div>
+                    <span v-else>--</span>
+                </template>
+            </el-table-column>
             <el-table-column label="授权信息" prop="externalUserCallbackUrl" width="300" :show-overflow-tooltip="true">
                 <template slot-scope="scope">
                     <div class="table-row">回调地址:<a style="color: #1890ff;" v-if="scope.row.agentCallbackUrl" @click="copy(scope.row.externalUserCallbackUrl)">{{scope.row.agentCallbackUrl}}</a><span v-else>--</span></div>
@@ -350,6 +359,26 @@ export default {
             this.corpId = null;
             this.sessionVisible = false;
             this.getList()
+        },
+        downloadImg(url, name) {
+            // 获取扩展名
+            let ext = 'png';
+            if (url) {
+                const match = url.match(/\.([^.?#]+)(?:[?#]|$)/);
+                if (match && match[1]) {
+                    ext = match[1].toLowerCase();
+                }
+            }
+
+            // 针对阿里云 OSS 等跨域图片,直接用纯原生 window.open 或者是 a 标签在新窗口打开。
+            // 因为 OSS 匿名用户不支持重写 response header,同时 fetch 会报跨域错误,所以直接让浏览器接管(通常会直接打开图片预览)。
+            const a = document.createElement('a');
+            a.href = url;
+            a.download = `${name || '域名备案截图'}.${ext}`; // 尝试设置下载属性(跨域时浏览器可能忽略并直接打开)
+            a.target = '_blank';
+            document.body.appendChild(a);
+            a.click();
+            a.remove();
         }
     }
 }