This commit is contained in:
cao123
2026-08-13 14:28:23 +08:00
parent d0776f9676
commit 5a27caee6d
7 changed files with 142 additions and 17 deletions
+22 -1
View File
@@ -1,12 +1,22 @@
// app.ts
import { startSSE, stopSSE } from './utils/server-sent-events'
import { checkUpdate } from './utils/updateManager'
import { BASE_URL } from './env'
// @ts-ignore
const systemInfo = wx.getWindowInfo();
// 域名包含 .test. 则为测试环境,不拦截登录
const isTestDomain = (): boolean => BASE_URL.includes('.test.');
// 判断是否在 PC/Windows 环境运行
const isPCEnvironment = (): boolean => {
const sysInfo = wx.getSystemInfoSync();
return ['windows', 'mac'].includes(sysInfo.platform);
};
export { };
App<IAppOption>({
globalData: {
isLogin: false, // 当前是否登录
isLogin: false, //
wasLogin: false, // 之前是否登录过,用来判断是不是 登录状态失效
safeBottom: systemInfo.safeArea.bottom - systemInfo.safeArea.height,
safeTop: systemInfo.safeArea.top * 2,
@@ -20,6 +30,17 @@ App<IAppOption>({
isModalShowing: false, //防止有多个登录弹窗打开
},
async onLaunch(props: any) {
// 非测试环境在 PC 端打开时提示无法使用
if (!isTestDomain() && isPCEnvironment()) {
wx.showModal({
title: "提示",
content: "该环境无法使用",
showCancel: false,
confirmText: "我知道了"
});
return;
}
wx.removeStorageSync("state");
if (props.query.state) {
wx.setStorageSync("state", props.query.state)