(function($) {
    // 危险文件扩展名
    const DANGEROUS_EXTENSIONS = [
        // 可执行文件
        'exe', 'bat', 'cmd', 'sh', 'bash', 'jar', 'msi', 'app', 'dmg',
        // 脚本文件
        'php', 'asp', 'aspx', 'jsp', 'js', 'vbs', 'py', 'pl', 'cgi',
        // 系统文件
        'dll', 'sys', 'drv', 'ocx', 'scr',
        // 其他危险文件
        'html', 'htm', 'xhtml', 'svg', 'swf', 'reg'
    ];

    // 文件类型图标映射
    const FILE_ICONS = {
        // 图片
        'image/jpeg': 'fa-file-image',
        'image/png': 'fa-file-image',
        'image/gif': 'fa-file-image',
        'image/bmp': 'fa-file-image',
        'image/svg+xml': 'fa-file-image',
        'image/webp': 'fa-file-image',

        // 文档
        'application/pdf': 'fa-file-pdf',
        'application/msword': 'fa-file-word',
        'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'fa-file-word',
        'application/vnd.ms-excel': 'fa-file-excel',
        'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'fa-file-excel',
        'application/vnd.ms-powerpoint': 'fa-file-powerpoint',
        'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'fa-file-powerpoint',
        'text/plain': 'fa-file-text',
        'text/html': 'fa-file-code',
        'text/css': 'fa-file-code',
        'application/json': 'fa-file-code',
        'application/javascript': 'fa-file-code',

        // 压缩文件
        'application/zip': 'fa-file-archive',
        'application/x-rar-compressed': 'fa-file-archive',
        'application/x-7z-compressed': 'fa-file-archive',
        'application/x-tar': 'fa-file-archive',
        'application/gzip': 'fa-file-archive',

        // 音视频
        'audio/mpeg': 'fa-file-audio',
        'audio/wav': 'fa-file-audio',
        'audio/ogg': 'fa-file-audio',
        'video/mp4': 'fa-file-video',
        'video/avi': 'fa-file-video',
        'video/mpeg': 'fa-file-video',
        'video/quicktime': 'fa-file-video',

        // 默认
        'default': 'fa-file'
    };

    // 文件上传插件类
    class FileUploader {
        constructor(options = {}) {
            this.options = $.extend({
                uploadUrl: '/api/upload',
                maxConcurrent: 3, // 最大并发上传数
                chunkSize: 1024 * 1024, // 分片大小（1MB）
                autoStart: false,
                onProgress: null,
                onComplete: null,
                onError: null
            }, options);

            // 文件队列
            this.queue = [];
            this.uploading = [];
            this.completed = [];
            this.failed = [];

            // 统计信息
            this.stats = {
                total: 0,
                queued: 0,
                uploading: 0,
                success: 0,
                failed: 0,
                speed: 0,
                totalSize: 0,
                uploadedSize: 0
            };

            // 速度计算
            this.speedCalculator = {
                startTime: null,
                lastBytes: 0,
                lastTime: null,
                speeds: []
            };

            this.isUploading = false;
            this.paused = false;

            this.initElements();
            this.bindEvents();
            this.updateStats();
        }

        initElements() {
            this.$uploadBox = $('#uploadBox');
            this.$fileInput = $('#fileInput');
            this.$selectFilesBtn = $('#selectFilesBtn');
            this.$queueList = $('#queueList');
            this.$emptyQueue = $('#emptyQueue');

            // 统计元素
            this.$queuedCount = $('#queuedCount');
            this.$uploadingCount = $('#uploadingCount');
            this.$uploadSpeed = $('#uploadSpeed');
            this.$totalCount = $('#totalCount');
            this.$successCount = $('#successCount');
            this.$failedCount = $('#failedCount');

            // 操作按钮
            this.$startUploadBtn = $('#startUploadBtn');
            this.$pauseAllBtn = $('#pauseAllBtn');
            this.$resumeAllBtn = $('#resumeAllBtn');
            this.$clearAllBtn = $('#clearAllBtn');
        }

        bindEvents() {
            // 点击选择文件按钮
            this.$selectFilesBtn.on('click', () => {
                this.$fileInput.click();
            });

            // 文件选择变化
            this.$fileInput.on('change', (e) => {
                this.handleFiles(e.target.files);
                e.target.value = ''; // 重置input
            });

            // 拖拽上传
            this.$uploadBox.on('dragover', (e) => {
                e.preventDefault();
                e.stopPropagation();
                this.$uploadBox.addClass('dragover');
            });

            this.$uploadBox.on('dragleave', (e) => {
                e.preventDefault();
                e.stopPropagation();
                this.$uploadBox.removeClass('dragover');
            });

            this.$uploadBox.on('drop', (e) => {
                e.preventDefault();
                e.stopPropagation();
                this.$uploadBox.removeClass('dragover');

                const files = e.originalEvent.dataTransfer.files;
                this.handleFiles(files);
            });

            // 点击上传区域
            this.$uploadBox.on('click', (e) => {
                if (e.target === this.$uploadBox[0] || e.target.classList.contains('upload-box')) {
                    this.$fileInput.click();
                }
            });

            // 操作按钮事件
            this.$startUploadBtn.on('click', () => this.startUpload());
            this.$pauseAllBtn.on('click', () => this.pauseAll());
            this.$resumeAllBtn.on('click', () => this.resumeAll());
            this.$clearAllBtn.on('click', () => this.clearAll());

            // 初始化速度计算
            this.initSpeedCalculator();
        }

        // 处理选择的文件
        handleFiles(files) {
            if (!files || files.length === 0) return;

            let validFiles = 0;

            for (let i = 0; i < files.length; i++) {
                const file = files[i];

                // 安全检查
                if (!this.isFileSafe(file)) {
                    this.showError(`文件 "${file.name}" 被阻止上传：危险文件类型`);
                    continue;
                }

                // 添加到队列
                this.addToQueue(file);
                validFiles++;
            }

            if (validFiles > 0) {
                this.showMessage(`已添加 ${validFiles} 个文件到上传队列`);
                this.updateQueueDisplay();

                if (this.options.autoStart) {
                    this.startUpload();
                }
            }
        }

        // 安全检查
        isFileSafe(file) {
            const fileName = file.name.toLowerCase();
            const extension = fileName.split('.').pop();

            // 检查扩展名
            if (DANGEROUS_EXTENSIONS.includes(extension)) {
                return false;
            }

            // 检查MIME类型
            const mimeType = file.type.toLowerCase();
            if (mimeType.startsWith('application/x-msdownload') ||
                mimeType.startsWith('application/x-msdos-program') ||
                mimeType.startsWith('application/x-executable') ||
                mimeType.startsWith('application/x-shellscript')) {
                return false;
            }

            // 检查文件名中是否包含可疑模式
            const suspiciousPatterns = [
                /\.(exe|bat|cmd|sh|jar|msi)$/i,
                /^desktop\.ini$/i,
                /^thumbs\.db$/i,
                /\.(php|asp|aspx|jsp)$/i,
                /\.(vbs|js|html)$/i
            ];

            for (const pattern of suspiciousPatterns) {
                if (pattern.test(fileName)) {
                    return false;
                }
            }

            return true;
        }

        // 添加到队列
        addToQueue(file) {
            const fileId = this.generateFileId();
            const fileItem = {
                id: fileId,
                file: file,
                name: file.name,
                size: file.size,
                type: file.type,
                progress: 0,
                status: 'queued', // queued, uploading, success, failed, paused
                speed: 0,
                element: null,
                startTime: null,
                uploadedSize: 0
            };

            this.queue.push(fileItem);
            this.stats.total++;
            this.stats.queued++;
            this.stats.totalSize += file.size;

            this.updateStats();
            return fileId;
        }

        // 生成文件ID
        generateFileId() {
            return 'file_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
        }

        // 更新队列显示
        updateQueueDisplay() {
            if (this.queue.length === 0 && this.uploading.length === 0) {
                this.$emptyQueue.show();
                return;
            }

            this.$emptyQueue.hide();

            // 清空队列列表（除了空状态消息）
            this.$queueList.children().not(this.$emptyQueue).remove();

            // 添加上传中的文件
            this.uploading.forEach(fileItem => {
                this.$queueList.append(this.createQueueItem(fileItem));
            });

            // 添加队列中的文件
            this.queue.forEach(fileItem => {
                this.$queueList.append(this.createQueueItem(fileItem));
            });

            // 添加已完成的文件（最近完成的）
            const recentCompleted = this.completed.slice(-5); // 显示最近5个
            recentCompleted.forEach(fileItem => {
                this.$queueList.append(this.createQueueItem(fileItem));
            });

            // 添加失败的文件（最近失败的）
            const recentFailed = this.failed.slice(-5); // 显示最近5个
            recentFailed.forEach(fileItem => {
                this.$queueList.append(this.createQueueItem(fileItem));
            });
        }

        // 创建队列项
        createQueueItem(fileItem) {
            if (fileItem.element) {
                return fileItem.element;
            }

            const $item = $(`
                <div class="queue-item" data-file-id="${fileItem.id}">
                    <div class="file-icon">
                        <i class="fas ${this.getFileIcon(fileItem.type)}"></i>
                    </div>
                    <div class="file-info">
                        <div class="file-name">${this.escapeHtml(fileItem.name)}</div>
                        <div class="file-size">${this.formatFileSize(fileItem.size)}</div>
                        ${fileItem.status === 'uploading' || fileItem.status === 'success' ? `
                        <div class="progress-container">
                            <div class="progress-bar">
                                <div class="progress-fill" style="width: ${fileItem.progress}%"></div>
                            </div>
                        </div>
                        ` : ''}
                    </div>
                    <div class="file-status status-${fileItem.status}">
                        ${this.getStatusText(fileItem.status)}
                        ${fileItem.status === 'uploading' && fileItem.speed > 0 ? ` (${this.formatSpeed(fileItem.speed)})` : ''}
                    </div>
                    <div class="file-actions">
                        ${fileItem.status === 'queued' ? `
                        <button class="file-action-btn start" title="开始上传">
                            <i class="fas fa-play"></i>
                        </button>
                        ` : ''}
                        ${fileItem.status === 'uploading' ? `
                        <button class="file-action-btn pause" title="暂停">
                            <i class="fas fa-pause"></i>
                        </button>
                        ` : ''}
                        ${fileItem.status === 'paused' ? `
                        <button class="file-action-btn resume" title="继续">
                            <i class="fas fa-play"></i>
                        </button>
                        ` : ''}
                        <button class="file-action-btn delete" title="移除">
                            <i class="fas fa-times"></i>
                        </button>
                    </div>
                </div>
            `);

            fileItem.element = $item;

            // 绑定操作按钮事件
            $item.find('.file-action-btn.start').on('click', () => this.startFileUpload(fileItem.id));
            $item.find('.file-action-btn.pause').on('click', () => this.pauseFileUpload(fileItem.id));
            $item.find('.file-action-btn.resume').on('click', () => this.resumeFileUpload(fileItem.id));
            $item.find('.file-action-btn.delete').on('click', () => this.removeFile(fileItem.id));

            return $item;
        }

        // 获取文件图标
        getFileIcon(mimeType) {
            return FILE_ICONS[mimeType] || FILE_ICONS['default'];
        }

        // 获取状态文本
        getStatusText(status) {
            const statusMap = {
                'queued': '等待中',
                'uploading': '上传中',
                'success': '成功',
                'failed': '失败',
                'paused': '已暂停'
            };
            return statusMap[status] || status;
        }

        // 开始上传
        startUpload() {
            if (this.isUploading) return;

            this.isUploading = true;
            this.paused = false;
            this.$startUploadBtn.prop('disabled', true);
            this.$startUploadBtn.html('<i class="fas fa-spinner fa-spin"></i> 上传中');

            this.processQueue();
        }

        // 处理队列
        processQueue() {
            if (this.paused || !this.isUploading) return;

            // 检查是否有空位进行新的上传
            const availableSlots = this.options.maxConcurrent - this.uploading.length;

            if (availableSlots > 0 && this.queue.length > 0) {
                // 从队列中取出文件开始上传
                const filesToUpload = this.queue.splice(0, availableSlots);

                filesToUpload.forEach(fileItem => {
                    fileItem.status = 'uploading';
                    fileItem.startTime = Date.now();
                    this.uploading.push(fileItem);
                    this.stats.queued--;
                    this.stats.uploading++;

                    this.uploadFile(fileItem);
                });

                this.updateStats();
                this.updateQueueDisplay();
            }

            // 如果还有队列中的文件或正在上传的文件，继续处理
            if ((this.queue.length > 0 || this.uploading.length > 0) && this.isUploading && !this.paused) {
                setTimeout(() => this.processQueue(), 100);
            } else if (this.uploading.length === 0 && this.queue.length === 0) {
                // 所有上传完成
                this.uploadComplete();
            }
        }

        // 上传单个文件
        uploadFile(fileItem) {
            // 模拟上传过程
            const totalSize = fileItem.size;
            let uploaded = 0;

            // 模拟分片上传
            const chunkSize = this.options.chunkSize;
            const totalChunks = Math.ceil(totalSize / chunkSize);
            let currentChunk = 0;

            const uploadChunk = () => {
                if (fileItem.status === 'paused' || !this.isUploading) {
                    return;
                }

                if (currentChunk >= totalChunks) {
                    // 上传完成
                    fileItem.status = 'success';
                    fileItem.progress = 100;

                    // 从上传中移除
                    const index = this.uploading.findIndex(item => item.id === fileItem.id);
                    if (index !== -1) {
                        this.uploading.splice(index, 1);
                        this.completed.push(fileItem);
                        this.stats.uploading--;
                        this.stats.success++;
                        this.stats.uploadedSize += fileItem.size;
                    }

                    this.updateFileDisplay(fileItem);
                    this.updateStats();

                    // 触发完成回调
                    if (this.options.onComplete) {
                        this.options.onComplete(fileItem);
                    }

                    return;
                }

                // 模拟上传延迟
                const chunkStart = currentChunk * chunkSize;
                const chunkEnd = Math.min(chunkStart + chunkSize, totalSize);
                const chunkSizeActual = chunkEnd - chunkStart;

                // 模拟上传时间（基于速度）
                const uploadTime = Math.max(100, Math.min(500, chunkSizeActual / 1024)); // 100ms - 500ms

                setTimeout(() => {
                    uploaded += chunkSizeActual;
                    currentChunk++;

                    fileItem.uploadedSize = uploaded;
                    fileItem.progress = Math.round((uploaded / totalSize) * 100);

                    // 计算速度
                    const now = Date.now();
                    const timeElapsed = (now - fileItem.startTime) / 1000; // 秒
                    if (timeElapsed > 0) {
                        fileItem.speed = uploaded / timeElapsed; // 字节/秒
                    }

                    this.updateFileDisplay(fileItem);
                    this.updateSpeed();

                    // 触发进度回调
                    if (this.options.onProgress) {
                        this.options.onProgress(fileItem);
                    }

                    // 继续上传下一块
                    uploadChunk();
                }, uploadTime);
            };

            uploadChunk();
        }

        // 开始单个文件上传
        startFileUpload(fileId) {
            const fileIndex = this.queue.findIndex(item => item.id === fileId);
            if (fileIndex !== -1) {
                const [fileItem] = this.queue.splice(fileIndex, 1);
                fileItem.status = 'uploading';
                fileItem.startTime = Date.now();
                this.uploading.push(fileItem);
                this.stats.queued--;
                this.stats.uploading++;

                this.updateStats();
                this.updateQueueDisplay();
                this.uploadFile(fileItem);
            }
        }

        // 暂停单个文件上传
        pauseFileUpload(fileId) {
            const fileItem = this.uploading.find(item => item.id === fileId);
            if (fileItem) {
                fileItem.status = 'paused';
                this.updateFileDisplay(fileItem);
            }
        }

        // 继续单个文件上传
        resumeFileUpload(fileId) {
            const fileItem = this.uploading.find(item => item.id === fileId);
            if (fileItem && fileItem.status === 'paused') {
                fileItem.status = 'uploading';
                this.updateFileDisplay(fileItem);
                this.uploadFile(fileItem);
            }
        }

        // 移除文件
        removeFile(fileId) {
            // 从队列中移除
            let index = this.queue.findIndex(item => item.id === fileId);
            if (index !== -1) {
                const [removed] = this.queue.splice(index, 1);
                this.stats.queued--;
                this.stats.total--;
                this.stats.totalSize -= removed.size;

                if (removed.element) {
                    removed.element.remove();
                }

                this.updateStats();
                this.updateQueueDisplay();
                return;
            }

            // 从上传中移除
            index = this.uploading.findIndex(item => item.id === fileId);
            if (index !== -1) {
                const [removed] = this.uploading.splice(index, 1);
                this.stats.uploading--;
                this.stats.total--;
                this.stats.totalSize -= removed.size;

                if (removed.element) {
                    removed.element.remove();
                }

                this.updateStats();
                this.updateQueueDisplay();
                return;
            }

            // 从已完成中移除
            index = this.completed.findIndex(item => item.id === fileId);
            if (index !== -1) {
                const [removed] = this.completed.splice(index, 1);
                this.stats.success--;
                this.stats.total--;

                if (removed.element) {
                    removed.element.remove();
                }

                this.updateStats();
                this.updateQueueDisplay();
                return;
            }

            // 从失败中移除
            index = this.failed.findIndex(item => item.id === fileId);
            if (index !== -1) {
                const [removed] = this.failed.splice(index, 1);
                this.stats.failed--;
                this.stats.total--;

                if (removed.element) {
                    removed.element.remove();
                }

                this.updateStats();
                this.updateQueueDisplay();
            }
        }

        // 暂停所有上传
        pauseAll() {
            this.paused = true;
            this.uploading.forEach(fileItem => {
                if (fileItem.status === 'uploading') {
                    fileItem.status = 'paused';
                    this.updateFileDisplay(fileItem);
                }
            });

            this.$pauseAllBtn.hide();
            this.$resumeAllBtn.show();
        }

        // 继续所有上传
        resumeAll() {
            this.paused = false;
            this.uploading.forEach(fileItem => {
                if (fileItem.status === 'paused') {
                    fileItem.status = 'uploading';
                    this.updateFileDisplay(fileItem);
                    this.uploadFile(fileItem);
                }
            });

            this.$resumeAllBtn.hide();
            this.$pauseAllBtn.show();

            // 继续处理队列
            this.processQueue();
        }

        // 清空所有
        clearAll() {
            if (!confirm('确定要清空所有上传队列吗？这将移除所有等待中和已完成的文件。')) {
                return;
            }

            // 清空所有数组
            this.queue = [];
            this.uploading = [];
            this.completed = [];
            this.failed = [];

            // 重置统计
            this.stats = {
                total: 0,
                queued: 0,
                uploading: 0,
                success: 0,
                failed: 0,
                speed: 0,
                totalSize: 0,
                uploadedSize: 0
            };

            this.isUploading = false;
            this.paused = false;

            // 重置按钮状态
            this.$startUploadBtn.prop('disabled', false);
            this.$startUploadBtn.html('<i class="fas fa-upload"></i> 开始上传');
            this.$resumeAllBtn.hide();
            this.$pauseAllBtn.show();

            // 清空队列显示
            this.$queueList.children().not(this.$emptyQueue).remove();
            this.$emptyQueue.show();

            this.updateStats();
        }

        // 上传完成
        uploadComplete() {
            this.isUploading = false;
            this.$startUploadBtn.prop('disabled', false);
            this.$startUploadBtn.html('<i class="fas fa-upload"></i> 开始上传');

            this.showMessage('所有文件上传完成！');
        }

        // 更新文件显示
        updateFileDisplay(fileItem) {
            if (!fileItem.element) return;

            const $item = fileItem.element;
            const $status = $item.find('.file-status');
            const $progressFill = $item.find('.progress-fill');
            const $fileActions = $item.find('.file-actions');

            // 更新状态
            $status.removeClass().addClass(`file-status status-${fileItem.status}`);
            $status.text(this.getStatusText(fileItem.status) +
                (fileItem.status === 'uploading' && fileItem.speed > 0 ? ` (${this.formatSpeed(fileItem.speed)})` : ''));

            // 更新进度条
            if ($progressFill.length) {
                $progressFill.css('width', `${fileItem.progress}%`);
            }

            // 更新操作按钮
            $fileActions.empty();

            if (fileItem.status === 'queued') {
                $fileActions.append(`
                    <button class="file-action-btn start" title="开始上传">
                        <i class="fas fa-play"></i>
                    </button>
                `);
                $fileActions.find('.start').on('click', () => this.startFileUpload(fileItem.id));
            } else if (fileItem.status === 'uploading') {
                $fileActions.append(`
                    <button class="file-action-btn pause" title="暂停">
                        <i class="fas fa-pause"></i>
                    </button>
                `);
                $fileActions.find('.pause').on('click', () => this.pauseFileUpload(fileItem.id));
            } else if (fileItem.status === 'paused') {
                $fileActions.append(`
                    <button class="file-action-btn resume" title="继续">
                        <i class="fas fa-play"></i>
                    </button>
                `);
                $fileActions.find('.resume').on('click', () => this.resumeFileUpload(fileItem.id));
            }

            $fileActions.append(`
                <button class="file-action-btn delete" title="移除">
                    <i class="fas fa-times"></i>
                </button>
            `);
            $fileActions.find('.delete').on('click', () => this.removeFile(fileItem.id));
        }

        // 更新统计信息
        updateStats() {
            this.$queuedCount.text(this.stats.queued);
            this.$uploadingCount.text(this.stats.uploading);
            this.$uploadSpeed.text(this.formatSpeed(this.stats.speed));
            this.$totalCount.text(this.stats.total);
            this.$successCount.text(this.stats.success);
            this.$failedCount.text(this.stats.failed);
        }

        // 初始化速度计算器
        initSpeedCalculator() {
            this.speedCalculator.startTime = Date.now();
            this.speedCalculator.lastBytes = 0;
            this.speedCalculator.lastTime = Date.now();
            this.speedCalculator.speeds = [];

            setInterval(() => {
                this.updateSpeed();
            }, 1000);
        }

        // 更新速度
        updateSpeed() {
            const now = Date.now();
            const timeElapsed = (now - this.speedCalculator.lastTime) / 1000; // 秒

            if (timeElapsed > 0) {
                const bytesUploaded = this.stats.uploadedSize - this.speedCalculator.lastBytes;
                const currentSpeed = bytesUploaded / timeElapsed; // 字节/秒

                // 添加到速度数组
                this.speedCalculator.speeds.push(currentSpeed);

                // 只保留最近10个速度值
                if (this.speedCalculator.speeds.length > 10) {
                    this.speedCalculator.speeds.shift();
                }

                // 计算平均速度
                let avgSpeed = 0;
                if (this.speedCalculator.speeds.length > 0) {
                    const sum = this.speedCalculator.speeds.reduce((a, b) => a + b, 0);
                    avgSpeed = sum / this.speedCalculator.speeds.length;
                }

                this.stats.speed = avgSpeed;
                this.speedCalculator.lastBytes = this.stats.uploadedSize;
                this.speedCalculator.lastTime = now;

                this.updateStats();
            }
        }

        // 格式化文件大小
        formatFileSize(bytes) {
            if (bytes === 0) return '0 B';

            const k = 1024;
            const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
            const i = Math.floor(Math.log(bytes) / Math.log(k));

            return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
        }

        // 格式化速度
        formatSpeed(bytesPerSecond) {
            if (bytesPerSecond < 1024) {
                return Math.round(bytesPerSecond) + ' B/s';
            } else if (bytesPerSecond < 1024 * 1024) {
                return (bytesPerSecond / 1024).toFixed(1) + ' KB/s';
            } else {
                return (bytesPerSecond / (1024 * 1024)).toFixed(1) + ' MB/s';
            }
        }

        // 显示消息
        showMessage(message) {
            // 简单实现，实际项目中可以使用更优雅的通知组件
            console.log('消息:', message);
            alert(message);
        }

        // 显示错误
        showError(message) {
            console.error('错误:', message);
            alert('错误: ' + message);
        }

        // HTML转义
        escapeHtml(text) {
            const div = document.createElement('div');
            div.textContent = text;
            return div.innerHTML;
        }
    }

    // 创建jQuery插件
    $.fn.fileUploader = function(options) {
        return this.each(function() {
            if (!$.data(this, 'fileUploader')) {
                $.data(this, 'fileUploader', new FileUploader(options));
            }
        });
    };

    // 页面加载完成后初始化
    $(document).ready(function() {
        // 初始化文件上传插件
        $('.upload-container').fileUploader({
            uploadUrl: '/api/upload',
            maxConcurrent: 3,
            autoStart: false,
            onProgress: function(fileItem) {
                console.log('文件上传进度:', fileItem.name, fileItem.progress + '%');
            },
            onComplete: function(fileItem) {
                console.log('文件上传完成:', fileItem.name);
            },
            onError: function(fileItem, error) {
                console.error('文件上传错误:', fileItem.name, error);
            }
        });
    });
})(jQuery);