From 8a8d2f2400a5d0b455ffe694bb8475f248a1f91b Mon Sep 17 00:00:00 2001 From: isummer Date: Thu, 14 Jul 2022 18:17:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=A2=84=E8=A7=88=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E9=A1=B5=E8=B7=AF=E7=94=B1=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/apps/FirAppInfosBase.vue | 15 +++++---------- .../src/components/apps/FirAppInfossecurity.vue | 2 +- .../src/components/apps/FirAppInfostimeline.vue | 7 +------ fir_client/src/components/apps/FirApps.vue | 2 +- .../src/components/user/FirSuperSignBase.vue | 1 - .../src/components/user/FirUserQrcode.vue | 11 ++++------- fir_ser/api/tasks.py | 11 ++++++----- fir_ser/api/utils/modelutils.py | 4 ++++ fir_ser/api/utils/serializer.py | 17 +++-------------- fir_ser/api/views/download.py | 7 ++++--- fir_ser/common/core/sysconfig.py | 4 ++++ fir_ser/config.py | 1 + 12 files changed, 34 insertions(+), 48 deletions(-) diff --git a/fir_client/src/components/apps/FirAppInfosBase.vue b/fir_client/src/components/apps/FirAppInfosBase.vue index 3e9b5c2..61c868f 100644 --- a/fir_client/src/components/apps/FirAppInfosBase.vue +++ b/fir_client/src/components/apps/FirAppInfosBase.vue @@ -8,10 +8,10 @@
-  {{ short_full_url }} + > {{ appinfos.preview_url }} + :text="appinfos.preview_url"> 保存本地
@@ -123,13 +123,12 @@ export default { margin: 20 }, icon_url: "", - appinfos: {status: 1}, + appinfos: {status: 1, preview_url: ''}, master_release: {}, allapp: [], activity: { editing: false }, - short_full_url: '', } }, methods: { @@ -149,9 +148,6 @@ export default { //合成函数,执行下载 a.dispatchEvent(new MouseEvent('click')) }, - short_url(appinfo) { - return appinfo.preview_url + '/' + appinfo.short; - }, setfunactive(item, index) { for (let key in this.$refs) { if (key === "qr") continue; @@ -168,7 +164,7 @@ export default { } }, appDownload(appinfo) { - window.open(this.short_url(appinfo), '_blank', ''); + window.open(appinfo.preview_url, '_blank', ''); }, defaulttimeline() { this.setfunactive('timeline', 5); @@ -219,7 +215,6 @@ export default { this.master_release = data.data.master_release; this.appinfos["icon_url"] = this.master_release.icon_url; this.$store.dispatch('doucurrentapp', this.appinfos); - this.short_full_url = this.appinfos.preview_url + "/" + this.appinfos.short; } else if (data.code === 1003) { this.$router.push({name: 'FirApps'}); } else { diff --git a/fir_client/src/components/apps/FirAppInfossecurity.vue b/fir_client/src/components/apps/FirAppInfossecurity.vue index f82926e..26e3f42 100644 --- a/fir_client/src/components/apps/FirAppInfossecurity.vue +++ b/fir_client/src/components/apps/FirAppInfossecurity.vue @@ -324,7 +324,7 @@ export default { }, methods: { format_copy_text(token) { - return this.currentapp.preview_url + "/" + this.currentapp.short + "?password=" + token + return this.currentapp.preview_url + "?password=" + token }, copy_success() { this.$message.success('复制剪切板成功'); diff --git a/fir_client/src/components/apps/FirAppInfostimeline.vue b/fir_client/src/components/apps/FirAppInfostimeline.vue index 2157cfe..be09460 100644 --- a/fir_client/src/components/apps/FirAppInfostimeline.vue +++ b/fir_client/src/components/apps/FirAppInfostimeline.vue @@ -142,12 +142,7 @@ export default { ); }, previewRelease(app) { - let routeData = this.$router.resolve({ - name: 'FirDownload', - params: {short: this.currentapp.short}, - query: {release_id: app.release_id} - }); - window.open(this.currentapp.preview_url + routeData.href, 'target', ''); + window.open(this.currentapp.preview_url + '?release_id=' + app.release_id, '_blank', ''); }, getAppTimelineFun(act = '') { const loading = this.$loading({ diff --git a/fir_client/src/components/apps/FirApps.vue b/fir_client/src/components/apps/FirApps.vue index 59bb21c..826d99b 100644 --- a/fir_client/src/components/apps/FirApps.vue +++ b/fir_client/src/components/apps/FirApps.vue @@ -1161,7 +1161,7 @@ export default { this.$router.push({name: 'FirAppInfostimeline', params: {id: app.app_id}}) }, appDownload(app) { - window.open(app.preview_url + '/' + app.short, '_blank', ''); + window.open(app.preview_url, '_blank', ''); } }, computed: { getDelappTitle() { diff --git a/fir_client/src/components/user/FirSuperSignBase.vue b/fir_client/src/components/user/FirSuperSignBase.vue index 9815d9b..d158f5b 100644 --- a/fir_client/src/components/user/FirSuperSignBase.vue +++ b/fir_client/src/components/user/FirSuperSignBase.vue @@ -1430,7 +1430,6 @@ + :text="appinfo.preview_url">
@@ -65,9 +65,9 @@ {{ appinfo.name }}
- {{ short_url(appinfo) }} + >{{ appinfo.preview_url }}
预览 保存本地 @@ -213,15 +213,12 @@ export default { this.isIndeterminate = checkedCount > 0 && checkedCount < this.allQrcodeAppid.length; }, go_download(appinfo) { - window.open(this.short_url(appinfo), '_blank', ''); + window.open(appinfo.preview_url, '_blank', ''); }, qrback(dataUrl, id) { this.qrcode_img_info[id] = dataUrl; this.allQrcodeAppid.push(id); }, - short_url(appinfo) { - return appinfo.preview_url + '/' + appinfo.short; - }, save_qr(appinfo) { let dtype = "I"; if (appinfo.master_release.release_type === 0) { diff --git a/fir_ser/api/tasks.py b/fir_ser/api/tasks.py index dc7affa..606e12b 100644 --- a/fir_ser/api/tasks.py +++ b/fir_ser/api/tasks.py @@ -22,17 +22,18 @@ from xsign.utils.ctasks import auto_delete_ios_mobile_tmp_file logger = logging.getLogger(__name__) +def clean_config_cache(key): + ConfigCacheBase().invalid_config_cache(key) + ConfigCacheBase(px='user').invalid_config_cache(key) + + @app.task def start_api_sever_do_clean(): # 启动服务的时候,同时执行下面操作,主要是修改配置存储的时候,需要执行清理,否则会出问题,如果不修改,则无需执行 logger.info("clean local storage cache") get_local_storage(clean_cache=True) check_bypass_status() - ConfigCacheBase().invalid_config_cache() - - -def clean_config_cache(key): - return ConfigCacheBase().invalid_config_cache(key) + clean_config_cache('*') @app.task diff --git a/fir_ser/api/utils/modelutils.py b/fir_ser/api/utils/modelutils.py index 5974320..ba13a1c 100644 --- a/fir_ser/api/utils/modelutils.py +++ b/fir_ser/api/utils/modelutils.py @@ -319,3 +319,7 @@ def get_user_storage_obj(user_obj, default=False): auth = storage.get('auth', {}) storage = AppStorage(user_id=user_obj, storage_type=storage_type, **auth) return storage + + +def get_preview_short_config(user_obj, short): + return f"{'#/' if UserConfig(user_obj).PREVIEW_ROUTE_HASH else ''}{short}" diff --git a/fir_ser/api/utils/serializer.py b/fir_ser/api/utils/serializer.py index 4fbd317..04ae1df 100644 --- a/fir_ser/api/utils/serializer.py +++ b/fir_ser/api/utils/serializer.py @@ -7,7 +7,8 @@ from rest_framework.exceptions import ValidationError from api import models from api.utils.apputils import bytes2human -from api.utils.modelutils import get_user_domain_name, get_app_domain_name, get_app_download_uri, get_user_storage_used +from api.utils.modelutils import get_user_domain_name, get_app_domain_name, get_app_download_uri, get_user_storage_used, \ + get_preview_short_config from common.base.baseutils import get_choices_dict, WeixinLoginUid from common.cache.storage import AdPicShowCache from common.core.sysconfig import Config, UserConfig @@ -153,19 +154,7 @@ class AppsSerializer(serializers.ModelSerializer): preview_url = serializers.SerializerMethodField() def get_preview_url(self, obj): - return get_app_download_uri(None, obj.user_id, obj) - - # private_developer_number = serializers.IntegerField(default=0) - # count = serializers.IntegerField(default=0) - # - # def get_private_developer_number(self, obj): - # return models.AppleDeveloperToAppUse.objects.filter(app_id=obj).count() - # - # private_developer_used_number = serializers.IntegerField(default=0) - # - # def get_private_developer_used_number(self, obj): - # return models.DeveloperDevicesID.objects.filter(app_id=obj, - # developerid__appledevelopertoappuse__app_id=obj).distinct().count() + return f"{get_app_download_uri(None, obj.user_id, obj)}/{get_preview_short_config(obj.user_id, obj.short)}" domain_name = serializers.SerializerMethodField() diff --git a/fir_ser/api/views/download.py b/fir_ser/api/views/download.py index fc3e3c5..10b2179 100644 --- a/fir_ser/api/views/download.py +++ b/fir_ser/api/views/download.py @@ -13,12 +13,12 @@ from rest_framework.views import APIView from api.models import Apps, AppReleaseInfo from api.utils.modelutils import get_filename_form_file, check_app_domain_name_access, \ - ad_random_weight, get_app_download_uri + ad_random_weight, get_app_download_uri, get_preview_short_config from api.utils.response import BaseResponse from api.utils.serializer import AppsShortSerializer, AppAdInfoSerializer from api.utils.signalutils import run_get_xsign_binary_file from common.base.baseutils import get_origin_domain_name, format_get_uri, make_random_uuid, make_resigned -from common.core.decorators import cache_response # 本来使用的是 drf-extensions==0.7.0 但是还未支持该版本Django +from common.core.decorators import cache_response from common.core.response import mobileprovision_file_response, file_response, ApiResponse from common.core.sysconfig import Config from common.core.throttle import VisitShortThrottle, InstallShortThrottle, InstallThrottle1, InstallThrottle2 @@ -124,7 +124,8 @@ class ShortDownloadView(APIView): res.code = 1000 res.domain_name = domain_name res.redirect = True - res.data = format_get_uri(domain_name, short, {'release_id': release_id, 'udid': udid}) + res.data = format_get_uri(domain_name, get_preview_short_config(user_obj, short), + {'release_id': release_id, 'udid': udid}) return Response(res.dict) if udid: if not app_obj.issupersign: diff --git a/fir_ser/common/core/sysconfig.py b/fir_ser/common/core/sysconfig.py index cef6181..242e1fd 100644 --- a/fir_ser/common/core/sysconfig.py +++ b/fir_ser/common/core/sysconfig.py @@ -445,6 +445,10 @@ class UserPersonalConfKeyCache(ConfigCacheBase): def DEVELOPER_STATUS_CONFIG(self): return super().get_value('DEVELOPER_STATUS_CONFIG', USERPERSONALCONFIGKEY.DEVELOPER_STATUS_CONFIG) + @property + def PREVIEW_ROUTE_HASH(self): + return super().get_value('PREVIEW_ROUTE_HASH', USERPERSONALCONFIGKEY.PREVIEW_ROUTE_HASH) + class ConfigDescriptionCache(ConfigCacheBase): def __init__(self, *args, **kwargs): diff --git a/fir_ser/config.py b/fir_ser/config.py index df58643..eb60f8e 100644 --- a/fir_ser/config.py +++ b/fir_ser/config.py @@ -468,6 +468,7 @@ class CONFIGDESCRIPTION(object): class USERPERSONALCONFIGKEY(object): DEVELOPER_STATUS_CONFIG = ['DEVELOPER_WAIT_ABNORMAL_STATE', 'DEVELOPER_WAIT_ABNORMAL_DEVICE', 'DEVELOPER_ABNORMAL_DEVICE_WRITE'] + PREVIEW_ROUTE_HASH = False # 预览路由模式是否是hash, 如果使用hash模式,url中就会存在“#“符号,这个符号后面的是路径。 class OSSSTORAGECONF(object):