From ed33bf6fa697cf20133ee6fe1c8b9f24394ba3bd Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Fri, 21 Mar 2025 11:06:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.js | 15 +++++++++++++++ index.html | 3 +++ package.json | 8 ++++---- 3 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 build.js diff --git a/build.js b/build.js new file mode 100644 index 0000000..f132ccf --- /dev/null +++ b/build.js @@ -0,0 +1,15 @@ +const fs = require('fs'); +const path = require('path'); + +const indexPath = path.resolve(__dirname, 'dist/index.html'); +let indexHtml = fs.readFileSync(indexPath, 'utf-8'); +const timestamp = new Date().getTime(); + +// 正则表达式匹配JS文件引用并添加时间戳 +indexHtml = indexHtml.replace(/`; + } + return match; +}); +fs.writeFileSync(indexPath, indexHtml); \ No newline at end of file diff --git a/index.html b/index.html index ad859db..5d1ed2c 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,9 @@ + + + diff --git a/package.json b/package.json index 6e1dab7..9a0e692 100644 --- a/package.json +++ b/package.json @@ -9,9 +9,9 @@ "dev": "concurrently \"electron .\" \"cross-env BROWSER=none vite\"", "build": "vite build", "preview": "vite preview", - "build:dev": "vite build & electron-builder -w --config=./config/development.json", - "build:prod": "vite build & electron-builder -w --config=./config/production.json", - "build:xy": "vite build & electron-builder -w --config=./config/xy.json" + "build:dev": "vite build & node build.js & electron-builder -w --config=./config/development.json", + "build:prod": "vite build & node build.js & electron-builder -w --config=./config/production.json", + "build:xy": "vite build & node build.js & electron-builder -w --config=./config/xy.json" }, "agora_electron": { "platform": "win32", @@ -56,4 +56,4 @@ "vite-plugin-html": "^3.2.2", "vite-plugin-resolve": "^2.5.1" } -} +} \ No newline at end of file From 431bad2b9a806914812061c2ab0d7b2099fa405c Mon Sep 17 00:00:00 2001 From: yj <1336058017@qq.com> Date: Fri, 21 Mar 2025 11:14:50 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.js b/build.js index f132ccf..2c05509 100644 --- a/build.js +++ b/build.js @@ -8,7 +8,7 @@ const timestamp = new Date().getTime(); // 正则表达式匹配JS文件引用并添加时间戳 indexHtml = indexHtml.replace(/`; + return ``; } return match; });