This is an automated email from the ASF dual-hosted git repository.

wangzx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/echarts-www.git

commit 6213cf021ec9ef85279d35463e4e40b99287b753
Author: plainheart <y...@all-my-life.cn>
AuthorDate: Sat Dec 9 02:18:58 2023 +0800

    use China CDN for Chinese website
---
 _jade/components/builder.jade             | 30 +++++++++++++++++++++---------
 _jade/layouts/basic.jade                  | 24 +++++++++++++-----------
 _jade/zh/cheat-sheet.jade                 |  2 +-
 _jade/zh/coding-standard.jade             |  4 ++--
 _jade/zh/download-map.jade                |  4 ++--
 _jade/zh/download-theme.jade              |  4 ++--
 _jade/zh/events.jade                      |  2 +-
 _jade/zh/events/2021-05-13-iscas.jade     |  2 +-
 _jade/zh/events/2021-07-05-apachecon.jade |  2 +-
 _jade/zh/feature.jade                     |  2 +-
 _jade/zh/index.jade                       |  2 +-
 builder/build.js                          | 17 +++++++++++++----
 builder/echarts.html                      |  3 ++-
 config/common.js                          | 25 +++++++++++++++++++++----
 js/index.js                               |  2 +-
 15 files changed, 83 insertions(+), 42 deletions(-)

diff --git a/_jade/components/builder.jade b/_jade/components/builder.jade
index 97a0b9a9..1a758b92 100644
--- a/_jade/components/builder.jade
+++ b/_jade/components/builder.jade
@@ -124,21 +124,33 @@ block content
             include ../en/footer
 
 block extra_js
