
<?php

class WP_File_Manager_Pro_Admin {
public function add_admin_page() {
add_menu_page(
__('文件管理器', 'wp-file-manager-pro'),
__('文件管理', 'wp-file-manager-pro'),
'manage_options',
'wp-file-manager-pro',
[$this, 'render_admin_page'],
'dashicons-media-archive',
75
);
}

public function enqueue_assets($hook) {
    if ($hook !== 'toplevel_page_wp-file-manager-pro') return;
    
    wp_enqueue_script('fm-pro-main', plugins_url('assets/js/main.js', __FILE__), ['jquery'], '2.0.0', true);
    wp_enqueue_style('fm-pro-style', plugins_url('assets/css/style.css', __FILE__), [], '2.0.0');
    
    wp_localize_script('fm-pro-main', 'fmPro', [
        'ajaxurl' => admin_url('admin-ajax.php'),
        'nonce' => wp_create_nonce('fm-pro-security'),
        'i18n' => [
            'uploading' => __('上传中...', 'wp-file-manager-pro'),
            'loading' => __('加载中...', 'wp-file-manager-pro'),
            'error' => __('发生错误', 'wp-file-manager-pro')
        ]
    ]);
}

public function render_admin_page() {
    echo '<div class="wrap fm-pro-wrapper">
        <h1>'.esc_html__('WordPress文件管理器', 'wp-file-manager-pro').'</h1>
        <div class="fm-pro-container">
            <div class="fm-pro-toolbar">
                <button class="button button-primary fm-pro-refresh">'.__('刷新', 'wp-file-manager-pro').'</button>
                <button class="button fm-pro-upload">'.__('上传', 'wp-file-manager-pro').'</button>
                <button class="button fm-pro-new-folder">'.__('新建文件夹', 'wp-file-manager-pro').'</button>
            </div>
            <div class="fm-pro-breadcrumb" id="fm-pro-breadcrumb"></div>
            <div class="fm-pro-contents" id="fm-pro-contents"></div>
            <div class="fm-pro-status-bar"></div>
        </div>
    </div>';
}
