feat(user-center): promote invite into standalone 推广中心 tab
Register a dedicated `promotion` dashboard panel gated by the existing invite switches (credits + invite reward + invite registration), and move the invite card out of the revenue tab so 收益中心 is pure earnings/withdrawal. - src/User/Center.php: register promotion panel; revenue no longer depends on invite being on - inc/helpers/user-center-renderers/profile-promotion.php: new panel body hosting the existing [data-aksrt-invite] card - profile-revenue.php: drop the invite section; aksrt-user-center.php: drop unused show_invite_section context, add promotion to built-in tabs + view map - repoint invite/promotion deep-link aliases from revenue to promotion across tab-url builder, tab resolver, runtime tabAliases, urls.php, and the revenue-JS enqueue gate - sidebar-nav.php: add 推广中心 service entry; shell.css: entry icon color; sidebar-creator.php: reword revenue card - UserRuntime.php: allow promotion in configurable tabs
This commit is contained in:
1 parent
644bafb35c
commit
51274fd00a
10 files changed
+69
-21
No files matched your search
@@ -104,7 +104,7 @@ if (!function_exists('aksrt_get_user_center_tab_url')) {
|
||||
function aksrt_get_user_center_tab_url(string $tab): string {
|
||||
$tab = sanitize_key($tab);
|
||||
if ('invite' === $tab || 'promotion' === $tab) {
|
||||
$tab = 'revenue';
|
||||
$tab = 'promotion';
|
||||
}
|
||||
$url = remove_query_arg([
|
||||
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
|
||||
@@ -154,6 +154,7 @@ if (!function_exists('aksrt_capture_user_center_view')) {
|
||||
'vip' => 'vip',
|
||||
'orders' => 'orders',
|
||||
'auth' => 'auth',
|
||||
'promotion' => 'promotion',
|
||||
'revenue' => 'revenue',
|
||||
'settings' => 'settings',
|
||||
'header' => 'header',
|
||||
@@ -179,7 +180,7 @@ if (!function_exists('aksrt_capture_user_center_panel')) {
|
||||
* Capture a built-in or registered user-center panel body.
|
||||
*/
|
||||
function aksrt_capture_user_center_panel(string $tab_key, array $tab, array $context): string {
|
||||
$built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
|
||||
$built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'promotion', 'revenue', 'settings'];
|
||||
if (in_array($tab_key, $built_in_tabs, true)) {
|
||||
return aksrt_capture_user_center_view($tab_key, $context);
|
||||
}
|
||||
@@ -287,7 +288,7 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
|
||||
if ('signin' === $active || 'assets' === $active) {
|
||||
$active = 'credits';
|
||||
} elseif ('invite' === $active || 'promotion' === $active) {
|
||||
$active = 'revenue';
|
||||
$active = 'promotion';
|
||||
} elseif ('vip' === $active) {
|
||||
// Prefer dedicated vip tab when registered; else credits (VIP shop).
|
||||
$active = in_array('vip', $keys, true) ? 'vip' : 'credits';
|
||||
@@ -346,8 +347,8 @@ if (!function_exists('aksrt_user_center_runtime_config')) {
|
||||
'activeTab' => $active_tab,
|
||||
'tabAliases' => [
|
||||
'signin' => 'credits',
|
||||
'invite' => 'revenue',
|
||||
'promotion' => 'revenue',
|
||||
'invite' => 'promotion',
|
||||
'promotion' => 'promotion',
|
||||
'assets' => 'credits',
|
||||
// vip → vip when panel exists; SPA may still map missing keys via server resolve.
|
||||
'vip' => 'vip',
|
||||
@@ -494,10 +495,6 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
|
||||
$runtime_config = aksrt_user_center_runtime_config($user_id, $tabs['default'], $active_tab, $tabs['urls']);
|
||||
$runtime_config['avatarUpload'] = aksrt_user_center_avatar_upload_config($allow_avatar_upload);
|
||||
$revenue_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_revenue_settings() : [];
|
||||
$show_invite_section = $show_credit_tabs
|
||||
&& class_exists('\AKSRT\Settings\Settings')
|
||||
&& \AKSRT\Settings\Settings::invite_enabled()
|
||||
&& \AKSRT\Settings\Settings::invite_registration_enabled();
|
||||
$show_revenue_section = !empty($revenue_settings['enabled']) || !empty($affiliate_settings['enabled']);
|
||||
$new_post_url = function_exists('aksrt_get_new_post_url') ? aksrt_get_new_post_url() : '';
|
||||
$revenue_url = isset($tabs['tabs']['revenue'])
|
||||
@@ -549,7 +546,6 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
|
||||
'balance_enabled' => $balance_enabled,
|
||||
'wallet_balance' => $wallet_balance,
|
||||
'vip_settings' => $vip_settings,
|
||||
'show_invite_section' => $show_invite_section,
|
||||
'user_email' => (string) $current_user->user_email,
|
||||
'runtime_config' => $runtime_config,
|
||||
'cover_upload_config' => aksrt_user_center_cover_upload_config($allow_bg_upload),
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* User center promotion panel (invite / 推广中心).
|
||||
*
|
||||
* Standalone dashboard tab that hosts the invite card. Reuses the existing
|
||||
* invite REST contract and credits.js `initInvite()` binding via the
|
||||
* `[data-aksrt-invite]` card in profile-invite.php.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
||||
if ($user_id <= 0) {
|
||||
echo '<div class="uc-panel-empty muted-2-color">' . esc_html__('请先登录', 'aksrt') . '</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
$currency_name = (string) ($context['currency_name'] ?? __('积分', 'aksrt'));
|
||||
?>
|
||||
<div class="uc-promotion-page" data-aksrt-promotion-page>
|
||||
<?php require __DIR__ . '/profile-invite.php'; ?>
|
||||
</div>
|
||||
@@ -15,7 +15,6 @@ if ($user_id <= 0) {
|
||||
}
|
||||
|
||||
$show_revenue_section = !empty($context['show_revenue_section']);
|
||||
$show_invite_section = !empty($context['show_invite_section']);
|
||||
$revenue_view = function_exists('aksrt_get_revenue_page_view')
|
||||
? aksrt_get_revenue_page_view($user_id)
|
||||
: ['balance' => 0, 'total_earned' => 0, 'total_withdrawn' => 0, 'records' => []];
|
||||
@@ -59,6 +58,4 @@ $revenue_url = static function (int $target_page): string {
|
||||
<section class="aksrt-revenue-page__section"><h3><?php esc_html_e('收益明细', 'aksrt'); ?></h3><?php if ($paged_records) : ?><div class="aksrt-revenue-page__list"><?php foreach ($paged_records as $record) : ?><div class="aksrt-revenue-page__item"><div><strong><?php echo esc_html((string) ($record['title'] ?? '')); ?></strong><time><?php echo esc_html((string) ($record['created_at'] ?? '')); ?></time></div><span class="<?php echo ($record['type'] ?? '') === 'withdrawal' ? 'is-out' : 'is-in'; ?>"><?php echo ($record['type'] ?? '') === 'withdrawal' ? '-' : '+'; ?>¥<?php echo esc_html(number_format_i18n((float) ($record['amount'] ?? 0), 2)); ?></span></div><?php endforeach; ?></div><?php if ($total_pages > 1) : ?><nav class="aksrt-revenue-page__pagination" aria-label="<?php esc_attr_e('收益分页', 'aksrt'); ?>"><?php for ($index = 1; $index <= $total_pages; $index++) : ?><a class="aksrt-revenue-page__page-chip<?php echo $index === $page ? ' is-active' : ''; ?>" href="<?php echo esc_url($revenue_url($index)); ?>"><?php echo esc_html((string) $index); ?></a><?php endfor; ?></nav><?php endif; ?><?php else : ?><p class="aksrt-revenue-page__empty"><?php esc_html_e('暂无收益明细', 'aksrt'); ?></p><?php endif; ?></section>
|
||||
</section>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ($show_invite_section) : require __DIR__ . '/profile-invite.php'; endif; ?>
|
||||
</div>
|
||||
@@ -28,7 +28,7 @@ if ($creation_url === '' && $revenue_url === '') {
|
||||
<?php if ($revenue_url !== '') : ?>
|
||||
<a class="uc-center-card uc-center-card--revenue" href="<?php echo esc_url($revenue_url); ?>">
|
||||
<span class="uc-center-card__icon"><i class="fas fa-chart-line" aria-hidden="true"></i></span>
|
||||
<span><strong><?php esc_html_e('收益中心', 'aksrt'); ?></strong><small><?php esc_html_e('邀请、返佣与收益', 'aksrt'); ?></small></span>
|
||||
<span><strong><?php esc_html_e('收益中心', 'aksrt'); ?></strong><small><?php esc_html_e('返佣与收益提现', 'aksrt'); ?></small></span>
|
||||
<i class="fas fa-angle-right" aria-hidden="true"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -11,6 +11,7 @@ $level_url = isset($dashboard_tabs['level'])
|
||||
? aksrt_get_user_center_tab_url('level')
|
||||
: '';
|
||||
$auth_url = isset($dashboard_tabs['auth']) ? aksrt_get_user_center_tab_url('auth') : '';
|
||||
$promotion_url = isset($dashboard_tabs['promotion']) ? aksrt_get_user_center_tab_url('promotion') : '';
|
||||
$orders_available = isset($dashboard_tabs['orders']);
|
||||
$orders_url = $orders_available ? (string) ($orders_url ?? '') : '';
|
||||
|
||||
@@ -21,6 +22,13 @@ $services = array_values(array_filter([
|
||||
'tone' => 'level',
|
||||
'url' => $level_url,
|
||||
],
|
||||
[
|
||||
'label' => __('推广中心', 'aksrt'),
|
||||
'icon' => 'bullhorn',
|
||||
'tone' => 'promotion',
|
||||
'url' => $promotion_url,
|
||||
'tab' => 'promotion',
|
||||
],
|
||||
[
|
||||
'label' => __('官方认证', 'aksrt'),
|
||||
'icon' => 'id-badge',
|
||||
|
||||
@@ -32,8 +32,8 @@ function aksrt_get_user_center_url(string $tab = ''): string {
|
||||
'assets' => 'credits',
|
||||
'vip' => 'vip', // dedicated vip tab when registered; resolver falls back if missing
|
||||
'signin' => 'credits',
|
||||
'invite' => 'revenue',
|
||||
'promotion' => 'revenue',
|
||||
'invite' => 'promotion',
|
||||
'promotion' => 'promotion',
|
||||
];
|
||||
if (isset($aliases[$tab])) {
|
||||
$tab = $aliases[$tab];
|
||||
|
||||
Reference in new issue
Block a user