index.html 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <title><%= htmlWebpackPlugin.options.title %></title>
  7. <script>
  8. var coverSupport =
  9. 'CSS' in window &&
  10. typeof CSS.supports === 'function' &&
  11. (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'));
  12. document.write(
  13. '<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' +
  14. (coverSupport ? ', viewport-fit=cover' : '') +
  15. '" />',
  16. );
  17. </script>
  18. <link
  19. rel="stylesheet"
  20. href="<%= BASE_URL %>static/index.<%= VUE_APP_INDEX_CSS_HASH %>.css"
  21. />
  22. <!-- 微信JS-SDK -->
  23. <script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js" async></script>
  24. <script>
  25. // 微信JS-SDK备用加载逻辑 - 简化版 (2025-01-03)
  26. (function () {
  27. const cdnUrls = [
  28. 'https://res.wx.qq.com/open/js/jweixin-1.6.0.js',
  29. 'https://res2.wx.qq.com/open/js/jweixin-1.6.0.js',
  30. ];
  31. let loadAttempts = 0;
  32. function checkWxLoaded() {
  33. return (
  34. typeof wx !== 'undefined' &&
  35. wx.config &&
  36. typeof wx.config === 'function' &&
  37. wx.ready &&
  38. typeof wx.ready === 'function'
  39. );
  40. }
  41. function loadBackupScript() {
  42. if (loadAttempts >= 2 || checkWxLoaded()) {
  43. return;
  44. }
  45. loadAttempts++;
  46. console.log(`🔄 备用加载微信JS-SDK (${loadAttempts}/2)`);
  47. const script = document.createElement('script');
  48. script.src = cdnUrls[loadAttempts % cdnUrls.length];
  49. script.async = true;
  50. script.onload = () => console.log('✅ 备用资源加载成功');
  51. script.onerror = () => {
  52. console.log('❌ 备用资源加载失败,重试...');
  53. setTimeout(loadBackupScript, 1000);
  54. };
  55. document.head.appendChild(script);
  56. }
  57. // 延迟检查并启动备用加载
  58. setTimeout(() => {
  59. if (!checkWxLoaded()) {
  60. console.log('⚠️ 启动备用加载...');
  61. loadBackupScript();
  62. } else {
  63. console.log('✅ 微信JS-SDK主资源加载成功');
  64. }
  65. }, 2000);
  66. })();
  67. </script>
  68. </head>
  69. <body>
  70. <noscript>
  71. <strong>Please enable JavaScript to continue.</strong>
  72. </noscript>
  73. <div id="app"></div>
  74. <!-- built files will be auto injected -->
  75. </body>
  76. </html>