Browse Source

🎨 打包调整

快乐的梦鱼 9 hours ago
parent
commit
c389851be0
6 changed files with 1666 additions and 235 deletions
  1. 1 1
      pack/manifest.json
  2. 1595 232
      package-lock.json
  3. 9 2
      package.json
  4. 52 0
      src/scripts/copyDist.cjs
  5. 4 0
      src/views/ListView.vue
  6. 5 0
      vite.config.ts

+ 1 - 1
pack/manifest.json

@@ -10,7 +10,7 @@
     "icons" : {
         "72" : "icon.png"
     },
-    "launch_path" : "https://mncdn.wenlvti.net/app_static/huli-showroom/index.html", /*应用的入口页面,默认为根目录下的index.html;支持网络地址,必须以http://或https://开头*/
+    "launch_path" : "index.html", /*应用的入口页面,默认为根目录下的index.html;支持网络地址,必须以http://或https://开头*/
     "developer" : {
         "name" : "", /*开发者名称*/
         "email" : "", /*开发者邮箱地址*/

File diff suppressed because it is too large
+ 1595 - 232
package-lock.json


+ 9 - 2
package.json

@@ -7,13 +7,20 @@
     "dev": "vite",
     "build": "run-p type-check \"build-only {@}\" --",
     "preview": "vite preview",
-    "build-only": "vite build",
+    "build-only": "vite build && node .\\src\\scripts\\copyDist.cjs",
     "type-check": "vue-tsc --build"
-  },
+  },  
+  "browserslist": [
+    "ie >= 11",
+    "> 1%",
+    "last 2 versions",
+    "not dead"
+  ],
   "dependencies": {
     "@imengyu/imengyu-utils": "^0.0.12",
     "@imengyu/js-request-transform": "^0.3.5",
     "@imengyu/vue-scroll-rect": "^0.1.7",
+    "@vitejs/plugin-legacy": "^7.2.1",
     "ant-design-vue": "^4.2.6",
     "md5": "^2.3.0",
     "pinia": "^3.0.3",

+ 52 - 0
src/scripts/copyDist.cjs

@@ -0,0 +1,52 @@
+const fs = require('fs');
+const path = require('path');
+
+// 定义源目录和目标目录路径
+const srcDir = path.resolve(__dirname, '../..', 'dist');
+const destDir = path.resolve(__dirname, '../..', 'pack');
+
+/**
+ * 递归拷贝目录内容
+ * @param {string} src - 源目录路径
+ * @param {string} dest - 目标目录路径
+ */
+function copyDir(src, dest) {
+    // 检查源目录是否存在
+    if (!fs.existsSync(src)) {
+        console.error(`错误:源目录不存在 - ${src}`);
+        process.exit(1);
+    }
+
+    // 创建目标目录(如果不存在)
+    if (!fs.existsSync(dest)) {
+        fs.mkdirSync(dest, { recursive: true });
+        console.log(`创建目标目录:${dest}`);
+    }
+
+    // 读取源目录内容
+    const entries = fs.readdirSync(src, { withFileTypes: true });
+
+    for (const entry of entries) {
+        const srcPath = path.join(src, entry.name);
+        const destPath = path.join(dest, entry.name);
+
+        if (entry.isDirectory()) {
+            // 递归处理子目录
+            copyDir(srcPath, destPath);
+        } else {
+            // 拷贝文件
+            fs.copyFileSync(srcPath, destPath);
+            console.log(`已拷贝:${srcPath} -> ${destPath}`);
+        }
+    }
+}
+
+// 执行拷贝并处理错误
+try {
+    console.log('开始拷贝文件...');
+    copyDir(srcDir, destDir);
+    console.log('文件拷贝完成!');
+} catch (err) {
+    console.error('拷贝过程中发生错误:', err);
+    process.exit(1);
+}

+ 4 - 0
src/views/ListView.vue

@@ -44,6 +44,10 @@ onMounted(async () => {
             </div>
             <h6>{{ value.title }}</h6>
           </div>
+          <div 
+            v-for="v of (newsData.list.value.length % 6)"
+            class="main-list-box1"
+          />
         </SimplePageListContentLoader>
         <a-pagination 
           v-if="newsData.totalPages.value > 1"

+ 5 - 0
vite.config.ts

@@ -4,6 +4,7 @@ import { defineConfig } from 'vite'
 import vue from '@vitejs/plugin-vue'
 import vueJsx from '@vitejs/plugin-vue-jsx'
 import vueDevTools from 'vite-plugin-vue-devtools'
+import legacy from '@vitejs/plugin-legacy';
 import Components from 'unplugin-vue-components/vite';
 import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
 
@@ -11,6 +12,10 @@ import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';
 export default defineConfig({
   plugins: [
     vue(),
+    legacy({
+      targets: ['defaults', 'not IE 11'],
+      renderLegacyChunks: true,
+    }),
     vueJsx(),
     vueDevTools(),
     Components({