优化下载页跳转

publicsignpoll
youngS 3 years ago
parent 7309eaf9b5
commit 9b7590146a
  1. 18
      fir_client/src/components/FirDownload.vue
  2. 18
      fir_client/src/components/ShortDownload.vue
  3. 10
      fir_ser/api/utils/baseutils.py
  4. 10
      fir_ser/api/views/download.py

@ -487,19 +487,6 @@
}) })
} }
}, },
auto_redirect_url(domain_name) {
if (domain_name) {
let nurl = location.href.split("//")[1].split("/");
const user_hostname = domain_name.split("//");
if (nurl[0] === user_hostname[1]) {
return true;
} else {
nurl[0] = user_hostname[1];
window.location.href = user_hostname[0] + "//" + nurl.join("/");
return false;
}
}
},
getDownloadTokenFun() { getDownloadTokenFun() {
let params = { let params = {
"short": this.$route.params.short, "short": this.$route.params.short,
@ -515,9 +502,6 @@
} }
getShortAppinfo(data => { getShortAppinfo(data => {
if (data.code === 1000) { if (data.code === 1000) {
if (!this.auto_redirect_url(data.domain_name)) {
return;
}
if (data.ad && data.ad.ad_uri) { if (data.ad && data.ad.ad_uri) {
this.ad_info = data.ad; this.ad_info = data.ad;
} }
@ -628,6 +612,8 @@
} }
} else if (data.code === 1002) { } else if (data.code === 1002) {
window.location.href = location.href.replace(location.search, ''); window.location.href = location.href.replace(location.search, '');
}else if (data.code === 302 && data.data) {
window.location.href = data.data;
} else { } else {
if (data.msg) { if (data.msg) {
document.title = data.msg; document.title = data.msg;

@ -476,19 +476,6 @@
}) })
} }
}, },
auto_redirect_url(domain_name) {
if (domain_name) {
let nurl = location.href.split("//")[1].split("/");
const user_hostname = domain_name.split("//");
if (nurl[0] === user_hostname[1]) {
return true;
} else {
nurl[0] = user_hostname[1];
window.location.href = user_hostname[0] + "//" + nurl.join("/");
return false;
}
}
},
getDownloadTokenFun() { getDownloadTokenFun() {
let params = { let params = {
"short": this.$route.params.short, "short": this.$route.params.short,
@ -504,9 +491,6 @@
} }
getShortAppinfo(data => { getShortAppinfo(data => {
if (data.code === 1000) { if (data.code === 1000) {
if (!this.auto_redirect_url(data.domain_name)) {
return;
}
if (data.ad && data.ad.ad_uri) { if (data.ad && data.ad.ad_uri) {
this.ad_info = data.ad; this.ad_info = data.ad;
} }
@ -613,6 +597,8 @@
} }
} else if (data.code === 1002) { } else if (data.code === 1002) {
window.location.href = location.href.replace(location.search, ''); window.location.href = location.href.replace(location.search, '');
}else if (data.code === 302 && data.data) {
window.location.href = data.data;
} else { } else {
this.iserror = true; this.iserror = true;
this.wrong = true; this.wrong = true;

@ -276,3 +276,13 @@ def ad_random_weight(user_obj):
ret = ad_info ret = ad_info
break break
return ret return ret
def format_get_uri(domain, short, data):
uri = ''
for k, v in data.items():
if v:
uri += f'&{k}={v}'
if uri:
uri = '?' + uri[1:]
return f'{domain}/{short}{uri}'

@ -23,7 +23,7 @@ from api.models import Apps, AppReleaseInfo, APPToDeveloper, APPSuperSignUsedInf
from django.http import FileResponse from django.http import FileResponse
import logging import logging
from api.utils.baseutils import get_profile_full_path, get_app_domain_name, get_filename_form_file, \ from api.utils.baseutils import get_profile_full_path, get_app_domain_name, get_filename_form_file, \
check_app_domain_name_access, get_real_ip_address, get_origin_domain_name, ad_random_weight check_app_domain_name_access, get_real_ip_address, get_origin_domain_name, ad_random_weight, format_get_uri
from api.utils.throttle import VisitShortThrottle, InstallShortThrottle, InstallThrottle1, InstallThrottle2 from api.utils.throttle import VisitShortThrottle, InstallShortThrottle, InstallThrottle1, InstallThrottle2
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@ -153,10 +153,16 @@ class ShortDownloadView(APIView):
if res.code != 1000: if res.code != 1000:
return Response(res.dict) return Response(res.dict)
domain_name = get_redirect_server_domain(request, user_obj, get_app_domain_name(app_obj)) domain_name = get_redirect_server_domain(request, user_obj, get_app_domain_name(app_obj))
origin_domain_name = get_origin_domain_name(request)
if domain_name.split('//')[-1].split('/')[0] != origin_domain_name:
res.code = 302
res.data = format_get_uri(domain_name, short, {'release_id': release_id, 'udid': udid})
return Response(res.dict)
if user_obj and user_obj.role and user_obj.role == 3: if user_obj and user_obj.role and user_obj.role == 3:
... ...
else: else:
if not check_app_domain_name_access(app_obj, get_origin_domain_name(request), user_obj, if not check_app_domain_name_access(app_obj, origin_domain_name, user_obj,
domain_name.split('//')[-1]): domain_name.split('//')[-1]):
res.code = 1004 res.code = 1004
res.msg = "访问域名不合法" res.msg = "访问域名不合法"

Loading…
Cancel
Save