|
@@ -2,12 +2,13 @@
|
|
|
* @Author: PoJun
|
|
|
* @Date: 2023-12-14 15:56:24
|
|
|
* @LastEditors: PoJun
|
|
|
- * @LastEditTime: 2024-03-04 18:40:48
|
|
|
+ * @LastEditTime: 2024-05-09 20:58:45
|
|
|
* @Message: Nothing
|
|
|
*/
|
|
|
export const logoutApp = async vm => {
|
|
|
// 退出设备
|
|
|
try {
|
|
|
+ // 消息相关先注释掉
|
|
|
// #ifdef APP-PLUS
|
|
|
// await uni.$uv.http.get("/system_ext/user/client_info", { custom: { toast: false } });
|
|
|
// #endif
|
|
@@ -21,3 +22,41 @@ export const logoutApp = async vm => {
|
|
|
console.log(error);
|
|
|
}
|
|
|
};
|
|
|
+
|
|
|
+export const checkAppUpdate = async needToast => {
|
|
|
+ try {
|
|
|
+ const sysInfo = uni.getSystemInfoSync();
|
|
|
+ const res = await uni.request({
|
|
|
+ url: "https://www.pgyer.com/apiv2/app/check",
|
|
|
+ data: {
|
|
|
+ appKey: "145b8b88437f52fc04ec8409c2d2c2b6",
|
|
|
+ _api_key: "d6e02150ac8f6289081185e041137f7d", // 蒲公英账号私人key
|
|
|
+ },
|
|
|
+ });
|
|
|
+ if (res.statusCode === 200) {
|
|
|
+ const latestVersionInfo = res.data?.data || {};
|
|
|
+ const currentVersion = sysInfo.appVersion;
|
|
|
+
|
|
|
+ if (latestVersionInfo.buildVersion !== currentVersion) {
|
|
|
+ // 有新版本,提示用户更新
|
|
|
+ uni.showModal({
|
|
|
+ title: "发现新版本",
|
|
|
+ content: `最新版本:${latestVersionInfo.buildVersion},更新内容:${latestVersionInfo.buildUpdateDescription}`,
|
|
|
+ confirmText: "立即更新",
|
|
|
+ success: async modalRes => {
|
|
|
+ if (modalRes.confirm) {
|
|
|
+ // 打开蒲公英的下载链接
|
|
|
+ plus.runtime.openURL(latestVersionInfo.downloadURL);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ if (needToast) {
|
|
|
+ uni.showToast({ title: "当前已是最新版本!", icon: "none" });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error("检查更新失败", error);
|
|
|
+ }
|
|
|
+};
|