xp-forge/htmx

为 XP 网页前端提供 HTMX 集成

v0.3.0 2024-03-29 12:02 UTC

This package is auto-updated.

Last update: 2024-08-29 13:24:55 UTC


README

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.4+ Supports PHP 8.0+ Latest Stable Version

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();
  }
});