xp-forge / htmx
为 XP 网页前端提供 HTMX 集成
v0.3.0
2024-03-29 12:02 UTC
Requires
- php: >=7.4.0
- xp-forge/frontend: ^6.0 | ^5.0
- xp-forge/web-auth: ^5.0 | ^4.0 | ^3.7
- xp-framework/core: ^12.0 | ^11.0 | ^10.0
Requires (Dev)
- xp-framework/test: ^2.0 | ^1.0
README
HTMX 集成
身份验证
将任何身份验证流程包裹在 HtmxFlow 中,以确保身份验证不会进行重定向,而是返回一个错误代码并触发一个事件
+ use web\frontend\HtmxFlow; - $auth= new SessionBased($flow, $sessions); + $auth= new SessionBased(new HtmxFlow($flow), $sessions);
可以在 JavaScript 中通过以下方式处理:
window.addEventListener('authenticationexpired', e => { if (confirm('Authentication expired. Do you want to re-authenticate?')) { window.location.reload(); } });