This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch gh-pages
in repository https://gitbox.apache.org/repos/asf/echarts-examples.git
The following commit(s) were added to refs/heads/gh-pages by this push:
new ef135eb3 use China CDN for Chinese website
ef135eb3 is described below
commit ef135eb3d8feff37541d4861f2731c04ec6693f2
Author: plainheart <[email protected]>
AuthorDate: Sat Dec 9 04:30:39 2023 +0800
use China CDN for Chinese website
---
public/zh/editor.html | 12 +++++------
public/zh/index.html | 12 +++++------
public/zh/view.html | 12 +++++------
src/common/config.js | 40 ++++++++++++++++++++++++++++++++---
src/common/helper.js | 4 +++-
src/editor/CodeAce.vue | 4 +++-
src/editor/CodeMonaco.vue | 6 +++++-
src/editor/Editor.vue | 3 ++-
src/editor/FullCodePreview.vue | 4 +++-
src/editor/Preview.vue | 4 +++-
src/editor/downloadExample.js | 6 ++++--
src/editor/sandbox/index.js | 7 ++++--
src/editor/sandbox/openwith/helper.js | 4 +++-
13 files changed, 86 insertions(+), 32 deletions(-)
diff --git a/public/zh/editor.html b/public/zh/editor.html
index 2e8ff2c8..194c4571 100644
--- a/public/zh/editor.html
+++ b/public/zh/editor.html
@@ -20,16 +20,16 @@
</style>
<link
rel="stylesheet"
-
href="//fastly.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
+
href="https://lib.baomitu.com/twitter-bootstrap/3.4.1/css/bootstrap.min.css"
/>
<link
rel="stylesheet"
-
href="https://fastly.jsdelivr.net/npm/[email protected]/lib/theme-chalk/index.css"
+
href="https://lib.baomitu.com/element-ui/2.15.14/theme-chalk/index.min.css"
/>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/lib/index.js"></script>
+ <script src="https://lib.baomitu.com/vue/2.6.14/vue.min.js"></script>
+ <script
src="https://cdn.staticfile.org/jquery/3.7.1/jquery.min.js"></script>
+ <script
src="https://lib.baomitu.com/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
+ <script
src="https://lib.baomitu.com/element-ui/2.15.14/index.min.js"></script>
</head>
<body>
<div id="main"></div>
diff --git a/public/zh/index.html b/public/zh/index.html
index cb34d927..b69b6938 100644
--- a/public/zh/index.html
+++ b/public/zh/index.html
@@ -20,16 +20,16 @@
</style>
<link
rel="stylesheet"
-
href="https://fastly.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
+
href="https://lib.baomitu.com/twitter-bootstrap/3.4.1/css/bootstrap.min.css"
/>
<link
rel="stylesheet"
-
href="https://fastly.jsdelivr.net/npm/[email protected]/lib/theme-chalk/index.css"
+
href="https://lib.baomitu.com/element-ui/2.15.14/theme-chalk/index.min.css"
/>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/lib/index.js"></script>
+ <script src="https://lib.baomitu.com/vue/2.6.14/vue.min.js"></script>
+ <script
src="https://cdn.staticfile.org/jquery/3.7.1/jquery.min.js"></script>
+ <script
src="https://lib.baomitu.com/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
+ <script
src="https://lib.baomitu.com/element-ui/2.15.14/index.min.js"></script>
</head>
<body>
<div id="main"></div>
diff --git a/public/zh/view.html b/public/zh/view.html
index c85347a2..7c1f4233 100644
--- a/public/zh/view.html
+++ b/public/zh/view.html
@@ -20,16 +20,16 @@
</style>
<link
rel="stylesheet"
-
href="https://fastly.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
+
href="https://lib.baomitu.com/twitter-bootstrap/3.4.1/css/bootstrap.min.css"
/>
<link
rel="stylesheet"
-
href="https://fastly.jsdelivr.net/npm/[email protected]/lib/theme-chalk/index.css"
+
href="https://lib.baomitu.com/element-ui/2.15.14/theme-chalk/index.min.css"
/>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/vue.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/jquery.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script>
- <script
src="https://fastly.jsdelivr.net/npm/[email protected]/lib/index.js"></script>
+ <script src="https://lib.baomitu.com/vue/2.6.14/vue.min.js"></script>
+ <script
src="https://cdn.staticfile.org/jquery/3.7.1/jquery.min.js"></script>
+ <script
src="https://lib.baomitu.com/twitter-bootstrap/3.4.1/js/bootstrap.min.js"></script>
+ <script
src="https://lib.baomitu.com/element-ui/2.15.14/index.min.js"></script>
</head>
<body>
<div id="main"></div>
diff --git a/src/common/config.js b/src/common/config.js
index 2bc86990..5abdc9b9 100644
--- a/src/common/config.js
+++ b/src/common/config.js
@@ -106,10 +106,18 @@ const URL_PARAMS = {};
export { URL_PARAMS };
-// https://npm.elemecdn.com/
-export const CDN_ROOT = 'https://fastly.jsdelivr.net/npm/';
+/**
+ * @param {'en' | 'zh'} locale
+ */
+export function getScriptURLs(locale) {
+ return locale === 'zh' ? SCRIPT_URLS_CN : SCRIPT_URLS;
+}
-export const SCRIPT_URLS = {
+const CDN_ROOT = 'https://fastly.jsdelivr.net/npm/';
+const CDN_ROOT_CN = 'https://lib.baomitu.com/';
+const CDN_ROOT_CN_NPM = 'https://registry.npmmirror.com/';
+
+const SCRIPT_URLS = {
echartsDir: `${CDN_ROOT}echarts@{{version}}`,
echartsNightlyDir: `${CDN_ROOT}echarts-nightly@{{version}}`,
echartsJS: '/dist/echarts.min.js',
@@ -135,3 +143,29 @@ export const SCRIPT_URLS = {
'https://api.map.baidu.com/api?v=3.0&ak=KOmVjPVUAey1G2E8zNhPiuQ6QiEmAwZu',
echartsBMapJS: '/dist/extension/bmap.min.js'
};
+
+const SCRIPT_URLS_CN = {
+ echartsDir: `${CDN_ROOT_CN_NPM}echarts/{{version}}/files`,
+ echartsNightlyDir: `${CDN_ROOT_CN_NPM}echarts-nightly/{{version}}/files`,
+ echartsJS: SCRIPT_URLS.echartsJS,
+
+ localEChartsDir: SCRIPT_URLS.localEChartsDir,
+ localEChartsGLDir: SCRIPT_URLS.localEChartsGLDir,
+
+ prPreviewEChartsDir: SCRIPT_URLS.prPreviewEChartsDir,
+
+ echartsWorldMapJS: `${CDN_ROOT_CN_NPM}echarts/4.9.0/files/map/js/world.js`,
+ echartsStatJS:
`${CDN_ROOT_CN_NPM}echarts-stat/latest/files/dist/ecStat.min.js`,
+ echartsGLJS: `${CDN_ROOT_CN_NPM}echarts-gl/2/files/dist/echarts-gl.min.js`,
+ datGUIMinJS: `${CDN_ROOT_CN}dat-gui/0.6.5/dat.gui.min.js`,
+ monacoDir: `https://cdn.staticfile.org/monaco-editor/0.27.0/min/vs`,
+ aceDir: `${CDN_ROOT_CN_NPM}ace-builds/1.4.12/files/src-min-noconflict`,
+ prettierDir: `${CDN_ROOT_CN}prettier/2.3.2`,
+ highlightjsDir: `${CDN_ROOT_CN_NPM}@highlightjs/cdn-assets/11.8.0/files`,
+ seedrandomJS: `${CDN_ROOT_CN}seedrandom/3.0.5/seedrandom.min.js`,
+ jQueryJS: `https://cdn.staticfile.org/jquery/3.7.1/jquery.min.js`,
+ acornJS: `https://cdn.staticfile.org/acorn/8.7.1/acorn.min.js`,
+
+ bmapLibJS: SCRIPT_URLS.bmapLibJS,
+ echartsBMapJS: SCRIPT_URLS.echartsBMapJS
+};
diff --git a/src/common/helper.js b/src/common/helper.js
index 4836af2e..ea7d3f01 100644
--- a/src/common/helper.js
+++ b/src/common/helper.js
@@ -1,5 +1,5 @@
import { store } from './store';
-import { SCRIPT_URLS } from './config';
+import { getScriptURLs } from './config';
import { compressToBase64, decompressFromBase64 } from 'lz-string';
const promisesCache = {};
@@ -67,6 +67,8 @@ function ensurePrettier() {
typeof prettier === 'undefined' ||
typeof prettierPlugins === 'undefined'
) {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
+
return loadScriptsAsync([
SCRIPT_URLS.prettierDir + '/standalone.js',
SCRIPT_URLS.prettierDir +
diff --git a/src/editor/CodeAce.vue b/src/editor/CodeAce.vue
index c818a5fa..3f4f630f 100644
--- a/src/editor/CodeAce.vue
+++ b/src/editor/CodeAce.vue
@@ -6,10 +6,12 @@
import { keywords } from '../data/option-keywords';
import { loadScriptsAsync } from '../common/helper';
import { store } from '../common/store';
-import { SCRIPT_URLS } from '../common/config';
+import { getScriptURLs } from '../common/config';
function ensureACE() {
if (typeof ace === 'undefined') {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
+
return loadScriptsAsync([
SCRIPT_URLS.aceDir + '/ace.js',
SCRIPT_URLS.aceDir + '/ext-language_tools.js'
diff --git a/src/editor/CodeMonaco.vue b/src/editor/CodeMonaco.vue
index 5545004d..9c345be6 100644
--- a/src/editor/CodeMonaco.vue
+++ b/src/editor/CodeMonaco.vue
@@ -5,9 +5,11 @@
<script>
import { loadScriptsAsync } from '../common/helper';
import { store } from '../common/store';
-import { SCRIPT_URLS, URL_PARAMS } from '../common/config';
+import { URL_PARAMS, getScriptURLs } from '../common/config';
function loadTypes() {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
+
return fetch(
('local' in URL_PARAMS
? SCRIPT_URLS.localEChartsDir
@@ -93,6 +95,8 @@ declare global {
function ensureMonacoAndTsTransformer() {
if (typeof monaco === 'undefined') {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
+
return loadScriptsAsync([
SCRIPT_URLS.monacoDir + '/loader.js',
// Prebuilt TS transformer with sucrase
diff --git a/src/editor/Editor.vue b/src/editor/Editor.vue
index e67ea3d5..2f6e775e 100644
--- a/src/editor/Editor.vue
+++ b/src/editor/Editor.vue
@@ -426,7 +426,7 @@ import { gotoURL } from '../common/route';
import { mount } from '@lang/object-visualizer';
import './object-visualizer.css';
-import { SCRIPT_URLS, URL_PARAMS } from '../common/config';
+import { getScriptURLs, URL_PARAMS } from '../common/config';
import { formatCode, loadScriptsAsync } from '../common/helper';
import openWithCodePen from './sandbox/openwith/codepen';
import openWithCodeSandbox from './sandbox/openwith/codesandbox';
@@ -772,6 +772,7 @@ export default {
},
dataType: 'text',
success: (diff) => {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
const highlightjsDir = SCRIPT_URLS.highlightjsDir;
loadScriptsAsync([
highlightjsDir + '/styles/github.min.css',
diff --git a/src/editor/FullCodePreview.vue b/src/editor/FullCodePreview.vue
index b279aec4..44d268d4 100644
--- a/src/editor/FullCodePreview.vue
+++ b/src/editor/FullCodePreview.vue
@@ -5,10 +5,12 @@
<script>
import { loadScriptsAsync } from '../common/helper';
import { store } from '../common/store';
-import { SCRIPT_URLS } from '../common/config';
+import { getScriptURLs } from '../common/config';
function ensureACE() {
if (typeof ace === 'undefined') {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
+
return loadScriptsAsync([SCRIPT_URLS.aceDir + '/ace.js']);
}
return Promise.resolve();
diff --git a/src/editor/Preview.vue b/src/editor/Preview.vue
index 7f009354..52f96b0f 100644
--- a/src/editor/Preview.vue
+++ b/src/editor/Preview.vue
@@ -154,7 +154,7 @@ import {
updateRunHash,
isValidPRVersion
} from '../common/store';
-import { SCRIPT_URLS, URL_PARAMS } from '../common/config';
+import { getScriptURLs, URL_PARAMS } from '../common/config';
import { compressStr } from '../common/helper';
import { createSandbox } from './sandbox';
import debounce from 'lodash/debounce';
@@ -173,6 +173,8 @@ function getScriptURL(link) {
}
function getScripts(nightly) {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
+
const echartsDirTpl =
SCRIPT_URLS[
isLocal
diff --git a/src/editor/downloadExample.js b/src/editor/downloadExample.js
index ae80e72d..8dd4d37b 100644
--- a/src/editor/downloadExample.js
+++ b/src/editor/downloadExample.js
@@ -1,11 +1,13 @@
import { store } from '../common/store';
-import { URL_PARAMS, SCRIPT_URLS } from '../common/config';
+import { URL_PARAMS, getScriptURLs } from '../common/config';
import { downloadBlob } from '../common/helper';
export function download(sourceHeader) {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
+
const hasRootPath = store.sourceCode.indexOf('ROOT_PATH') > -1;
const rootPathCode = hasRootPath ? `var ROOT_PATH = '${store.cdnRoot}';` :
'';
- const lang = store.locale && store.locale.indexOf('zh') > -1 ? 'zh-CN' :
'en';
+ const lang = store.locale === 'zh' > -1 ? 'zh-CN' : 'en';
const hasJQueryJS = /\$[\.\(]+/g.test(store.sourceCode);
const jqueryScriptCode = hasJQueryJS
diff --git a/src/editor/sandbox/index.js b/src/editor/sandbox/index.js
index 91ff2eaa..890036e5 100644
--- a/src/editor/sandbox/index.js
+++ b/src/editor/sandbox/index.js
@@ -5,7 +5,7 @@ import handleLoop from './handleLoop?raw-minify';
import showDebugDirtyRect from '../../dep/showDebugDirtyRect?raw-minify';
import setup from './setup?raw-minify';
import { store } from '../../common/store';
-import { SCRIPT_URLS } from '../../common/config';
+import { getScriptURLs } from '../../common/config';
function prepareSetupScript(isShared) {
const isProd = process.env.NODE_ENV === 'production';
@@ -32,6 +32,7 @@ export function createSandbox(
onOptionUpdated,
onCSSParsed
) {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
const commonLibs = [
SCRIPT_URLS.jQueryJS,
SCRIPT_URLS.seedrandomJS,
@@ -84,7 +85,9 @@ export function createSandbox(
'cdn.bootcdn.net',
'lib.baomitu.com',
'unpkg.zhimg.com',
- 'npm.elemecdn.com'
+ 'npm.elemecdn.com',
+ 'registry.npmmirror.com',
+ 'cdn.staticfile.org'
];
store.isPR && domains.push(`echarts-pr-${store.prNumber}.surge.sh`);
return domains;
diff --git a/src/editor/sandbox/openwith/helper.js
b/src/editor/sandbox/openwith/helper.js
index 5e4019f6..58a0b396 100644
--- a/src/editor/sandbox/openwith/helper.js
+++ b/src/editor/sandbox/openwith/helper.js
@@ -1,5 +1,5 @@
import { store } from '../../../common/store';
-import { SCRIPT_URLS } from '../../../common/config';
+import { getScriptURLs } from '../../../common/config';
/**
* Get templates
@@ -8,6 +8,8 @@ import { SCRIPT_URLS } from '../../../common/config';
* @param {string} css
*/
export function getTemplates(title, scripts, css) {
+ const SCRIPT_URLS = getScriptURLs(store.locale);
+
title = `${title ? title + ' - ' : ''}Apache ECharts Demo`;
scripts = (scripts && scripts.slice()) || [];
const lang = store.locale && store.locale.indexOf('zh') > -1 ? 'zh-CN' :
'en';
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]