-    
script(src="https://fastly.jsdelivr.net/npm/compare-versions@3.6.0/index.min.js";)
+    - var isCN = ecWWWLang == 'zh';
+    if isCN 
+        - var npmRegistryServer = 'https://registry.npmmirror.com';
+        - var npmVersionFetcher = 'Object.keys(json.versions).sort((v1, v2) => 
compareVersions(v2, v1, \'>\'))';
+        - var tagPropName       = 'dist-tags'; 
+        - var extraBuilderParam = '&cn=1';
+    else 
+        - var npmRegistryServer = 'https://data.jsdelivr.com/v1/package/npm';
+        - var npmVersionFetcher = 'json.versions';
+        - var tagPropName       = 'tags'; 
+
+    if isCN
+        
script(src="https://registry.npmmirror.com/compare-versions/3.6.0/files/index.js";)
+    else
+        
script(src="https://fastly.jsdelivr.net/npm/compare-versions@3.6.0/index.min.js";)
     script.
-        var $versionsDom = document.querySelector('#versions');
+        var $versionsDom = document.querySelector('#versions'); 
 
-        fetch('https://data.jsdelivr.com/v1/package/npm/echarts', {
-            mode: 'cors'
-        }).then(res => res.json()).then(json => {
-            const versions = json.versions.filter(version => 
compareVersions(version, '3.8.0') >= 0);
-            versions.forEach(version => {
+        fetch('#{npmRegistryServer}/echarts', { mode: 'cors' }).then(res => 
res.json()).then(json => {
+            var versions = !{npmVersionFetcher};
+            versions.filter(version => compareVersions(version, '3.8.0', '>') 
>= 0).forEach(version => {
                 const $optionDom = document.createElement('option');
                 $optionDom.value = version;
                 $optionDom.innerHTML = version;
                 $versionsDom.appendChild($optionDom);
             });
-            $versionsDom.value = json.tags.latest;
+            $versionsDom.value = json['#{tagPropName}'].latest;
         });
 
         function updateCheckbox() {
@@ -185,7 +197,7 @@ block extra_js
                 parameters += '&api=true';
             }
 
-            parameters += `&version=${$versionsDom.value || ''}`;
+            parameters += `&version=${$versionsDom.value || 
''}!{extraBuilderParam}`;
 
             //- var email = $('#email').val();
             var log = parameters;
diff --git a/_jade/layouts/basic.jade b/_jade/layouts/basic.jade
index 42def47c..756bbb3e 100644
--- a/_jade/layouts/basic.jade
+++ b/_jade/layouts/basic.jade
@@ -6,6 +6,13 @@ block variables
 
 block variablesLang
 
+- var isCN = ecWWWLang == 'zh';
+
+if isCN 
+    - var cdn3rdRoot = cdnThirdPartyCN;
+else
+    - var cdn3rdRoot = cdnThirdParty;
+
 doctype html
 html(lang='#{htmlAttrLang}')
     head
@@ -14,26 +21,21 @@ html(lang='#{htmlAttrLang}')
         meta(http-equiv='X-UA-Compatible', content='IE=edge,chrome=1')
         meta(name='viewport', 
content='width=device-width,initial-scale=1,user-scalable=no')
 
-        if ecWWWLang == 'zh'
+        if isCN
             meta(name="description" content="Apache 
ECharts,一款基于JavaScript的数据可视化图表库,提供直观,生动,可交互,可个性化定制的数据可视化图表。")
         else
             meta(name="description" content="Apache ECharts, a powerful, 
interactive charting and visualization library for browser")
         meta(name="keywords" 
content="echarts,apache,charts,data-visualization,charting-library,visualization,data-viz,canvas,svg,plot,graph")
 
         link(rel='shortcut icon', 
href='#{cdnPayRoot}/#{ecWWWLang}/images/favicon.png?_v_=#{cdnPayVersion}')
-        link(rel='stylesheet', type='text/css', 
href='#{cdnThirdParty.bootstrapCSS}')
-        // HTML5 shim and Respond.js for IE8 support of HTML5 elements and 
media queries
-        <!--[if lt IE 9]>
-        script(src='https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js')
-        script(src='https://oss.maxcdn.com/respond/1.4.2/respond.min.js')
-        <![endif]-->
+        link(rel='stylesheet', type='text/css', 
href='#{cdn3rdRoot.bootstrapCSS}')
 
         link(rel='stylesheet', type='text/css', href="#{getAssetUrl(host, 
ecWWWLang + '/css/main.css')}")
 
         script.
             window.EC_WWW_LANG = '#{ecWWWLang}';
 
-        script(type='text/javascript', 
src='#{cdnThirdParty.paceProgressBarJS}')
+        script(type='text/javascript', src='#{cdn3rdRoot.paceProgressBarJS}')
 
         script(id='font-hack', type='text/javascript').
             if (/windows/i.test(navigator.userAgent)) {
@@ -46,7 +48,7 @@ html(lang='#{htmlAttrLang}')
 
         block extra_head
 
-        script(type='text/javascript', src='#{cdnThirdParty.jquery}')
+        script(type='text/javascript', src='#{cdn3rdRoot.jquery}')
 
     <!--[if lte IE 8]>
     body.lower-ie
@@ -54,7 +56,7 @@ html(lang='#{htmlAttrLang}')
             
img(src="#{cdnPayRoot}/#{ecWWWLang}/images/forie.png?_v_=#{cdnPayVersion}", 
alt="ie tip")
     <![endif]-->
     <!--[if (gt IE 8)|!(IE)]>
-    body(class="#{pageTitle}")
+    body
     <![endif]-->
     noscript
         div.no-script
@@ -80,7 +82,7 @@ html(lang='#{htmlAttrLang}')
     #main
         block content
 
-    script(type='text/javascript', src='#{cdnThirdParty.bootstrapJS}')
+    script(type='text/javascript', src='#{cdn3rdRoot.bootstrapJS}')
     script(type='text/javascript', src="#{getAssetUrl(cdnPayRoot, ecWWWLang + 
'/js/common.js')}")
 
     block extra_js
diff --git a/_jade/zh/cheat-sheet.jade b/_jade/zh/cheat-sheet.jade
index 54936ed1..75bcdbc7 100644
--- a/_jade/zh/cheat-sheet.jade
+++ b/_jade/zh/cheat-sheet.jade
@@ -57,5 +57,5 @@ block extra_js
     script(type='text/javascript').
         document.getElementById('nav-resources').className = 'active';
 
-    script(src='#{cdnThirdParty.echartsMinJS_4_8_0}')
+    script(src='#{cdn3rdRoot.echartsMinJS_4_8_0}')
     script(type='text/javascript', src="#{getAssetUrl(cdnPayRoot, ecWWWLang + 
'/js/cheat-sheet.js')}")
\ No newline at end of file
diff --git a/_jade/zh/coding-standard.jade b/_jade/zh/coding-standard.jade
index a137fe99..77393981 100644
--- a/_jade/zh/coding-standard.jade
+++ b/_jade/zh/coding-standard.jade
@@ -4,8 +4,8 @@ block extra_head
     title 代码规范 - Apache ECharts
 
     link(rel='stylesheet', type='text/css', 
href='#{cdnPayRoot}/#{ecWWWLang}/vendors/prettify/prettify.css?_v_=#{cdnPayVersion}')
-    script(type='text/javascript', src='#{cdnThirdParty.prettifyJS}')
-    script(type='text/javascript', src='#{cdnThirdParty.prettifyCSSHandlerJS}')
+    script(type='text/javascript', src='#{cdn3rdRoot.prettifyJS}')
+    script(type='text/javascript', src='#{cdn3rdRoot.prettifyCSSHandlerJS}')
 
 
 block content
diff --git a/_jade/zh/download-map.jade b/_jade/zh/download-map.jade
index 2bc1f3af..5b8ef679 100644
--- a/_jade/zh/download-map.jade
+++ b/_jade/zh/download-map.jade
@@ -99,8 +99,8 @@ block content
         include ../components/footer
 
 block extra_js
-    script(src="#{cdnThirdParty.prettifyJS}")
-    script(src="#{cdnThirdParty.prettifyCSSHandlerJS}")
+    script(src="#{cdn3rdRoot.prettifyJS}")
+    script(src="#{cdn3rdRoot.prettifyCSSHandlerJS}")
     script.
         document.getElementById('nav-download').className = 'active';
         $('pre').addClass('prettyprint');
diff --git a/_jade/zh/download-theme.jade b/_jade/zh/download-theme.jade
index 5753e6ea..1319be0c 100644
--- a/_jade/zh/download-theme.jade
+++ b/_jade/zh/download-theme.jade
@@ -48,8 +48,8 @@ block content
         include ../components/footer
 
 block extra_js
-    script(src="#{cdnThirdParty.prettifyJS}")
-    script(src="#{cdnThirdParty.prettifyCSSHandlerJS}")
+    script(src="#{cdn3rdRoot.prettifyJS}")
+    script(src="#{cdn3rdRoot.prettifyCSSHandlerJS}")
     script.
         document.getElementById('nav-download').className = 'active';
         $('pre').addClass('prettyprint');
diff --git a/_jade/zh/events.jade b/_jade/zh/events.jade
index 91649a73..f40bf820 100644
--- a/_jade/zh/events.jade
+++ b/_jade/zh/events.jade
@@ -49,4 +49,4 @@ block extra_js
             elements_selector: ".lazy"
         };
         document.getElementById('nav-contribute').className = 'active';
-    
script(src='https://fastly.jsdelivr.net/npm/vanilla-lazyload@12.0.0/dist/lazyload.min.js')
+    
script(src='https://lib.baomitu.com/vanilla-lazyload/12.0.3/lazyload.min.js')
diff --git a/_jade/zh/events/2021-05-13-iscas.jade 
b/_jade/zh/events/2021-05-13-iscas.jade
index 87f34a8d..cc50592b 100644
--- a/_jade/zh/events/2021-05-13-iscas.jade
+++ b/_jade/zh/events/2021-05-13-iscas.jade
@@ -128,4 +128,4 @@ block extra_js
             elements_selector: ".lazy"
         };
         document.getElementById('nav-contribute').className = 'active';
-    
script(src='https://fastly.jsdelivr.net/npm/vanilla-lazyload@12.0.0/dist/lazyload.min.js')
+    
script(src='https://lib.baomitu.com/vanilla-lazyload/12.0.3/lazyload.min.js')
diff --git a/_jade/zh/events/2021-07-05-apachecon.jade 
b/_jade/zh/events/2021-07-05-apachecon.jade
index 04f0db1d..23dc0201 100644
--- a/_jade/zh/events/2021-07-05-apachecon.jade
+++ b/_jade/zh/events/2021-07-05-apachecon.jade
@@ -80,4 +80,4 @@ block extra_js
             elements_selector: ".lazy"
         };
         document.getElementById('nav-contribute').className = 'active';
-    
script(src='https://fastly.jsdelivr.net/npm/vanilla-lazyload@12.0.0/dist/lazyload.min.js')
+    
script(src='https://lib.baomitu.com/vanilla-lazyload/12.0.3/lazyload.min.js')
diff --git a/_jade/zh/feature.jade b/_jade/zh/feature.jade
index b918f00a..cbaca84e 100644
--- a/_jade/zh/feature.jade
+++ b/_jade/zh/feature.jade
@@ -94,6 +94,6 @@ block extra_js
         window.lazyLoadOptions = {
             elements_selector: 'iframe'
         };
-    
script(src='https://fastly.jsdelivr.net/npm/vanilla-lazyload@12.0.0/dist/lazyload.min.js')
+    
script(src='https://lib.baomitu.com/vanilla-lazyload/12.0.3/lazyload.min.js')
     script(type='text/javascript').
         document.getElementById('nav-doc').className = 'active';
diff --git a/_jade/zh/index.jade b/_jade/zh/index.jade
index 1b41fc4a..7b96d392 100644
--- a/_jade/zh/index.jade
+++ b/_jade/zh/index.jade
@@ -163,5 +163,5 @@ block extra_js
         window.lazyLoadOptions = {
             elements_selector: ".lazy"
         };
-    
script(src='https://lib.baomitu.com/vanilla-lazyload/12.0.0/lazyload.min.js')
+    
script(src='https://lib.baomitu.com/vanilla-lazyload/12.0.3/lazyload.min.js')
     script(src='#{cdnPayRoot}/#{ecWWWLang}/js/index.js?_v_=#{homeVersion}')
diff --git a/builder/build.js b/builder/build.js
index e2f15ad3..db275415 100644
--- a/builder/build.js
+++ b/builder/build.js
@@ -15,7 +15,10 @@ define(function (require) {
 
     var version = BUILD_CONFIG.version + '';
     var isVersion5 = version.startsWith('5');
-    var jsDelivrBase = 'https://fastly.jsdelivr.net/npm';
+    var isCN = BUILD_CONFIG.cn == 1;
+    var jsDelivrBase = isCN
+        ? 'https://registry.npmmirror.com'
+        : 'https://fastly.jsdelivr.net/npm';
 
     var urlArgs = '__v__=' + (+new Date());
 
@@ -65,7 +68,7 @@ define(function (require) {
     };
 
     function resolveNpmDependencies(pkg, version) {
-        return fetch(`${jsDelivrBase}/${pkg}@${version}/package.json`, { mode: 
'cors' })
+        return fetch(`${jsDelivrBase}/${pkg}${isCN ? '/' : 
'@'}${version}/${isCN ? 'files/' : ''}package.json`, { mode: 'cors' })
             .then(response => response.json())
             .then(pkgCfg => {
                 var entry = pkgCfg.module || pkgCfg.main || 'index.js';
@@ -122,10 +125,15 @@ define(function (require) {
                     }
 
                     // PENDING: fetch minified file to speed up downloading if 
no source required
-                    if (!BUILD_CONFIG.source) {
+                    if (!BUILD_CONFIG.source && !isCN) {
                         path = path.replace('.js', '.min.js');
                     }
 
+                    if (isCN) {
+                        // compatible with npmmirror.com
+                        path = path.replace(/([^\/]+)@([^/]+)/, '$1/$2/files');
+                    }
+
                     var retryCount = 0;
                     return new Promise(function (resolve, reject) {
                         var err;
@@ -140,7 +148,8 @@ define(function (require) {
                                 moduleLoadTimers.length = 0;
                                 return reject(err);
                             }
-                            fetchModuleContent(`${jsDelivrBase}/${path}`)
+                            console.log(path)
+                            fetchModuleContent(`${jsDelivrBase}${path}`)
                                 .then(function (content) {
                                     builderLog('Loaded module: "' + path + 
'"');
                                     err = null;
diff --git a/builder/echarts.html b/builder/echarts.html
index 6e8c2f14..2ba53c96 100644
--- a/builder/echarts.html
+++ b/builder/echarts.html
@@ -7,7 +7,8 @@
     <meta name="viewport" 
content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     <meta http-equiv="x-dns-prefetch-control" content="on">
-    <link rel="dns-prefetch" href="https://fastly.jsdelivr.net/npm";>
+    <link rel="dns-prefetch" href="https://registry.npmmirror.com";>
+    <link rel="dns-prefetch" href="https://fastly.jsdelivr.net";>
     <link rel="shortcut icon" 
href="https://echarts.apache.org/en/images/favicon.png";>
     <script src="lib/esl.js"></script>
     <script src="lib/uglifyjs.js"></script>
diff --git a/config/common.js b/config/common.js
index 5c1b1a93..1583f352 100644
--- a/config/common.js
+++ b/config/common.js
@@ -5,16 +5,13 @@ module.exports = {
         bootstrapCSS: 
'https://fastly.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css',
         bootstrapJS: 
'https://fastly.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js',
         lodash: 'https://fastly.jsdelivr.net/npm/lodash@3.10.1/index.min.js',
-        perfectScrollbarJS: 
'https://fastly.jsdelivr.net/npm/perfect-scrollbar@0.6.8/dist/js/min/perfect-scrollbar.min.js',
-        perfectScrollbarCSS: 
'https://fastly.jsdelivr.net/npm/perfect-scrollbar@0.6.8/dist/css/perfect-scrollbar.min.css',
-        paceProgressBarJS: 
'https://fastly.jsdelivr.net/npm/pace-progressbar@1.0.2/pace.min.js',
+        paceProgressBarJS: 
'https://fastly.jsdelivr.net/npm/pace-js@1.2.4/pace.min.js',
         sweetalertJS: 
'https://fastly.jsdelivr.net/npm/sweetalert@2.1.2/dist/sweetalert.min.js',
         echartsMinJS_4_8_0: 
'https://fastly.jsdelivr.net/npm/echarts@4.8.0/dist/echarts.min.js',
         prettifyJS: 
'https://fastly.jsdelivr.net/npm/code-prettify@0.1.0/src/prettify.min.js',
         // Can not find good prettify css in jsdelivr.
         // prettifyCSS: 
'https://fastly.jsdelivr.net/npm/code-prettify@0.1.0/styles/doxy.css',
         prettifyCSSHandlerJS: 
'https://fastly.jsdelivr.net/npm/code-prettify@0.1.0/src/lang-css.js',
-        jqueryLazyloadJS: 
'https://fastly.jsdelivr.net/npm/jquery-lazyload@1.9.7/jquery.lazyload.min.js',
 
         // CDN for doc
         vueJS: 'https://fastly.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js',
@@ -25,6 +22,26 @@ module.exports = {
         beautifierJS: 
'https://fastly.jsdelivr.net/npm/js-beautify@1.11.0/js/lib/beautifier.min.js',
     },
 
+    cdnThirdPartyCN: {
+        jquery: 'https://cdn.staticfile.org/jquery/3.7.1/jquery.min.js',
+        bootstrapCSS: 
'https://lib.baomitu.com/twitter-bootstrap/3.3.7/css/bootstrap.min.css',
+        bootstrapJS: 
'https://lib.baomitu.com/twitter-bootstrap/3.3.7/js/bootstrap.min.js',
+        lodash: 'https://lib.baomitu.com/lodash.js/3.10.1/lodash.min.js',
+        paceProgressBarJS: 'https://lib.baomitu.com/pace/1.2.4/pace.min.js',
+        sweetalertJS: 
'https://lib.baomitu.com/sweetalert/2.1.2/sweetalert.min.js',
+        echartsMinJS_4_8_0: 
'https://lib.baomitu.com/echarts/4.8.0/echarts.min.js',
+        prettifyJS: 
'https://registry.npmmirror.com/code-prettify/0.1.0/files/src/prettify.js',
+        prettifyCSSHandlerJS: 
'https://registry.npmmirror.com/code-prettify/0.1.0/files/src/lang-css.js',
+
+        // CDN for doc
+        vueJS: 'https://lib.baomitu.com/vue/2.6.14/vue.min.js',
+        elementUIJS: 'https://lib.baomitu.com/element-ui/2.15.14/index.min.js',
+        elementUICSS: 
'https://lib.baomitu.com/element-ui/2.15.14/theme-chalk/index.min.css',
+        codeMirrorJS: 
'https://lib.baomitu.com/codemirror/5.56.0/codemirror.min.js',
+        codeMirrorJSModeJS: 
'https://lib.baomitu.com/codemirror/5.56.0/mode/javascript/javascript.min.js',
+        beautifierJS: 
'https://lib.baomitu.com/js-beautify/1.11.0/beautifier.min.js',
+    },
+
     // Source folder of echarts
     echartsPath: '../echarts',
     // Target folder of echarts
diff --git a/js/index.js b/js/index.js
index c2785f87..f46a9a09 100644
--- a/js/index.js
+++ b/js/index.js
@@ -125,7 +125,7 @@ window.lazyLoadOptions = {
             var landingAnimationURL = 
                 window.EC_WWW_LANG === 'zh'
                     ? 
'https://registry.npmmirror.com/echarts-www-landing-animation/latest/files/'
-                    : 
'https://cdn.jsdelivr.net/npm/echarts-www-landing-animation/';
+                    : 
'https://fastly.jsdelivr.net/npm/echarts-www-landing-animation/';
             // Load script.
             var link = document.createElement('link');
             var script = document.createElement('script');


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@echarts.apache.org
For additional commands, e-mail: commits-h...@echarts.apache.org

Reply via email to