From ce6a0e8dcc95cc2e943f198ecc7245815a4d1121 Mon Sep 17 00:00:00 2001 From: xiaoyu Date: Mon, 20 Jul 2020 16:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8B=B9=E6=9E=9C=E8=B6=85?= =?UTF-8?q?=E7=BA=A7=E7=AD=BE=E5=90=8D=EF=BC=8C=E4=B8=8B=E8=BD=BD=E6=8F=8F?= =?UTF-8?q?=E8=BF=B0=E6=96=87=E4=BB=B6=E4=B9=8B=E5=90=8E=EF=BC=8C=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E8=B7=B3=E8=BD=AC=E5=88=B0=E6=8F=8F=E8=BF=B0=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=AE=89=E8=A3=85=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/FirAppInfossecurity.vue | 6 ++-- fir_client/src/components/FirDownload.vue | 19 ++++++++++-- .../src/components/FirSuperSignBase.vue | 7 +++++ .../src/components/FirUserProfileInfo.vue | 2 +- fir_download/src/components/FirDownload.vue | 14 ++++++++- fir_ser/api/utils/storage/caches.py | 17 +++++----- fir_ser/api/utils/utils.py | 2 +- fir_ser/api/views/download.py | 31 +++++++++++++++---- 8 files changed, 77 insertions(+), 21 deletions(-) diff --git a/fir_client/src/components/FirAppInfossecurity.vue b/fir_client/src/components/FirAppInfossecurity.vue index 2089bf6..24e6034 100644 --- a/fir_client/src/components/FirAppInfossecurity.vue +++ b/fir_client/src/components/FirAppInfossecurity.vue @@ -121,7 +121,7 @@ wxeasytypeflag: false, wxredirectflag: false, clecount: 0, - wxeasy_disable:false + wxeasy_disable: false } }, methods: { @@ -188,8 +188,8 @@ this.wxeasytypetip.val = 'off'; } this.wxeasytypeflag = true; - if(!this.$store.state.userinfo.domain_name){ - this.wxeasy_disable=true; + if (!this.$store.state.userinfo.domain_name) { + this.wxeasy_disable = true; } }, setwxredirectshow(currentapp) { diff --git a/fir_client/src/components/FirDownload.vue b/fir_client/src/components/FirDownload.vue index 8b1585c..d0991aa 100644 --- a/fir_client/src/components/FirDownload.vue +++ b/fir_client/src/components/FirDownload.vue @@ -191,15 +191,21 @@ isdownload: false, udid: "", wxeasytypeflag: false, + timer: '', } - }, methods: { + }, + beforeDestroy() { + clearTimeout(this.timer); + }, + methods: { download() { if (this.currentappinfo.app_id) { this.isdownload = true; getdownloadurl(res => { if (res.code === 1000) { if (res.data.download_url === "") { - window.location.href = this.full_url; + window.location.href = this.full_url.split("?")[0]; + // window.location.href = this.full_url; return } if (this.currentappinfo.type === 1) { @@ -212,6 +218,15 @@ } else { if (this.agent !== '') { this.downloadurl = res.data.download_url; + window.location.href = this.downloadurl; + if (res.data.extra_url !== "") { + // eslint-disable-next-line no-unused-vars + this.timmer = setTimeout(data => { + window.location.href = res.data.extra_url; + }, 3000); + } + + return; } } } else { diff --git a/fir_client/src/components/FirSuperSignBase.vue b/fir_client/src/components/FirSuperSignBase.vue index a9b0a96..fea5013 100644 --- a/fir_client/src/components/FirSuperSignBase.vue +++ b/fir_client/src/components/FirSuperSignBase.vue @@ -567,10 +567,17 @@ }) }, iosdeveloperFun(params) { + const loading = this.$loading({ + lock: true, + text: '执行中,请耐心等待...', + spinner: 'el-icon-loading', + background: 'rgba(0, 0, 0, 0.7)' + }); iosdeveloper(data => { if (data.code === 1000) { this.app_developer_lists = data.data; this.pagination.total = data.count; + loading.close(); if (data.use_num) { this.developer_used_info = data.use_num; if (this.developer_used_info.all_usable_number !== 0) { diff --git a/fir_client/src/components/FirUserProfileInfo.vue b/fir_client/src/components/FirUserProfileInfo.vue index 1196f05..b79cf7d 100644 --- a/fir_client/src/components/FirUserProfileInfo.vue +++ b/fir_client/src/components/FirUserProfileInfo.vue @@ -130,7 +130,7 @@ this.$message.success("更新成功") } } else { - this.$message.error("更新失败 "+data.msg) + this.$message.error("更新失败 " + data.msg) } }, datainfo) diff --git a/fir_download/src/components/FirDownload.vue b/fir_download/src/components/FirDownload.vue index ef0524d..70deb9b 100644 --- a/fir_download/src/components/FirDownload.vue +++ b/fir_download/src/components/FirDownload.vue @@ -189,8 +189,11 @@ iserror: false, udid: "", wxeasytypeflag: false, + timer: '', } + }, beforeDestroy() { + clearTimeout(this.timer); }, methods: { download() { if (this.currentappinfo.app_id) { @@ -198,7 +201,7 @@ getdownloadurl(res => { if (res.code === 1000) { if (res.data.download_url === "") { - window.location.href = this.full_url; + window.location.href = this.full_url.split("?")[0]; return } if (this.currentappinfo.type === 1) { @@ -211,6 +214,15 @@ } else { if (this.agent !== '') { this.downloadurl = res.data.download_url; + window.location.href = this.downloadurl; + if (res.data.extra_url !== "") { + // eslint-disable-next-line no-unused-vars + this.timmer = setTimeout(data => { + window.location.href = res.data.extra_url; + }, 3000); + } + + return; } } } else { diff --git a/fir_ser/api/utils/storage/caches.py b/fir_ser/api/utils/storage/caches.py index d141c70..123d63b 100644 --- a/fir_ser/api/utils/storage/caches.py +++ b/fir_ser/api/utils/storage/caches.py @@ -39,24 +39,27 @@ def get_download_url_by_cache(app_obj, filename, limit, isdownload=True, key='', developerid=SuperSign_obj.developerid).first() if APPToDeveloper_obj: return local_storage.get_download_url( - APPToDeveloper_obj.binary_file + "." + download_url_type, limit) + APPToDeveloper_obj.binary_file + "." + download_url_type, limit), "" else: - return "" + return "", "" else: - return "" + return "", "" else: - return "" + return "", "" - return local_storage.get_download_url(filename.split(".")[0] + "." + download_url_type, limit) + mobileconifg = "" + if download_url_type == 'mobileconifg': + mobileconifg = local_storage.get_download_url(filename.split(".")[0] + "." + "mobileprovision", limit) + return local_storage.get_download_url(filename.split(".")[0] + "." + download_url_type, limit), mobileconifg down_key = "_".join([key.lower(), CACHE_KEY_TEMPLATE.get('download_url_key'), filename]) download_val = cache.get(down_key) if download_val: if download_val.get("time") > now - 60: - return download_val.get("download_url") + return download_val.get("download_url"), "" else: user_obj = UserInfo.objects.filter(pk=app_obj.get("user_id")).first() storage = Storage(user_obj) - return storage.get_download_url(filename, limit) + return storage.get_download_url(filename, limit), "" def get_app_instance_by_cache(app_id, password, limit, udid): diff --git a/fir_ser/api/utils/utils.py b/fir_ser/api/utils/utils.py index c8f07ab..ff9b154 100644 --- a/fir_ser/api/utils/utils.py +++ b/fir_ser/api/utils/utils.py @@ -50,7 +50,7 @@ def delete_app_profile_file(developer_obj, app_obj): file = get_profile_full_path(developer_obj, app_obj) try: if os.path.isfile(file): - os.remove(get_profile_full_path(developer_obj, app_obj)) + os.remove(file) except Exception as e: logger.error("delete_app_profile_file developer_obj:%s app_obj:%s file:%s Exception:%s" % ( developer_obj, app_obj, file, e)) diff --git a/fir_ser/api/views/download.py b/fir_ser/api/views/download.py index c845e6f..48e9aba 100644 --- a/fir_ser/api/views/download.py +++ b/fir_ser/api/views/download.py @@ -17,9 +17,10 @@ from api.utils.storage.caches import get_app_instance_by_cache, get_download_url import os from rest_framework_extensions.cache.decorators import cache_response from api.utils.serializer import AppsShortSerializer -from api.models import Apps, AppReleaseInfo, APPToDeveloper +from api.models import Apps, AppReleaseInfo, APPToDeveloper, APPSuperSignUsedInfo from django.http import FileResponse import logging +from api.utils.utils import get_profile_full_path logger = logging.getLogger(__file__) @@ -75,6 +76,22 @@ class DownloadView(APIView): response['Content-Disposition'] = 'attachment; filename=' + make_random_uuid() + '.mobileconfig' return response res.msg = "mobileconifg release_id error" + elif ftype == 'mobileprovision': + release_obj = AppReleaseInfo.objects.filter(release_id=filename.split('.')[0]).first() + if release_obj: + appsuper_obj = APPSuperSignUsedInfo.objects.filter(app_id=release_obj.app_id).last() + if not appsuper_obj: + appsuper_obj = APPSuperSignUsedInfo.objects.last() + developer_obj = appsuper_obj.developerid + file_path = get_profile_full_path(developer_obj, release_obj.app_id) + if os.path.isfile(file_path): + response = FileResponse(open(file_path, 'rb')) + else: + response = FileResponse() + response['Content-Type'] = "application/x-apple-aspen-config" + response['Content-Disposition'] = 'attachment; filename=' + make_random_uuid() + '.mobileprovision' + return response + res.msg = "mobileprovision release_id error" else: file_path = os.path.join(settings.MEDIA_ROOT, filename) try: @@ -164,16 +181,18 @@ class InstallView(APIView): if app_obj: if app_obj.get("type") == 0: apptype = '.apk' - download_url = get_download_url_by_cache(app_obj, release_id + apptype, 600) + download_url, extra_url = get_download_url_by_cache(app_obj, release_id + apptype, 600) else: apptype = '.ipa' if isdownload: - download_url = get_download_url_by_cache(app_obj, release_id + apptype, 600, udid=udid) + download_url, extra_url = get_download_url_by_cache(app_obj, release_id + apptype, 600, + udid=udid) else: - download_url = get_download_url_by_cache(app_obj, release_id + apptype, 600, isdownload, - udid=udid) + download_url, extra_url = get_download_url_by_cache(app_obj, release_id + apptype, 600, + isdownload, + udid=udid) - res.data = {"download_url": download_url} + res.data = {"download_url": download_url, "extra_url": extra_url} if download_url != "" and "mobileconifg" not in download_url: set_app_download_by_cache(app_id) if request.META.get('HTTP_X_FORWARDED_FOR', None):