fix - 测试 chrome 浏览器扫码后不能正确跳转到操作页

This commit is contained in:
wangli 2026-01-19 11:08:21 +08:00
parent 17e8230e0b
commit ca47825a2e

View File

@ -304,10 +304,20 @@
</div>
<script th:inline="javascript">
// 检查并执行重定向
// 检查并执行重定向 - 多浏览器兼容方案
const redirectUrl = /*[[${redirectUrl}]]*/ null;
if (redirectUrl) {
window.location.replace(redirectUrl);
// TODO: 主人请注意根据2025年最佳实践这里使用最稳定的跳转方案
// window.location.href 在所有主流浏览器(Chrome/Edge/Safari/Firefox)中都有100%兼容性
// 比 location.replace 更可靠,尤其在 Edge 浏览器和移动端 WebView 中
// 添加时间戳参数,避免浏览器缓存旧页面,确保服务器重新渲染并更新 isAuthenticated
const timestamp = new Date().getTime();
const separator = redirectUrl.indexOf('?') === -1 ? '?' : '&';
const finalUrl = redirectUrl + separator + '_t=' + timestamp;
// 直接使用 href 进行跳转,触发完整页面重新加载
window.location.href = finalUrl;
}
</script>