feat(index): 首页标题连击5次显示构建版本信息\nfix(scripts): explorer使用spawn避免GUI进程阻塞\nfix(index): version.json运行时读取,不依赖构建时require
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
<image :src="$util.img(siteInfo.logo_square)" mode="aspectFill"></image>
|
||||
</view>
|
||||
<view class="info-box" :style="{ color: '#ffffff' }">
|
||||
<text class="font-size-base">{{ siteInfo.site_name }}</text>
|
||||
<text class="font-size-base" @tap="onTitleTap">{{ siteInfo.site_name }}</text>
|
||||
<text>{{ followOfficialAccount.welcomeMsg }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user