From 34e27d062170dfee7eb5555bc99c0eba92a2ecfb Mon Sep 17 00:00:00 2001
From: ZF sun <34314687@qq.com>
Date: Sat, 9 May 2026 17:14:51 +0800
Subject: [PATCH] =?UTF-8?q?feat(index):=20=E9=A6=96=E9=A1=B5=E6=A0=87?=
=?UTF-8?q?=E9=A2=98=E8=BF=9E=E5=87=BB5=E6=AC=A1=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E6=9E=84=E5=BB=BA=E7=89=88=E6=9C=AC=E4=BF=A1=E6=81=AF\nfix(scr?=
=?UTF-8?q?ipts):=20explorer=E4=BD=BF=E7=94=A8spawn=E9=81=BF=E5=85=8DGUI?=
=?UTF-8?q?=E8=BF=9B=E7=A8=8B=E9=98=BB=E5=A1=9E\nfix(index):=20version.jso?=
=?UTF-8?q?n=E8=BF=90=E8=A1=8C=E6=97=B6=E8=AF=BB=E5=8F=96=EF=BC=8C?=
=?UTF-8?q?=E4=B8=8D=E4=BE=9D=E8=B5=96=E6=9E=84=E5=BB=BA=E6=97=B6require?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pages/index/index.vue | 2 +-
pages/index/public/js/index.js | 63 ++++++++++++++++++++++++++++++++++
scripts/mp-weixin.patch.js | 4 ++-
scripts/open-directory.js | 9 +++--
4 files changed, 73 insertions(+), 5 deletions(-)
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 894d33f..bdb9755 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -9,7 +9,7 @@
- {{ siteInfo.site_name }}
+ {{ siteInfo.site_name }}
{{ followOfficialAccount.welcomeMsg }}
diff --git a/pages/index/public/js/index.js b/pages/index/public/js/index.js
index f4ae3a0..d7ba0cc 100644
--- a/pages/index/public/js/index.js
+++ b/pages/index/public/js/index.js
@@ -91,6 +91,69 @@ export default {
// 阻止事件继续传播
return false;
+ },
+ /**
+ * 标题连击 5 次显示构建版本信息(供测试人员使用)
+ */
+ onTitleTap() {
+ this._titleTapCount = (this._titleTapCount || 0) + 1;
+ if (this._titleTapTimer) {
+ clearTimeout(this._titleTapTimer);
+ }
+ if (this._titleTapCount >= 5) {
+ this._titleTapCount = 0;
+ this._showVersionInfo();
+ return;
+ }
+ // 2 秒内未达到 5 次则重置计数
+ this._titleTapTimer = setTimeout(() => {
+ this._titleTapCount = 0;
+ }, 2000);
+ },
+ _showVersionInfo() {
+ // #ifdef MP-WEIXIN
+ try {
+ const fs = uni.getFileSystemManager();
+ fs.readFile({
+ filePath: 'version.json',
+ encoding: 'utf-8',
+ success: (res) => {
+ try {
+ const v = JSON.parse(res.data);
+ if (v && v.commitId) {
+ uni.showModal({
+ title: '构建版本信息',
+ content: `提交 ID: ${v.commitId}\n构建时间: ${v.buildTime}`,
+ showCancel: false
+ });
+ return;
+ }
+ } catch (e) {}
+ uni.showModal({ title: '构建版本信息', content: '版本信息不可用', showCancel: false });
+ },
+ fail: () => this._showVersionFromGlobal()
+ });
+ } catch (e) {
+ this._showVersionFromGlobal();
+ }
+ // #endif
+ // #ifndef MP-WEIXIN
+ this._showVersionFromGlobal();
+ // #endif
+ },
+ _showVersionFromGlobal() {
+ try {
+ const v = typeof __app_version !== 'undefined' ? __app_version : null;
+ if (v && v.commitId) {
+ uni.showModal({
+ title: '构建版本信息',
+ content: `提交 ID: ${v.commitId}\n构建时间: ${v.buildTime}`,
+ showCancel: false
+ });
+ return;
+ }
+ } catch (e) {}
+ uni.showModal({ title: '构建版本信息', content: '版本信息不可用', showCancel: false });
}
}
}
\ No newline at end of file
diff --git a/scripts/mp-weixin.patch.js b/scripts/mp-weixin.patch.js
index 640180c..9ad2d8e 100644
--- a/scripts/mp-weixin.patch.js
+++ b/scripts/mp-weixin.patch.js
@@ -89,7 +89,9 @@ async function commonPatch(mode = 'production') {
// 4) 处理 vendor.js:在开头追加 require 语句(如果还没有的话)
const vendorExists = await exists(vendorPath);
if (!vendorExists) {
- console.warn(`目标 vendor.js 不存在,跳过追加 require。路径: ${vendorPath}`);
+ console.warn(`⚠ 目标 vendor.js 不存在,跳过追加 require。路径: ${vendorPath}`);
+ console.warn(' → 请先执行 HBuilder 构建(uniapp 构建),产生 vendor.js 后再运行此脚本。');
+ console.warn(' → version.json 已生成,可在首页连击 5 次标题查看版本信息。');
return;
}
diff --git a/scripts/open-directory.js b/scripts/open-directory.js
index 182c9ef..7493f08 100644
--- a/scripts/open-directory.js
+++ b/scripts/open-directory.js
@@ -55,10 +55,13 @@ async function openDirectoryWindows(directoryPath) {
console.log(`📁 在文件资源管理器中打开: ${normalizedPath}`);
- // 方法1: 使用 explorer 命令
+ // 方法1: 使用 explorer 命令(spawn + detached,不等待 GUI 进程)
try {
- const command = `explorer "${normalizedPath}"`;
- await execAsync(command);
+ const child = spawn('explorer', [normalizedPath], {
+ stdio: 'ignore',
+ detached: true
+ });
+ child.unref();
console.log('✅ 已启动文件资源管理器');
return true;
} catch (error) {