Added raw content proxy cdn url

This commit is contained in:
2023-02-06 01:03:05 +08:00
parent 145761f490
commit 0c8a839aa6

View File

@@ -2,7 +2,9 @@ const constValues = {
tooSmallScreenMinWidth: 600, tooSmallScreenMinWidth: 600,
defaultNotifyIconColor: '#555555', defaultNotifyIconColor: '#555555',
telegramContactLink: 'https://t.me/XiaofangInternet', telegramContactLink: 'https://t.me/XiaofangInternet',
repoSourceUrl: 'https://raw.githubusercontent.com/fankes/AndroidNotifyIconAdapt/main/' repoSourceDirectUrl: 'https://raw.githubusercontent.com/fankes/AndroidNotifyIconAdapt/main/',
/** Thanks for https://www.7ed.net/#/raw-cdn */
repoSourceProxyUrl: 'https://raw.githubusercontentS.com/fankes/AndroidNotifyIconAdapt/main/'
}; };
function onPageLoad() { function onPageLoad() {
@@ -214,6 +216,11 @@ const pageFunctions = {
} }
}; };
const repoSourceUrlController = {
isUseProxy: false,
getCurrentUrl: () => repoSourceUrlController.isUseProxy ? constValues.repoSourceProxyUrl : constValues.repoSourceDirectUrl
};
const nfDataRequestController = { const nfDataRequestController = {
requestData: (name) => { requestData: (name) => {
pageController.isPageBlocked = true; pageController.isPageBlocked = true;
@@ -221,7 +228,7 @@ const nfDataRequestController = {
$('#load-fail-text-box').hide(); $('#load-fail-text-box').hide();
$('#data-list').html(''); $('#data-list').html('');
$.ajax({ $.ajax({
url: constValues.repoSourceUrl + name + '/NotifyIconsSupportConfig.json', url: repoSourceUrlController.getCurrentUrl() + name + '/NotifyIconsSupportConfig.json',
method: 'GET', method: 'GET',
dataType: 'json', dataType: 'json',
success: (result) => { success: (result) => {
@@ -252,6 +259,11 @@ const nfDataRequestController = {
pageController.isPageBlocked = false; pageController.isPageBlocked = false;
}, },
error: () => { error: () => {
if (!repoSourceUrlController.isUseProxy) {
repoSourceUrlController.isUseProxy = true;
nfDataRequestController.requestData(name);
return;
}
$('#loading-icon').hide(); $('#loading-icon').hide();
$('#load-fail-text-box').show(); $('#load-fail-text-box').show();
} }