fix(user-home): add reference tab loading skeletons
This commit is contained in:
1 parent
4c6b02a6b9
commit
5a17b399a0
7 files changed
+166
-12
No files matched your search
@@ -71,9 +71,14 @@ require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
|
||||
if (!locate_template(['templates/parts/user-home/panel-' . $panel_tab . '.php'], false, false)) {
|
||||
continue;
|
||||
}
|
||||
$defer_panel = in_array($panel_tab, ['favorites', 'follow'], true) && $panel_tab !== $active_tab;
|
||||
$panel_context = $ctx;
|
||||
if ($defer_panel) {
|
||||
$panel_context['placeholder_only'] = true;
|
||||
}
|
||||
?>
|
||||
<div id="panel-<?php echo esc_attr($panel_tab); ?>" class="dashboard-panel<?php echo $panel_tab === $active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo $panel_tab !== $active_tab ? ' hidden' : ''; ?>>
|
||||
<?php get_template_part('templates/parts/user-home/panel', $panel_tab, $ctx); ?>
|
||||
<div id="panel-<?php echo esc_attr($panel_tab); ?>" class="dashboard-panel<?php echo $panel_tab === $active_tab ? ' is-active' : ''; ?>" role="tabpanel" data-panel-loaded="<?php echo $defer_panel ? 'false' : 'true'; ?>"<?php echo $panel_tab !== $active_tab ? ' hidden' : ''; ?>>
|
||||
<?php get_template_part('templates/parts/user-home/panel', $panel_tab, $panel_context); ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
@@ -14,15 +14,34 @@ defined('ABSPATH') || exit;
|
||||
$args = is_array($args ?? null) ? $args : [];
|
||||
extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
|
||||
if (!empty($favorite_post_ids)) :
|
||||
$user_home_render_config = aksrt_resolve_post_list_render_config([
|
||||
'context' => 'author',
|
||||
'overrides' => [
|
||||
'no_author' => true,
|
||||
'no_margin' => true,
|
||||
],
|
||||
]);
|
||||
$user_home_render_config = aksrt_resolve_post_list_render_config([
|
||||
'context' => 'author',
|
||||
'overrides' => [
|
||||
'no_author' => true,
|
||||
'no_margin' => true,
|
||||
],
|
||||
]);
|
||||
|
||||
if (!empty($placeholder_only)) {
|
||||
$placeholder_mode = (string) ($user_home_render_config['mode'] ?? 'list');
|
||||
$placeholder_html = function_exists('aksrt_render_placeholder')
|
||||
? aksrt_render_placeholder($placeholder_mode, 4)
|
||||
: '';
|
||||
?>
|
||||
<div class="posts-row ajaxpager aksrt-user-home__post-list" data-view="<?php echo esc_attr($placeholder_mode); ?>">
|
||||
<div class="post_ajax_loader" role="status" aria-label="<?php esc_attr_e('正在加载', 'aksrt'); ?>">
|
||||
<?php echo $placeholder_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- 固定文章骨架由 aksrt_render_placeholder() 输出。 ?>
|
||||
</div>
|
||||
<div class="uh-panel-load-error" role="alert">
|
||||
<span><?php esc_html_e('加载失败,请重试', 'aksrt'); ?></span>
|
||||
<button type="button" data-uh-retry><?php esc_html_e('重试', 'aksrt'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return;
|
||||
}
|
||||
|
||||
if (!empty($favorite_post_ids)) :
|
||||
$favorites_query = new WP_Query([
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish',
|
||||
|
||||
@@ -21,6 +21,17 @@ extract($args, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_ext
|
||||
$follow_page = max(1, (int) ($follow_page ?? 1));
|
||||
$follow_sub = in_array($follow_sub ?? 'followers', ['following', 'followers'], true) ? $follow_sub : 'followers';
|
||||
|
||||
if (!empty($placeholder_only)) :
|
||||
?>
|
||||
<?php echo aksrt_get_user_home_follow_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- 固定骨架由本主题 helper 输出。 ?>
|
||||
<div class="uh-panel-load-error" role="alert">
|
||||
<span><?php esc_html_e('加载失败,请重试', 'aksrt'); ?></span>
|
||||
<button type="button" data-uh-retry><?php esc_html_e('重试', 'aksrt'); ?></button>
|
||||
</div>
|
||||
<?php
|
||||
return;
|
||||
endif;
|
||||
|
||||
$follow_instance = class_exists('\AKSRT\User\Follow') ? \AKSRT\User\Follow::get_instance() : null;
|
||||
$following_count = $follow_instance ? (int) $follow_instance->get_following_count((int) $user_id) : 0;
|
||||
$follower_count = $follow_instance ? (int) $follow_instance->get_follower_count((int) $user_id) : 0;
|
||||
@@ -63,3 +74,4 @@ $total_pages = max(1, (int) ($list['total_pages'] ?? 1));
|
||||
aksrt_render_profile_empty($svg_empty_follow ?? $svg_empty_post ?? '', $empty_msg);
|
||||
?>
|
||||
<?php endif; ?>
|
||||
<?php echo aksrt_get_user_home_follow_placeholder(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- 固定骨架由本主题 helper 输出。 ?>
|
||||
Reference in new issue
Block a user