From d31766e742cbc2bac63e335396f22abcc7d6e256 Mon Sep 17 00:00:00 2001
From: 1012414140@qq.com <1012414140@qq.com>
Date: 星期五, 16 十月 2026 09:05:59 +0800
Subject: [PATCH] feat: 优化调用的CDN
---
public/index.html | 154 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 140 insertions(+), 14 deletions(-)
diff --git a/public/index.html b/public/index.html
index 6a0df03..507251a 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,17 +1,143 @@
<!DOCTYPE html>
<html lang="en">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
- <title></title>
- </head>
- <body>
- <div id="app"></div>
- </body>
-<!-- <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>-->
-<!-- <script>-->
-<!-- // VConsole 榛樿浼氭寕杞藉埌 `window.VConsole` 涓�-->
-<!-- var vConsole = new window.VConsole();-->
-<!-- </script>-->
+<head>
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no">
+ <title>宄板嘲鐭垮尯鏅烘収鍋滆溅</title>
+
+ <!--
+ 鏍峰紡鏂囦欢锛氫富婧愮敤鍥藉唴闃块噷浜� npmmirror锛堢Щ鍔�/鑱旈��/鐢典俊缃戠粶绋冲畾鍙揪锛夛紝
+ 鍔犺浇澶辫触鑷姩鍒囧洖 jsdelivr銆侰SS 澶辫触涓嶄細瀵艰嚧鐧藉睆锛屼粎鏍峰紡寮傚父銆�
+ -->
+ <link rel="stylesheet"
+ href="https://registry.npmmirror.com/element-ui/2.15.14/files/lib/theme-chalk/index.css"
+ onerror="this.onerror=null;this.href='https://cdn.jsdelivr.net/npm/element-ui@2.15.14/lib/theme-chalk/index.css'">
+ <link rel="stylesheet"
+ href="https://registry.npmmirror.com/view-design/4.7.0/files/dist/styles/iview.css"
+ onerror="this.onerror=null;this.href='https://cdn.jsdelivr.net/npm/view-design@4.7.0/dist/styles/iview.css'">
+
+ <style>
+ /* 棣栧睆鍔犺浇鍗犱綅锛圴ue 鎸傝浇鍚庝細鑷姩鏇挎崲鎺� #app 鍐呯殑鍐呭锛� */
+ #app-loading{position:fixed;top:0;left:0;right:0;bottom:0;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;background:#f5f7fa;color:#606266;font-size:15px;z-index:9998}
+ #app-loading .spin{width:38px;height:38px;margin-bottom:14px;border:3px solid #dcdfe6;border-top-color:#409eff;border-radius:50%;animation:appspin .8s linear infinite}
+ @keyframes appspin{to{transform:rotate(360deg)}}
+ /* 璧勬簮鍏ㄩ儴鍔犺浇澶辫触鏃剁殑鎻愮ず灞傦紝鏇夸唬鈥滅函鐧藉睆鈥� */
+ #fatal-mask{display:none;position:fixed;top:0;left:0;right:0;bottom:0;inset:0;z-index:9999;background:#fff;align-items:center;justify-content:center;padding:30px;box-sizing:border-box}
+ #fatal-mask .box{max-width:420px;text-align:center;color:#303133}
+ #fatal-mask .ico{font-size:44px;color:#f56c6c;margin-bottom:14px}
+ #fatal-mask .msg{font-size:15px;line-height:1.7;color:#606266;margin-bottom:20px;word-break:break-all}
+ #fatal-mask button{padding:10px 34px;font-size:15px;color:#fff;background:#409eff;border:none;border-radius:4px;outline:none}
+ #fatal-mask button:active{background:#3a8ee6}
+ </style>
+
+ <script>
+ /*
+ * 鍩虹搴擄紙Vue / ElementUI / ViewUI / ECharts锛夊婧愬鐏惧姞杞藉櫒
+ *
+ * 鑳屾櫙锛氳繖浜涘簱閫氳繃 webpack externals 澶栫疆锛屼笟鍔″寘鎵ц寮轰緷璧栧搴旂殑鍏ㄥ眬鍙橀噺銆�
+ * 涔嬪墠鍙紩鐢� cdn.jsdelivr.net 涓�涓簮锛岃鍩熷悕鍦ㄥ浗鍐呮墜鏈鸿渹绐濈綉缁滐紙4G/5G锛変笅
+ * 缁忓父琚� DNS 姹℃煋 / 杩炴帴閲嶇疆锛岃剼鏈姞杞藉け璐ュ悗 window.Vue 涓� undefined锛�
+ * 涓氬姟鍖呮墽琛岀珛鍗虫姤閿欙紝#app 姘歌繙涓虹┖锛岃〃鐜颁负鎵嬫満鐧藉睆銆�
+ *
+ * 绛栫暐锛氬浗鍐� npmmirror 涓轰富婧愶紝jsdelivr銆乥ootcdn 渚濇鍏滃簳锛�
+ * 鐢ㄢ�滃閾捐剼鏈� + 绱ч殢鍏跺悗鐨勫唴鑱旀娴嬭剼鏈�濇垚瀵硅緭鍑猴紝淇濊瘉涓ユ牸鐨勫姞杞介『搴忥紝
+ * 涓氬姟鍖咃紙webpack 娉ㄥ叆鍦� body 鏈熬锛変竴瀹氬湪鎵�鏈夊熀纭�搴撳氨缁悗鎵嶆墽琛屻��
+ */
+ window.__cdnTry = function (globalName, urls, idx) {
+ if (window[globalName]) return true;
+ if (idx >= urls.length) {
+ (window.__CDN_FAILED__ = window.__CDN_FAILED__ || []).push(globalName);
+ return false;
+ }
+ document.write('<script src="' + urls[idx] + '"><\/script>');
+ document.write('<script>window.__cdnTry("' + globalName + '",' + JSON.stringify(urls) + ',' + (idx + 1) + ');<\/script>');
+ };
+
+ /* 鐧藉睆鍏滃簳锛氳褰曡剼鏈敊璇紝瓒呮椂鍚庤嫢鍩虹搴撲粛鏈氨缁垯缁欏嚭鍙鎻愮ず */
+ window.__lastError__ = '';
+ window.addEventListener('error', function (e) {
+ if (e && e.message) {
+ window.__lastError__ = e.message + (e.filename ? ('锛�' + e.filename.split('/').pop() + ':' + e.lineno + '锛�') : '');
+ }
+ }, true);
+ window.addEventListener('unhandledrejection', function (e) {
+ var r = e && e.reason;
+ window.__lastError__ = 'Promise寮傚父: ' + (r && r.message ? r.message : String(r));
+ });
+ window.__showFatal = function (msg) {
+ var mask = document.getElementById('fatal-mask');
+ var loading = document.getElementById('app-loading');
+ if (loading) loading.style.display = 'none';
+ if (mask) {
+ document.getElementById('fatal-msg').textContent = msg;
+ mask.style.display = 'flex';
+ }
+ };
+ setTimeout(function () {
+ /* 娉ㄦ剰锛歷iew-design 鐨� UMD 鍖呭湪娴忚鍣ㄤ笅鎸傝浇鐨勫叏灞�鍚嶆槸灏忓啓 iview锛屼笉鏄� ViewUI */
+ var required = ['Vue', 'ELEMENT', 'iview', 'echarts'];
+ var labels = { Vue: 'Vue', ELEMENT: 'ElementUI', iview: 'ViewUI', echarts: 'ECharts' };
+ var missing = required.filter(function (n) { return !window[n]; });
+ if (missing.length) {
+ window.__showFatal('闈欐�佽祫婧愬姞杞藉け璐ワ紝椤甸潰鏃犳硶鍚姩锛堢己灏戯細' + missing.map(function (n) { return labels[n]; }).join('銆�') +
+ '锛夈�傝鍒囨崲 WiFi 鎴� 4G/5G 缃戠粶鍚庨噸璇曘��' +
+ (window.__lastError__ ? ('\n' + window.__lastError__) : ''));
+ return;
+ }
+ /* 搴撻綈鍏ㄤ絾 12 绉掍粛鏈寕杞斤紝閫氬父鏄笟鍔″寘/鎺ュ彛寮傚父锛屼篃瑕佽鐢ㄦ埛鐪嬪埌鑰屼笉鏄櫧灞� */
+ setTimeout(function () {
+ var loading = document.getElementById('app-loading');
+ if (loading && loading.parentNode) {
+ window.__showFatal('椤甸潰鍔犺浇瓒呮椂锛岃鐐瑰嚮閲嶈瘯銆�' +
+ (window.__lastError__ ? ('\n' + window.__lastError__) : ''));
+ }
+ }, 12000);
+ }, 8000);
+ </script>
+</head>
+<body>
+ <div id="app"><div id="app-loading"><div class="spin"></div><div>姝e湪鍔犺浇锛岃绋嶅�欌��</div></div></div>
+
+ <div id="fatal-mask">
+ <div class="box">
+ <div class="ico">!</div>
+ <div class="msg" id="fatal-msg">闈欐�佽祫婧愬姞杞藉け璐ワ紝璇烽噸璇曘��</div>
+ <button type="button" onclick="location.reload()">閲嶆柊鍔犺浇</button>
+ </div>
+ </div>
+
+ <script>
+ (function () {
+ /* 椤哄簭涓嶈兘鍙橈細Vue -> ElementUI -> ViewUI -> ECharts */
+ var LIBS = [
+ ['Vue', [
+ 'https://registry.npmmirror.com/vue/2.7.16/files/dist/vue.min.js',
+ 'https://cdn.jsdelivr.net/npm/vue@2.7.16/dist/vue.min.js',
+ 'https://cdn.bootcdn.net/ajax/libs/vue/2.7.16/vue.min.js'
+ ]],
+ ['ELEMENT', [
+ 'https://registry.npmmirror.com/element-ui/2.15.14/files/lib/index.js',
+ 'https://cdn.jsdelivr.net/npm/element-ui@2.15.14/lib/index.js',
+ 'https://cdn.bootcdn.net/ajax/libs/element-ui/2.15.14/index.js'
+ ]],
+ ['iview', [
+ 'https://registry.npmmirror.com/view-design/4.7.0/files/dist/iview.min.js',
+ 'https://cdn.jsdelivr.net/npm/view-design@4.7.0/dist/iview.min.js',
+ 'https://cdn.bootcdn.net/ajax/libs/view-design/4.7.0/iview.min.js'
+ ]],
+ ['echarts', [
+ 'https://registry.npmmirror.com/echarts/5.4.3/files/dist/echarts.min.js',
+ 'https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js',
+ 'https://cdn.bootcdn.net/ajax/libs/echarts/5.4.3/echarts.min.js'
+ ]]
+ ];
+ LIBS.forEach(function (lib) {
+ var name = lib[0], urls = lib[1];
+ document.write('<script src="' + urls[0] + '"><\/script>');
+ document.write('<script>window.__cdnTry("' + name + '",' + JSON.stringify(urls) + ',1);<\/script>');
+ });
+ })();
+ </script>
+</body>
</html>
--
Gitblit v1.9.1