Jelajahi Sumber

适配低版本浏览器。

jiaxiaoqiang 8 bulan lalu
induk
melakukan
e0f494d0ad
2 mengubah file dengan 11 tambahan dan 1 penghapusan
  1. 3 1
      package.json
  2. 8 0
      vite.config.ts

+ 3 - 1
package.json

@@ -76,7 +76,7 @@
     "vue": "^3.4.21",
     "vue-draggable-plus": "^0.4.0",
     "vue-i18n": "9.9.1",
-    "vue-pdf-embed": "^2.0.2",
+    "vue-pdf-embed": "2.0.2",
     "vue-qrcode": "^2.2.2",
     "vue-router": "^4.3.0",
     "vue3-pdfjs": "^0.1.6",
@@ -96,6 +96,7 @@
     "@types/uuid": "^9.0.8",
     "@typescript-eslint/eslint-plugin": "^7.1.1",
     "@typescript-eslint/parser": "^7.1.1",
+    "@vitejs/plugin-legacy": "^5.4.2",
     "@vitejs/plugin-vue": "^5.0.4",
     "@vitejs/plugin-vue-jsx": "^3.1.0",
     "autoprefixer": "^10.4.18",
@@ -107,6 +108,7 @@
     "eslint-plugin-prettier": "^5.1.3",
     "eslint-plugin-vue": "^9.22.0",
     "fast-glob": "^3.3.2",
+    "i": "^0.3.7",
     "lint-staged": "^15.2.2",
     "postcss": "^8.4.35",
     "postcss-html": "^1.6.0",

+ 8 - 0
vite.config.ts

@@ -7,6 +7,7 @@ import Components from "unplugin-vue-components/vite";
 import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
 import Icons from "unplugin-icons/vite";
 import IconsResolver from "unplugin-icons/resolver";
+import legacyPlugin from "@vitejs/plugin-legacy";
 
 import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
 import mockDevServerPlugin from "vite-plugin-mock-dev-server";
@@ -84,6 +85,10 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
       UnoCSS({
         hmrTopLevelAwait: false,
       }),
+      legacyPlugin({
+        targets: ["chrome 70"], // 需要兼容的目标列表,可以设置多个
+        additionalLegacyPolyfills: ["regenerator-runtime/runtime"], // 面向IE11时需要此插件
+      }),
       // 自动导入参考: https://github.com/sxzz/element-plus-best-practices/blob/main/vite.config.ts
       AutoImport({
         // 自动导入 Vue 相关函数,如:ref, reactive, toRef 等
@@ -251,6 +256,9 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => {
       __APP_INFO__: JSON.stringify(__APP_INFO__),
       "process.env": process.env, //尝试访问 Node.js 环境变量,但这些变量在浏览器环境中是不存在的。(process is not defined)
     },
+    esbuild: {
+      drop: ["console", "debugger"], // 去除 console.log 和 debugger
+    },
   };
 });
 // 打包文件时候 更新版本号 用作判断是否要刷新页面