feat(user-center): redesign sidebar and wallet tips

This commit is contained in:
kate522 committed 2026-07-28 13:41:00 +08:00
1 parent 82e71d1bf9
commit a7f3caec59
24 files changed
+895 -528

No files matched your search

@@ -1,36 +1,89 @@
<?php
/**
* User center sidebar: main service navigation.
*
* Expects extracted $context vars.
* User center sidebar: services and account settings.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('我的服务', 'aksrt'); ?></div>
<div class="uc-sidebar__buttons">
<?php foreach ($dashboard_tabs as $tab_key => $tab) :
// VIP / 订单 only under 权益与消费 (sidebar-commerce), not duplicated here.
if (in_array((string) $tab_key, ['vip', 'orders'], true)) {
continue;
}
?>
<a class="uc-sidebar__btn<?php echo $active_tab === $tab_key ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url($tab_key)); ?>" data-tab="<?php echo esc_attr($tab_key); ?>">
<i class="fas fa-<?php echo esc_attr($tab['icon']); ?>" aria-hidden="true"></i>
<span><?php echo esc_html($tab['label']); ?></span>
$cart_url = function_exists('aksrt_get_cart_page_url') ? aksrt_get_cart_page_url() : '';
$level_url = isset($dashboard_tabs['credits'])
? add_query_arg('asset_tab', 'points', aksrt_get_user_center_tab_url('credits'))
: '';
$auth_url = function_exists('aksrt_get_page_url_by_template')
? aksrt_get_page_url_by_template('templates/pages/page-user-auth.php')
: '';
$services = array_values(array_filter([
[
'label' => __('购物车', 'aksrt'),
'icon' => 'shopping-cart',
'tone' => 'cart',
'url' => $cart_url,
],
[
'label' => __('我的等级', 'aksrt'),
'icon' => 'chart-line',
'tone' => 'level',
'url' => $level_url,
],
[
'label' => __('官方认证', 'aksrt'),
'icon' => 'id-badge',
'tone' => 'auth',
'url' => $auth_url,
],
], static fn(array $item): bool => (string) $item['url'] !== ''));
$settings = array_values(array_filter([
[
'label' => __('消息通知', 'aksrt'),
'icon' => 'bell',
'tone' => 'notice',
'url' => (string) ($messages_url ?? ''),
'count' => (int) ($notification_unread_count ?? 0),
],
[
'label' => __('个人资料', 'aksrt'),
'icon' => 'user-edit',
'tone' => 'profile',
'url' => isset($dashboard_tabs['profile']) ? aksrt_get_user_center_tab_url('profile') : '',
],
[
'label' => __('账户安全', 'aksrt'),
'icon' => 'shield-alt',
'tone' => 'security',
'url' => isset($dashboard_tabs['settings']) ? aksrt_get_user_center_tab_url('settings') : '',
],
], static fn(array $item): bool => (string) $item['url'] !== ''));
$render_grid = static function (array $items): void {
?>
<div class="uc-service-grid">
<?php foreach ($items as $item) : ?>
<a class="uc-service-grid__item uc-service-grid__item--<?php echo esc_attr((string) $item['tone']); ?>" href="<?php echo esc_url((string) $item['url']); ?>">
<span class="uc-service-grid__icon">
<i class="fas fa-<?php echo esc_attr((string) $item['icon']); ?>" aria-hidden="true"></i>
<?php if (!empty($item['count'])) : ?><small><?php echo esc_html((string) $item['count']); ?></small><?php endif; ?>
</span>
<span><?php echo esc_html((string) $item['label']); ?></span>
</a>
<?php endforeach; ?>
<?php if (!empty($messages_url)) : ?>
<a href="<?php echo esc_url($messages_url); ?>" class="uc-sidebar__btn">
<i class="fas fa-bell" aria-hidden="true"></i>
<span><?php esc_html_e('消息通知', 'aksrt'); ?></span>
<?php if ($notification_unread_count > 0) : ?>
<span class="uc-sidebar__badge"><?php echo esc_html((string) $notification_unread_count); ?></span>
<?php endif; ?>
</a>
<?php endif; ?>
</div>
<?php
};
?>
<?php if ($services) : ?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__heading"><span><?php esc_html_e('我的服务', 'aksrt'); ?></span></div>
<?php $render_grid($services); ?>
</div>
<?php endif; ?>
<?php if ($settings) : ?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__heading"><span><?php esc_html_e('功能设置', 'aksrt'); ?></span></div>
<?php $render_grid($settings); ?>
</div>
<?php endif; ?>