浏览代码

兼容低版本浏览器

Hwf 2 月之前
父节点
当前提交
6ea5aeeb8d
共有 5 个文件被更改,包括 702 次插入91 次删除
  1. 3 0
      index.html
  2. 2 0
      package.json
  3. 668 91
      pnpm-lock.yaml
  4. 1 0
      src/main.ts
  5. 28 0
      vite.config.ts

+ 3 - 0
index.html

@@ -59,5 +59,8 @@
     </script>
     </script>
     <% } %>
     <% } %>
     <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
     <script src="//res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
+    <script>
+        this.globalThis || (this.globalThis = this)
+    </script>
   </body>
   </body>
 </html>
 </html>

+ 2 - 0
package.json

@@ -26,6 +26,7 @@
     "@vueuse/core": "^11.0.3",
     "@vueuse/core": "^11.0.3",
     "await-to-js": "^3.0.0",
     "await-to-js": "^3.0.0",
     "axios": "^1.6.8",
     "axios": "^1.6.8",
+    "core-js": "^3.41.0",
     "crypto-js": "^4.2.0",
     "crypto-js": "^4.2.0",
     "dayjs": "^1.11.13",
     "dayjs": "^1.11.13",
     "echarts": "^5.5.1",
     "echarts": "^5.5.1",
@@ -54,6 +55,7 @@
     "@types/nprogress": "^0.2.3",
     "@types/nprogress": "^0.2.3",
     "@typescript-eslint/eslint-plugin": "^7.9.0",
     "@typescript-eslint/eslint-plugin": "^7.9.0",
     "@typescript-eslint/parser": "^7.9.0",
     "@typescript-eslint/parser": "^7.9.0",
+    "@vitejs/plugin-legacy": "^6.0.2",
     "@vitejs/plugin-vue": "^5.0.4",
     "@vitejs/plugin-vue": "^5.0.4",
     "@vitejs/plugin-vue-jsx": "^3.1.0",
     "@vitejs/plugin-vue-jsx": "^3.1.0",
     "@vue/eslint-config-typescript": "^13.0.0",
     "@vue/eslint-config-typescript": "^13.0.0",

文件差异内容过多而无法显示
+ 668 - 91
pnpm-lock.yaml


+ 1 - 0
src/main.ts

@@ -1,5 +1,6 @@
 import { createApp } from "vue";
 import { createApp } from "vue";
 import { store } from "./store";
 import { store } from "./store";
+import 'core-js/stable'; // 引入所有稳定版 Polyfill
 import 'element-plus/dist/index.css'
 import 'element-plus/dist/index.css'
 // normalize.css
 // normalize.css
 import "normalize.css/normalize.css";
 import "normalize.css/normalize.css";

+ 28 - 0
vite.config.ts

@@ -13,6 +13,7 @@ import viteCompression from "vite-plugin-compression";
 import { createHtmlPlugin } from "vite-plugin-html";
 import { createHtmlPlugin } from "vite-plugin-html";
 import { enableCDN } from "./build/cdn";
 import { enableCDN } from "./build/cdn";
 import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
 import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
+import legacy from '@vitejs/plugin-legacy';
 
 
 // 当前工作目录路径
 // 当前工作目录路径
 const root: string = process.cwd();
 const root: string = process.cwd();
@@ -67,6 +68,33 @@ export default defineConfig(({ mode }) => {
         vueTemplate: true, // 是否在 vue 模板中自动导入
         vueTemplate: true, // 是否在 vue 模板中自动导入
 
 
       }),
       }),
+      legacy({
+        targets: ['defaults', 'Chrome >= 51'],
+        additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
+        modernPolyfills: ['es.string.replace-all'],
+        renderLegacyChunks: true,
+        polyfills: [
+          'es.array.flat-map',
+          'es.array.filter',
+          'es.promise',
+          'es.promise.finally',
+          'es.object.assign',
+          'es.array.for-each',
+          'es.object.define-properties',
+          'es.object.define-property',
+          'es.object.get-own-property-descriptor',
+          'es.object.get-own-property-descriptors',
+          'es.object.keys',
+          'es.object.to-string',
+          'web.dom-collections.for-each',
+          'esnext.global-this',
+          'esnext.string.match-all',
+          'es.array.iterator',
+          'es.string.includes',
+          'es.string.starts-with',
+          'es.object.values'
+        ]
+      }),
       // 生产环境默认不启用 CDN 加速
       // 生产环境默认不启用 CDN 加速
       enableCDN(env.VITE_CDN_DEPS),
       enableCDN(env.VITE_CDN_DEPS),
       ViteImageOptimizer()
       ViteImageOptimizer()

部分文件因为文件数量过多而无法显示