Skip to content

Commit abae346

Browse files
committed
feat(version): 更新微信版本信息获取功能
- 新增微信版本信息获取请求,从支持微信的官方接口获取最新版本数据 - 更新微信版本列表显示逻辑,根据用户设备显示对应平台的最新版本 - 在 README 中添加 support.weixin.qq.com 域名,以支持新的微信版本信息接口 -优化错误处理和数据解析逻辑,提高版本信息获取的稳定性和准确性
1 parent 71045d7 commit abae346

File tree

5 files changed

+55
-7
lines changed

5 files changed

+55
-7
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ QQ 版本列表 Vigor for WeChat MiniProgram 是一个使用 TDesign 组件库
4444
3. [前往微信公众平台注册微信小程序开发者账号](https://mp.weixin.qq.com/cgi-bin/wx),取得 `AppID`(由于小程序需配置域名白名单,测试号无法实现这一点,因此请注册小程序账号而非测试号)。
4545
4.[微信公众平台](https://mp.weixin.qq.com/)-开发管理-服务器域名 中,将以下域名导入微信小程序 request 合法域名:
4646
```
47-
https://csydown.ll.tcdnos.com;https://dldir1.qq.com;https://dldir1v6.qq.com;https://download.z.weixin.qq.com;https://downv6.qq.com;https://im.qq.com;https://imtt.dd.qq.com;https://jsonschema.qpic.cn;https://open.bigmodel.cn;https://qq-gray-1258344701.shiply-cdn.qq.com;https://shiply-cdn.qq.com;https://shiply-demo-1258344701.file.myqcloud.com;https://static.tdesign.tencent.com;https://tcb-api.tencentcloudapi.com;https://tim-1258344701.shiply-cdn.qq.com;https://tim.qq.com;https://upage.html5.qq.com;https://weixin.qq.com;https://z.weixin.qq.com;
47+
https://csydown.ll.tcdnos.com;https://dldir1.qq.com;https://dldir1v6.qq.com;https://download.z.weixin.qq.com;https://downv6.qq.com;https://im.qq.com;https://imtt.dd.qq.com;https://jsonschema.qpic.cn;https://open.bigmodel.cn;https://qq-gray-1258344701.shiply-cdn.qq.com;https://shiply-cdn.qq.com;https://shiply-demo-1258344701.file.myqcloud.com;https://support.weixin.qq.com;https://static.tdesign.tencent.com;https://tcb-api.tencentcloudapi.com;https://tim-1258344701.shiply-cdn.qq.com;https://tim.qq.com;https://upage.html5.qq.com;https://weixin.qq.com;https://z.weixin.qq.com;
4848
```
4949
5. 下载[微信小程序开发者工具](https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html),登录后点击“小程序”-“导入”,填入上一步取得的 `AppID`,将 `<仓库源代码解压目录>/source` 目录选中后导入。
5050
6. 点击微信小程序开发者工具上方“预览”按钮并使用手机扫码,即可使用 QQ 版本列表 Vigor for WeChat MiniProgram。
@@ -65,9 +65,11 @@ QQ 版本列表 Vigor for WeChat MiniProgram 是一个使用 TDesign 组件库
6565
6666
从右向左滑动版本列表,可切换到 TIM 版本列表[^2]和微信版本列表[^3]。
6767
68+
微信版本列表默认显示微信小程序所在操作系统的版本列表。
69+
6870
[^2]: Android TIM 版本信息来源:https://im.qq.com/rainbow/TIMDownload
6971
70-
[^3]: Android 微信版本信息来源:https://weixin.qq.com/updates
72+
[^3]: 微信版本信息来源:https://weixin.qq.com/updates
7173
7274
点击卡片将弹出弹出层,可查阅到更为详尽的信息和原始 JSON 字符串信息。
7375

source/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
App({
1616
onLaunch() {
1717
}, globalData: {
18-
QVERBOW_VERSION: "1.2.1",
18+
QVERBOW_VERSION: "1.2.2",
1919
UA_VERSION: 3, // 用户协议 2024.11.18 第三版
2020
EARLIEST_ACCESSIBILITY_QQ_VERSION: false,
2121
EARLIEST_ACCESSIBILITY_TIM_VERSION: false,

source/pages/index/index.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ Page({
8383
safeBottomPadding: 0,
8484
weixinLocalPlatform: "",
8585
listOrder: ['QQ 版本列表 Vigor', 'TIM 版本列表 Vigor', '微信版本列表 Vigor'],
86-
WeixinFirstSwitch: false
86+
WeixinFirstSwitch: false,
87+
weixinLatestJSON: {}
8788
}, onLoad: function () {
8889
const accountInfo = wx.getAccountInfoSync();
8990
const appBaseInfo = wx.getAppBaseInfo()
@@ -488,6 +489,47 @@ Page({
488489
},
489490
});
490491

492+
wx.request({
493+
fail: (err) => {
494+
endProgress(this)
495+
const errorMessage = err.errMsg;
496+
this.setData({
497+
errorText: errorMessage, errorVisible: true
498+
});
499+
}, method: 'GET', success: (res) => {
500+
try {
501+
const responseData = res.data.toString();
502+
const startString = "var cgiData= {\"errCode\":0,\"errMsg\":\"ok\",\"data\":";
503+
const start = responseData.indexOf(startString) + startString.length;
504+
const end = responseData.indexOf(",\"isMobile\":");
505+
const jsonData = JSON.parse(responseData.substring(start, end));
506+
let platform = this.data.weixinLocalPlatform
507+
const getPlatformVersion = (platform) => {
508+
switch (platform) {
509+
case 'ios':
510+
return 'iosVersion';
511+
case 'windows':
512+
return 'winVersion';
513+
case 'mac':
514+
return 'macVersion';
515+
default:
516+
return 'andrVersion';
517+
}
518+
};
519+
const platformVersion = getPlatformVersion(platform);
520+
this.setData({
521+
weixinLatestJSON: jsonData, weixinLatestVersion: jsonData.prodItems[platformVersion]
522+
})
523+
} catch (e) {
524+
endProgress(this)
525+
const errorMessage = e.errMsg;
526+
this.setData({
527+
errorText: errorMessage, errorVisible: true
528+
});
529+
}
530+
}, url: 'https://support.weixin.qq.com/update/',
531+
})
532+
491533

492534
}, aboutPopupVisible(e) {
493535
this.setData({

source/pages/index/index.wxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ See the Mulan PubL v2 for more details.
129129
</view>
130130
<view class="flex justify-center items-center" slot="note">
131131
<t-button bind:tap="updateWeixin" class="mr-16rpx" icon="download-1" shape="square"
132-
size="medium" style="visibility: {{index===0?'visible':'hidden'}}"
132+
size="medium" style="visibility: {{item.version===weixinLatestVersion?'visible':'hidden'}}"
133133
theme="light" variant="outline"/>
134134
</view>
135135
</t-cell>

source/utils/ShiplyUtil.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
1010
See the Mulan PubL v2 for more details.
1111
*/
12-
1312
const generateAESKey = () => {
1413
return new Promise((resolve, reject) => {
1514
wx.getRandomValues({
@@ -22,6 +21,11 @@ const generateAESKey = () => {
2221
});
2322
};
2423

24+
async function getAESKey() {
25+
return await generateAESKey();
26+
}
27+
2528
module.exports = {
26-
generateAESKey: generateAESKey
29+
generateAESKey: generateAESKey,
30+
getAESKey: getAESKey
2731
};

0 commit comments

Comments
 (0)