feat: 添加小程序 web-view Token 传递问题分析与修复方案,更新 H5 端 URL 验证逻辑

This commit is contained in:
2026-05-27 03:44:44 +08:00
parent 6dc6258c19
commit 8c50afc120
4 changed files with 159 additions and 5 deletions

View File

@@ -10,6 +10,22 @@
<body>
<script>window.__INITIAL_URL__ = document.URL;</script>
<!-- 🐞 原始 URL 验证 -->
<div id="url-check" style="display:none" data-url=""></div>
<script>
var u = document.URL;
document.getElementById('url-check').setAttribute('data-url', u);
console.log('[URL_CHECK] document.URL:', u);
console.log('[URL_CHECK] search:', location.search);
console.log('[URL_CHECK] has_token:', location.search.includes('token='));
// 如果没 token,在页面顶部写一行红色提示
if (!location.search.includes('token=')) {
var d = document.createElement('div');
d.style.cssText = 'position:fixed;top:0;left:0;right:0;z-index:99999;background:red;color:white;padding:10px;font-size:14px;text-align:center';
d.textContent = '⚠️ URL无token: search=[' + location.search + '] url=' + u.substring(0, 80);
document.body.prepend(d);
}
</script>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>