feat(users): add inline promotion center

This commit is contained in:
kate522 committed 2026-08-03 13:40:54 +08:00
1 parent aa958c7d01
commit d138c05f77
11 files changed
+76 -88

No files matched your search

+1 -1
View File
@@ -526,7 +526,7 @@ class SchemaUsers {
'option_key' => 'aksrt_settings',
'groups' => [
['key' => 'center', 'title' => '用户中心', 'fields' => [
['key' => 'user_center_tabs', 'label' => '用户中心 Tab', 'type' => 'input', 'default' => 'profile,level,posts,comments,favorites,vip,credits,auth', 'help' => '逗号分隔。level=我的等级;auth=官方认证;等级、VIP、订单和认证会按功能开关自动注入'],
['key' => 'user_center_tabs', 'label' => '用户中心 Tab', 'type' => 'input', 'default' => 'profile,level,posts,comments,favorites,vip,credits,promotion,auth', 'help' => '逗号分隔。level=我的等级;promotion=推广中心;auth=官方认证;等级、VIP、订单、推广中心和认证会按功能开关自动注入'],
['key' => 'user_cover_upload', 'label' => '封面上传', 'type' => 'switch', 'default' => true],
['key' => 'user_social_links', 'label' => '社交链接', 'type' => 'switch', 'default' => true],
['key' => 'user_desc_std', 'label' => '默认签名', 'type' => 'input', 'default' => '这家伙很懒…', 'desc' => '用户未设置个人简介时显示的默认文案'],
+2 -2
View File
@@ -83,14 +83,14 @@ class UserRuntime {
*/
public static function get_user_center_settings(): array {
$settings = Settings::get_all();
$raw_tabs = $settings['user_center_tabs'] ?? 'profile,level,posts,comments,credits,favorites,auth';
$raw_tabs = $settings['user_center_tabs'] ?? 'profile,level,posts,comments,credits,promotion,favorites,auth';
$tabs = is_array($raw_tabs)
? $raw_tabs
: preg_split('/[\s,]+/', (string) $raw_tabs, -1, PREG_SPLIT_NO_EMPTY);
// Built-in switchable panels. VIP is always auto-injected when enabled
// by AKSRT\User\Center — keep it allowed for explicit config too.
$allowed_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'settings'];
$allowed_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'promotion', 'vip', 'orders', 'auth', 'settings'];
$normalized_tabs = ['profile'];
foreach ((array) $tabs as $tab) {
+24
View File
@@ -91,6 +91,12 @@ class Center {
'priority' => 50,
'type' => 'panel',
],
'promotion' => [
'label' => __('推广中心', 'aksrt'),
'icon' => 'user-plus',
'priority' => 55,
'type' => 'panel',
],
'notif' => [
'label' => __('消息通知', 'aksrt'),
'icon' => 'bell',
@@ -121,6 +127,10 @@ class Center {
&& !empty(\AKSRT\User\Level::settings()['enabled']);
$credits_on = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled();
$balance_on = class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
$promotion_on = $credits_on
&& class_exists('\AKSRT\Settings\Settings')
&& \AKSRT\Settings\Settings::invite_enabled()
&& \AKSRT\Settings\Settings::invite_registration_enabled();
$vip_on = class_exists('\AKSRT\Settings\Settings')
&& !empty(\AKSRT\Settings\Settings::get_payment_vip_settings()['enabled']);
@@ -167,6 +177,17 @@ class Center {
if (($credits_on || $balance_on) && !in_array('credits', $order, true)) {
$order[] = 'credits';
}
if ($promotion_on && !in_array('promotion', $order, true)) {
$insert_at = count($order);
foreach (['credits', 'favorites', 'posts'] as $anchor) {
$idx = array_search($anchor, $order, true);
if ($idx !== false) {
$insert_at = (int) $idx + 1;
break;
}
}
array_splice($order, $insert_at, 0, ['promotion']);
}
$auth_on = class_exists('\AKSRT\User\AuthApply')
&& !empty(\AKSRT\User\AuthApply::settings()['enabled']);
if ($auth_on && !in_array('auth', $order, true)) {
@@ -186,6 +207,9 @@ class Center {
if ($key === 'credits' && !$credits_on && !$balance_on) {
continue;
}
if ($key === 'promotion' && !$promotion_on) {
continue;
}
if ($key === 'vip' && !$vip_on) {
continue;
}