perf(modal): unify cancellable frontend modal flows
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
25ce1d8f43
commit
5375ad6429
36 files changed
+2623
-1806
No files matched your search
@@ -11,22 +11,35 @@ use AKSRT\User\AuthApply;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
||||
$snapshot = class_exists(AuthApply::class) ? AuthApply::snapshot($user_id) : [
|
||||
'status' => '',
|
||||
'stage' => '',
|
||||
'can_apply' => false,
|
||||
'verified' => false,
|
||||
'info' => [],
|
||||
'apply' => [],
|
||||
'active' => null,
|
||||
'latest' => null,
|
||||
'poll_interval' => 5,
|
||||
];
|
||||
$settings = class_exists(AuthApply::class) ? AuthApply::settings() : ['enabled' => false, 'allow_apply' => false];
|
||||
$status = class_exists(AuthApply::class) ? AuthApply::get_status($user_id) : '';
|
||||
$info = class_exists(AuthApply::class) ? AuthApply::get_auth_info($user_id) : [];
|
||||
$apply = class_exists(AuthApply::class) ? AuthApply::get_apply_payload($user_id) : [];
|
||||
$record = is_array($apply['_application'] ?? null) ? $apply['_application'] : [];
|
||||
$stage = sanitize_key((string) ($record['status'] ?? ''));
|
||||
$locks_application = in_array($stage, ['created', 'provider_pending', 'provider_processing', 'manual_pending'], true);
|
||||
$reason = (string) ($record['review_note'] ?? $record['provider_result_summary'] ?? '');
|
||||
$can_apply = !empty($settings['enabled']) && !empty($settings['allow_apply']) && $status !== 'verified';
|
||||
$status = (string) ($snapshot['status'] ?? '');
|
||||
$info = is_array($snapshot['info'] ?? null) ? $snapshot['info'] : [];
|
||||
$active = is_array($snapshot['active'] ?? null) ? $snapshot['active'] : [];
|
||||
$latest = is_array($snapshot['latest'] ?? null) ? $snapshot['latest'] : [];
|
||||
$stage = sanitize_key((string) ($active['status'] ?? ''));
|
||||
$locks_application = $stage !== '';
|
||||
$reason = (string) (($latest['review_note'] ?? '') ?: ($latest['provider_result_summary'] ?? ''));
|
||||
$can_apply = !empty($snapshot['can_apply']);
|
||||
$config = [
|
||||
'restBase' => untrailingslashit(rest_url('aksrt/v1/identity/applications')),
|
||||
'nonce' => wp_create_nonce('wp_rest'),
|
||||
'currentUuid' => $locks_application ? (string) ($record['application_uuid'] ?? '') : '',
|
||||
'currentUuid' => $locks_application ? (string) ($active['application_uuid'] ?? '') : '',
|
||||
'currentStage' => $locks_application ? $stage : '',
|
||||
'provider' => sanitize_key((string) ($settings['provider'] ?? 'aliyun')),
|
||||
'allowManual' => !empty($settings['allow_manual_fallback']),
|
||||
'pollInterval' => max(5, (int) ($snapshot['poll_interval'] ?? 5)),
|
||||
'snapshot' => class_exists(AuthApply::class) ? AuthApply::snapshot_view($user_id) : [],
|
||||
];
|
||||
?>
|
||||
<div class="aksrt-user-auth-panel uc-auth-panel" data-identity-root data-identity-config="<?php echo esc_attr(wp_json_encode($config)); ?>">
|
||||
@@ -58,12 +71,11 @@ $config = [
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($can_apply) : ?>
|
||||
<div class="aksrt-modal uc-auth-modal" id="uc-auth-modal" aria-hidden="true">
|
||||
<div class="aksrt-modal__overlay" data-auth-modal-close></div>
|
||||
<div class="aksrt-modal__box uc-auth-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="uc-auth-modal-title">
|
||||
<template data-auth-modal-template>
|
||||
<div class="uc-auth-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="uc-auth-modal-title">
|
||||
<div class="aksrt-modal__header uc-auth-modal__header">
|
||||
<div><span><i class="fas fa-id-badge" aria-hidden="true"></i></span><strong id="uc-auth-modal-title"><?php esc_html_e('身份认证', 'aksrt'); ?></strong></div>
|
||||
<button type="button" class="aksrt-modal__close" data-auth-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
|
||||
<button type="button" class="aksrt-modal__close" data-aksrt-modal-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
|
||||
</div>
|
||||
<div class="aksrt-modal__body uc-auth-modal__body">
|
||||
<div data-auth-status <?php echo !$locks_application ? 'hidden' : ''; ?>>
|
||||
@@ -98,6 +110,6 @@ $config = [
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
Reference in new issue
Block a user