dootask/resources/views/download.blade.php
kuaifan 84f225f3f3 feat(mobile): 兼容新 Expo 壳(dootask_expo UA)
配合 dootask-app 仓库的 Expo 迁移(见 docs/migration-eeui-to-expo.md 的 Phase 5),
让服务端和前端同时识别旧 EEUI 壳与新 Expo 壳的 User-Agent,并让 eeui.js 的同步返回
方法在 Expo 壳下优先读取 injectedJS 启动时写入的 __EXPO_INIT_DATA__ / __EXPO_VARIATES__
缓存,避免原本同步 API 变成 Promise 后破坏调用方。

后端:
- Base::isEEUIApp():同时匹配 kuaifan_eeui / dootask_expo
- UserDevice:android_(kuaifan_eeui|dootask_expo) 正则捕获标识段,版本号按实际段名取
- IndexController PDF 预览:浏览器分类兼容 android_dootask_expo / ios_dootask_expo
- SystemController::prefetch:$isApp 同时接受两种 UA
- resources/views/download.blade.php:/eeui|dootask_expo/i

前端:
- app.js:
  - isEEUIApp 正则新增 dootask_expo
  - $preload 等待条件改为 requireModuleJs 可用 OR window.__EXPO_BRIDGE_READY__,
    避免 Expo 壳下等 15 秒超时
- eeui.js:以下几个同步 getter 在 Expo 壳下先读 window.__EXPO_* 再回落到原生:
  - eeuiAppVersion / eeuiAppLocalVersion → __EXPO_INIT_DATA__.version
  - eeuiAppGetPageInfo → __EXPO_INIT_DATA__.pageInfo
  - eeuiAppGetThemeName → __EXPO_INIT_DATA__.themeName
  - eeuiAppKeyboardStatus → __EXPO_INIT_DATA__.keyboardVisible
  - eeuiAppGetVariate → __EXPO_VARIATES__[key]
  - eeuiAppGetCachesString → __EXPO_CACHES__[key](RN 侧后续要同步 broadcast)

旧 EEUI 壳不受影响:只读缓存不存在时自动回落到原有 $A.eeuiModule() 调用,
行为与改动前一致。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 09:44:53 +00:00

99 lines
2.7 KiB
PHP
Executable File

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta name="format-detection" content="telephone=no"/>
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ $name }} - {{ $system_alias }}</title>
<link rel="shortcut icon" href="{{ asset_main('favicon.ico') }}">
<style>
* {
margin: 0;
padding: 0;
}
body {
font-size: 14px;
}
.down {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #000;
color: #fff;
padding: 16px 18px;
border-radius: 12px;;
max-width: calc(100% - 160px);
}
.title {
font-size: 18px;
}
.link {
margin-top: 10px;
display: block;
height: 30px;
line-height: 30px;
padding: 0 12px;
text-align: center;
background-color: #f60;
color: #fff;
text-decoration: none;
border-radius: 5px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.dark {
.down {
background-color: #ffffff;
color: #555;
}
}
</style>
</head>
<body>
<div class="down">
<div class="title">{{ $name }}</div>
<a class="link" href="{{ $url }}" target="_blank">{{$button}} ({{ $size }})</a>
</div>
<script>
let themeConf = window.localStorage.getItem("__system:themeConf__");
if (themeConf === 'auto') {
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
themeConf = 'dark';
}
}
if (themeConf === 'dark') {
document.body.classList.add("dark");
}
//
const isEEUIApp = window && window.navigator && /eeui|dootask_expo/i.test(window.navigator.userAgent);
if (isEEUIApp) {
document.querySelector(".link").addEventListener('click', function (e) {
e.preventDefault();
window.top.postMessage({
action: "eeuiAppSendMessage",
data: [
{
action: 'openUrl',
url: "{{ $url }}",
}
]
}, "*")
});
}
</script>
</body>
</html>