From 6898c9edb80f10f4733fc74d76ce2aaaea62fc8c Mon Sep 17 00:00:00 2001 From: Aisen60 Date: Tue, 9 Mar 2021 00:10:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=9B=A0=20js-beautif?= =?UTF-8?q?y=20cdn=20=E9=93=BE=E6=8E=A5=EF=BC=88https://lib.baomitu.com/js?= =?UTF-8?q?-beautify/1.10.2/beautifier.min.js=EF=BC=89=E5=B7=B2=E4=B8=A2?= =?UTF-8?q?=E5=A4=B1=EF=BC=8C=E5=AF=BC=E8=87=B4=E9=A1=B9=E7=9B=AE=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98=E3=80=82=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=20/src/utils/pluginsConfig.js=20=E6=96=87=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E7=BB=9F=E4=B8=80=E7=AE=A1=E7=90=86=20cdn=20=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/loadBeautifier.js | 4 +++- src/utils/loadMonaco.js | 3 ++- src/utils/loadTinymce.js | 5 ++++- src/utils/pluginsConfig.js | 11 +++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/utils/pluginsConfig.js diff --git a/src/utils/loadBeautifier.js b/src/utils/loadBeautifier.js index a3bef88f..cec9ccd2 100644 --- a/src/utils/loadBeautifier.js +++ b/src/utils/loadBeautifier.js @@ -1,9 +1,11 @@ import loadScript from './loadScript' import ELEMENT from 'element-ui' +import pluginsConfig from './pluginsConfig' let beautifierObj export default function loadBeautifier(cb) { + const { beautifierUrl } = pluginsConfig if (beautifierObj) { cb(beautifierObj) return @@ -17,7 +19,7 @@ export default function loadBeautifier(cb) { background: 'rgba(255, 255, 255, 0.5)' }) - loadScript('https://lib.baomitu.com/js-beautify/1.10.2/beautifier.min.js', () => { + loadScript(beautifierUrl, () => { loading.close() // eslint-disable-next-line no-undef beautifierObj = beautifier diff --git a/src/utils/loadMonaco.js b/src/utils/loadMonaco.js index 14fc1d03..be822ef6 100644 --- a/src/utils/loadMonaco.js +++ b/src/utils/loadMonaco.js @@ -1,5 +1,6 @@ import { loadScriptQueue } from './loadScript' import ELEMENT from 'element-ui' +import pluginsConfig from './pluginsConfig' // monaco-editor单例 let monacoEidtor @@ -14,7 +15,7 @@ export default function loadMonaco(cb) { return } - const vs = 'https://lib.baomitu.com/monaco-editor/0.19.3/min/vs' + const { monacoEditorUrl: vs } = pluginsConfig // 使用element ui实现加载提示 const loading = ELEMENT.Loading.service({ diff --git a/src/utils/loadTinymce.js b/src/utils/loadTinymce.js index ca0e585b..e2455fc8 100644 --- a/src/utils/loadTinymce.js +++ b/src/utils/loadTinymce.js @@ -1,9 +1,12 @@ import loadScript from './loadScript' import ELEMENT from 'element-ui' +import pluginsConfig from './pluginsConfig' let tinymceObj export default function loadTinymce(cb) { + const { tinymceUrl } = pluginsConfig + if (tinymceObj) { cb(tinymceObj) return @@ -17,7 +20,7 @@ export default function loadTinymce(cb) { background: 'rgba(255, 255, 255, 0.5)' }) - loadScript('https://lib.baomitu.com/tinymce/5.3.2/tinymce.min.js', () => { + loadScript(tinymceUrl, () => { loading.close() // eslint-disable-next-line no-undef tinymceObj = tinymce diff --git a/src/utils/pluginsConfig.js b/src/utils/pluginsConfig.js new file mode 100644 index 00000000..d841cb78 --- /dev/null +++ b/src/utils/pluginsConfig.js @@ -0,0 +1,11 @@ +const CDN = 'https://lib.baomitu.com/' + +function splicingPluginUrl(PluginName, version, fileName) { + return `${CDN}${PluginName}/${version}/${fileName}` +} + +export default { + beautifierUrl: splicingPluginUrl('js-beautify', '1.13.5', 'beautifier.min.js'), + monacoEditorUrl: splicingPluginUrl('monaco-editor', '0.19.3', 'min/vs'), + tinymceUrl: splicingPluginUrl('tinymce', '5.3.2', 'tinymce.min.js') +}