<?php
/**
 * HuSNS - 一款免费开源的社交平台
 * 
 * @author  HYR
 * @QQ      281900864
 * @website https://huyourui.com
 * @license MIT
 * @声明    严禁用于违法违规用途
 */
// $userId 由控制器传入，表示当前登录用户ID（用于 checkLogin() 判断）
// $targetUserId 由控制器传入，表示目标用户ID（用于显示谁的主页）
$currentPage = 'user';
$pageType = 'user';
$bodyClass = 'user-page';
$hideTabBar = true;
$showBack = true;
$headerTitle = '用户主页';
$username = isset($username) ? $username : '';

// 页面特定CSS和JS文件
$pageCssFiles = [
    $this->themeUrl() . '/app/css/styles.css',
    $this->themeUrl() . '/app/css/user.css'
];
$pageJsFiles = [
    $this->themeUrl() . '/app/js/utils.js',
    $this->themeUrl() . '/app/js/post-card.js',
    $this->themeUrl() . '/app/js/post-actions.js',
    $this->themeUrl() . '/app/js/user.js'
];

$this->assign('pageCssFiles', $pageCssFiles);
$this->assign('pageJsFiles', $pageJsFiles);

$this->setLayout('app');
?>

<!-- 配置参数 -->
<script>
var THEME_URL = '<?php echo $this->themeUrl(); ?>';
window.HuSNS_User = {
    apiUrls: {
        userProfile: '/?r=mobileApi/userProfile',
        userPosts: '/?r=mobileApi/userPosts',
        userComments: '/?r=mobileApi/userComments',
        userFavorites: '/?r=mobileApi/userFavorites',
        follow: '/?r=mobileApi/follow',
        unfollow: '/?r=mobileApi/unfollow',
        like: '<?php echo $this->url('mobileApi/like'); ?>',
        unlike: '<?php echo $this->url('mobileApi/unlike'); ?>'
    },
    themeUrl: '<?php echo $this->themeUrl(); ?>',
    baseUrl: '<?php echo Helper::getBaseUrl(); ?>',
    targetUserId: <?php echo intval($targetUserId ?? 0); ?>,
    currentUserId: <?php echo isset($userId) && $userId ? intval($userId) : 0; ?>,
    targetUsername: '<?php echo $username ?? ''; ?>',
    tab: '<?php echo $tab ?? 'posts'; ?>',
    settings: {
        messageEnabled: <?php echo (int)Setting::get('mobile_message_enabled', 1); ?>,
        favoriteEnabled: <?php echo (int)Setting::get('mobile_favorite_enabled', 1); ?>
    }
};
</script>

<div class="user-page-content">
    <!-- 用户资料将通过 JavaScript 动态加载 -->
    <div class="loading-state">
        <div class="loading-spinner"></div>
        <div class="loading-text">加载中...</div>
    </div>
</div>