feat: R27-2 R27-5 优化企微入口与 Portal 体验
这个提交包含在:
+2
-11
@@ -1,17 +1,10 @@
|
||||
import { registerSW } from "virtual:pwa-register";
|
||||
import { canUseWindow, isEnterpriseMessengerContainer, matchesMedia } from "./lib/runtimeContext";
|
||||
|
||||
const MOBILE_APPROVAL_TASK_PATH = /^\/workflow\/tasks\/([^/]+)$/i;
|
||||
const OFFLINE_ALLOWED_PATHS = ["/mobile/approvals"];
|
||||
const RUNTIME_CACHE_NAMES = ["app-api-runtime"];
|
||||
|
||||
function canUseWindow() {
|
||||
return typeof window !== "undefined";
|
||||
}
|
||||
|
||||
function matchesMedia(query: string) {
|
||||
return canUseWindow() && typeof window.matchMedia === "function" && window.matchMedia(query).matches;
|
||||
}
|
||||
|
||||
export function registerPwaIfEnabled() {
|
||||
if (import.meta.env.DEV) {
|
||||
return;
|
||||
@@ -59,12 +52,10 @@ export function shouldPreferMobileApprovalExperience() {
|
||||
return false;
|
||||
}
|
||||
|
||||
const userAgent = window.navigator.userAgent.toLowerCase();
|
||||
const isStandalone = matchesMedia("(display-mode: standalone)") || (window.navigator as Navigator & { standalone?: boolean }).standalone === true;
|
||||
const isImContainer = /(wxwork|wecom|wechatwork|dingtalk|aliapp\(dingtalk\))/i.test(userAgent);
|
||||
const isTouchSmallScreen = window.navigator.maxTouchPoints > 0 && matchesMedia("(max-width: 1024px)");
|
||||
|
||||
return isStandalone || isImContainer || isTouchSmallScreen;
|
||||
return isStandalone || isEnterpriseMessengerContainer() || isTouchSmallScreen;
|
||||
}
|
||||
|
||||
export async function clearPwaRuntimeCaches() {
|
||||
|
||||
在新工单中引用
屏蔽一个用户