From 62a399b547c3bd8c7081f7470ce66a6e17cf6d6f Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期四, 29 一月 2026 16:33:17 +0800
Subject: [PATCH] #
---
src/main/webapp/views/apkBuild/apkBuild.html | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/src/main/webapp/views/apkBuild/apkBuild.html b/src/main/webapp/views/apkBuild/apkBuild.html
index f1da2c1..d580fba 100644
--- a/src/main/webapp/views/apkBuild/apkBuild.html
+++ b/src/main/webapp/views/apkBuild/apkBuild.html
@@ -224,7 +224,7 @@
<el-table-column label="鎿嶄綔" width="180" align="center" fixed="right">
<template slot-scope="scope">
<el-button type="text" size="small" @click="showDetail(scope.row)">璇︽儏</el-button>
- <el-button type="text" size="small" v-if="scope.row.status === 2 && !scope.row.apkPath"
+ <el-button type="text" size="small" v-if="scope.row.status === 2 && scope.row.apkPath"
@click="downloadApk(scope.row)" :loading="scope.row.downloading">涓嬭浇</el-button>
<el-button type="text" size="small" style="color: #67c23a;"
v-if="scope.row.status === 2 && scope.row.apkPath"
@@ -658,21 +658,58 @@
downloadApk(row) {
this.$set(row, 'downloading', true);
$.ajax({
- url: baseUrl + '/apkBuildTask/download/' + row.id + '/auth',
+ url: baseUrl + '/apkBuildTask/downloadFile/' + row.id + '/auth',
headers: this.getHeaders(),
- method: 'POST',
- success: (res) => {
+ method: 'GET',
+ xhrFields: { responseType: 'blob' },
+ success: (data, status, xhr) => {
this.$set(row, 'downloading', false);
- if (res.code === 200) {
- this.$message.success('APK涓嬭浇瀹屾垚: ' + res.data.apkPath);
- this.loadData();
- } else {
- this.$message.error(res.msg || '涓嬭浇澶辫触');
+ const contentType = xhr.getResponseHeader('Content-Type') || '';
+ if (contentType.indexOf('application/json') !== -1) {
+ const reader = new FileReader();
+ reader.onload = () => {
+ try {
+ const res = JSON.parse(reader.result);
+ this.$message.error(res.msg || '涓嬭浇澶辫触');
+ } catch (e) {
+ this.$message.error('涓嬭浇澶辫触');
+ }
+ };
+ reader.readAsText(data);
+ return;
}
+ const disposition = xhr.getResponseHeader('Content-Disposition') || '';
+ const fileNameMatch = disposition.match(/filename="?([^"]+)"?/);
+ let fileName = fileNameMatch ? decodeURIComponent(fileNameMatch[1]) : '';
+ if (!fileName) {
+ fileName = (row.projectName ? row.projectName : row.id) + '.apk';
+ }
+ const blob = new Blob([data], { type: contentType || 'application/octet-stream' });
+ const link = document.createElement('a');
+ link.href = URL.createObjectURL(blob);
+ link.download = fileName;
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ URL.revokeObjectURL(link.href);
+ this.$message.success('APK宸插紑濮嬩笅杞�');
},
- error: () => {
+ error: (xhr) => {
this.$set(row, 'downloading', false);
- this.$message.error('璇锋眰澶辫触');
+ if (xhr && xhr.response) {
+ const reader = new FileReader();
+ reader.onload = () => {
+ try {
+ const res = JSON.parse(reader.result);
+ this.$message.error(res.msg || '涓嬭浇澶辫触');
+ } catch (e) {
+ this.$message.error('璇锋眰澶辫触');
+ }
+ };
+ reader.readAsText(xhr.response);
+ } else {
+ this.$message.error('璇锋眰澶辫触');
+ }
}
});
},
--
Gitblit v1.9.1