<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>云智API - 优质的接口调用服务平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="云智API致力于为您提供更加稳定、高速的PHP接口调用服务。广泛应用于网站装饰,图片编辑,智能开发,数据分析,写作优化,音乐解析,生活服务等领域,助力开发者快速构建网站和应用。">
    <meta name="keywords" content="API,云智API,api,云智计算,API接口,api接口,云智api,PHP接口,php接口,API调用,api调用,免费API,免费api,免费接口">
    <meta name="robots" content="index, follow">
    <meta property="og:title" content="云智API - 优质的接口调用服务平台">
    <meta property="og:description" content="云智API致力于为您提供更加稳定、高速的PHP接口调用服务。广泛应用于网站装饰,图片编辑,智能开发,数据分析,写作优化,音乐解析,生活服务等领域,助力开发者快速构建网站和应用。">
    <meta property="og:type" content="website">
    <meta property="og:url" content="https://api.jkyai.top">
    <link rel="icon" href="https://api.jkyai.top/favicon.ico">
    <link rel="canonical" href="https://api.jkyai.top/" />
    
    <script src="https://cdn.tailwindcss.com"></script>
    <link href="https://cdn.jsdelivr.net/npm/remixicon@4.2.0/fonts/remixicon.css" rel="stylesheet"/>
    
    <style>
        html {
            cursor: url('/js/index.ico'), auto;
        }
    
        body {
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }
    
        @keyframes progress {
            from { width: 0; }
            to { width: 100%; }
        }
        .progress-bar {
            height: 3px;
            background: linear-gradient(90deg, #6366f1 0%, #ec4899 50%, #f59e0b 100%);
            animation: progress 0.5s ease-out;
        }
        @keyframes spin {
            100% { transform: rotate(360deg); }
        }
        .animate-spin {
            animation: spin 1s linear infinite;
        }
        .dialog-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 999;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .dialog-content {
            position: relative;
            background: white;
            padding: 1.5rem;
            border-radius: 0.5rem;
            width: 90%;
            max-width: 500px;
            z-index: 1000;
        }
        .success-dialog {
            position: relative;
            background: white;
            padding: 2rem;
            border-radius: 12px;
            text-align: center;
            box-shadow: 0 10px 30px rgba(0,0,0,0.15);
            width: 320px;
            z-index: 1001;
        }
        .success-icon {
            color: #67C23A;
            font-size: 3.5rem;
            margin-bottom: 1rem;
        }
        @keyframes progress-bar {
            from { width: 100% }
            to { width: 0% }
        }
        .success-progress {
            height: 3px;
            background: #67C23A;
            margin-top: 1.5rem;
            animation: progress-bar 2.5s linear forwards;
        }
        .search-button {
            position: fixed;
            bottom: 20px;
            right: 20px;
            z-index: 1000;
            transition: all 0.3s ease;
        }
        .api-test-button {
            position: fixed;
            bottom: 80px;
            right: 20px;
            z-index: 1000;
            transition: all 0.3s ease;
        }
        .back-to-top {
            position: fixed;
            bottom: 140px;
            right: 20px;
            z-index: 1000;
            opacity: 0;
            visibility: hidden;
            transition: all 0.3s ease;
        }
        .back-to-top.show {
            opacity: 1;
            visibility: visible;
        }
        .search-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(0, 0, 0, 0.5);
            z-index: 1001;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        .search-dialog {
            background: white;
            padding: 2rem;
            border-radius: 12px;
            width: 90%;
            max-width: 500px;
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }
        .api-test-dialog {
            background: white;
            padding: 1.5rem;
            border-radius: 12px;
            width: 95%;
            max-width: 800px;
            max-height: 90vh;
            overflow-y: auto;
            box-shadow: 0 10px 25px rgba(0,0,0,0.1);
        }
        .search-results-container {
            max-height: 400px;
            overflow-y: auto;
            padding-right: 8px;
            margin-top: 1rem;
        }
        .search-result-item {
            background: #f8f9fa;
            padding: 12px;
            border-radius: 8px;
            margin-bottom: 8px;
            transition: all 0.2s ease;
        }
        .search-result-item:hover {
            background: #e9ecef;
            transform: translateY(-2px);
        }
        .icp-number {
            text-align: center;
            padding: 10px 0;
            color: rgba(0, 0, 0, 0.5);
            font-size: 14px;
            margin-top: 2rem;
        }
        .icp-number a {
            color: rgba(0, 0, 0, 0.5);
            text-decoration: none;
            display: inline-flex;
            align-items: center;
        }
        .icp-number a:hover {
            text-decoration: underline;
        }
        .floating-btn {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
            cursor: pointer;
            background: #6366f1;
            color: white;
            transition: all 0.3s ease;
        }
        .floating-btn:hover {
            background: #4f46e5;
            transform: translateY(-2px);
        }
        .more-results {
            text-align: center;
            padding: 8px;
            color: #666;
            font-size: 14px;
        }
        .close-btn {
            font-size: 1.5rem;
            padding: 0.5rem;
            margin-right: -0.5rem;
        }
        .param-row, .header-row {
            display: flex;
            margin-bottom: 8px;
            gap: 8px;
        }
        .param-input, .header-input {
            flex: 1;
            min-width: 0;
        }
        .remove-btn {
            color: #ef4444;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            flex-shrink: 0;
        }
        .add-btn {
            background: #6366f1;
            color: white;
            border-radius: 4px;
            padding: 6px 12px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 12px;
            font-size: 0.875rem;
        }
        .add-btn:hover {
            background: #4f46e5;
        }
        .response-container {
            border: 1px solid #e5e7eb;
            border-radius: 8px;
            padding: 12px;
            margin-top: 16px;
            background: #f9fafb;
            max-height: 300px;
            overflow-y: auto;
        }
        .response-header {
            display: flex;
            justify-content: space-between;
            margin-bottom: 8px;
        }
        .response-title {
            font-weight: 600;
        }
        .response-status {
            color: #6366f1;
        }
        .response-time {
            color: #6b7280;
            font-size: 0.875rem;
        }
        .response-content {
            white-space: pre-wrap;
            font-family: monospace;
            font-size: 0.875rem;
        }
        @media (max-width: 640px) {
            .floating-btn {
                width: 40px;
                height: 40px;
            }
            .api-test-button {
                bottom: 70px;
            }
            .search-button {
                bottom: 20px;
            }
            .back-to-top {
                bottom: 120px;
            }
            .api-test-dialog {
                width: 95%;
                padding: 1rem;
                max-height: 85vh;
            }
            .param-row, .header-row {
                flex-wrap: wrap;
                gap: 6px;
                margin-bottom: 6px;
            }
            .param-input, .header-input {
                flex: 1 1 calc(50% - 10px);
                min-width: calc(50% - 10px);
                font-size: 0.875rem;
                padding: 0.5rem;
            }
            .remove-btn {
                width: 30px;
                flex: 0 0 30px;
                margin-left: auto;
            }
            .add-btn {
                padding: 4px 8px;
                font-size: 0.75rem;
                margin-bottom: 8px;
            }
            .response-container {
                max-height: 200px;
            }
        }
    </style>
</head>
<body class="bg-gray-50">
    <script>
        document.addEventListener('contextmenu', function(e) {
            e.preventDefault();
        });
        
        document.addEventListener('keydown', function(e) {
            if (e.key === 'F12' || 
                (e.ctrlKey && e.shiftKey && (e.key === 'I' || e.key === 'J' || e.key === 'C')) || 
                (e.ctrlKey && e.key === 'u') || 
                (e.ctrlKey && e.key === 's')) {
                e.preventDefault();
                return false;
            }
        });
    </script>

    <nav class="sticky top-0 bg-white shadow-sm z-50">
        <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="flex items-center justify-between h-16">
                <div class="flex-shrink-0 flex items-center">
                    <h1 class="ml-2 text-xl font-bold text-gray-900">云智API【接口列表】</h1>
                </div>
                <div class="hidden md:flex items-center space-x-4">
                    <a href="?action=friendlinks" class="px-3 py-2 rounded-md text-gray-700 hover:bg-gray-100">友情链接</a>
                    <a href="/updata.php" class="px-3 py-2 rounded-md text-gray-700 hover:bg-gray-100">更新日志</a>
                    <a href="http://qm.qq.com/cgi-bin/qm/qr?_wv=1027&k=pqVhxuGgys_jC0dI9vKZximcISOFoi8Z&authKey=KOdP7Eoe9vMQE7nabBKAvvnkLMEDjPO7PIl%2F%2FP0Rf8aT1ihtVpPE3rv1x9UYSk1%2B&noverify=0&group_code=462675976" class="px-3 py-2 rounded-md text-gray-700 hover:bg-gray-100">官方群聊</a>
                    <a href="/chat" class="px-3 py-2 rounded-md text-gray-700 hover:bg-gray-100" target="_blank">智能对话</a>
                </div>
            </div>
        </div>
    </nav>

    <div id="percentageCounter" class="progress-bar"></div>

    <main class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8" id="app">
        <div v-if="loading" class="text-center py-12 space-y-4">
            <div class="animate-spin text-4xl text-indigo-600">
                <i class="ri-loader-4-line"></i>
            </div>
            <p class="text-gray-600">正在努力加载接口列表...</p>
        </div>

        <div v-if="!loading">
            <div v-if="RandAdvertise && RandAdvertise.url" class="mb-8 bg-gradient-to-r from-purple-500 to-pink-500 rounded-xl p-6 text-white shadow-lg">
                <div class="flex flex-col md:flex-row items-center justify-between space-y-4 md:space-y-0">
                    <div class="flex items-center space-x-4">
                        <img :src="RandAdvertise.logo" class="w-12 h-12 rounded-full border-2 border-white">
                        <div>
                            <h2 class="text-xl font-bold">{{ RandAdvertise.name }}</h2>
                            <p class="text-sm opacity-90">{{ RandAdvertise.description }}</p>
                        </div>
                    </div>
                    <div class="flex space-x-3">
                        <button @click="Advertise(RandAdvertise.id)" 
                                class="px-4 py-2 bg-white/20 rounded-lg hover:bg-white/30 transition flex items-center space-x-2">
                            <span>查看详情</span>
                            <i class="ri-arrow-right-line"></i>
                        </button>
                        <button @click="endAdvertise" 
                                class="px-4 py-2 bg-white/20 rounded-lg hover:bg-white/30 transition flex items-center space-x-2">
                            <span>关闭广告</span>
                            <i class="ri-close-line"></i>
                        </button>
                    </div>
                </div>
            </div>

            <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
                <div v-for="api in filteredApis" :key="api.id" class="bg-white rounded-xl shadow-sm hover:shadow-md transition-all">
                    <div class="p-6">
                        <div class="flex items-start justify-between">
                            <div>
                                <h3 class="text-lg font-semibold text-gray-900">{{ api.name }}</h3>
                                <div class="mt-2">
                                    <span v-if="api.status == 1" 
                                          class="px-3 py-1 bg-green-100 text-green-800 text-sm rounded-full">状态正常</span>
                                    <span v-else-if="api.status == 0" 
                                          class="px-3 py-1 bg-red-100 text-red-800 text-sm rounded-full">暂停维护</span>
                                    <span v-else 
                                          class="px-3 py-1 bg-yellow-100 text-yellow-800 text-sm rounded-full">未知状态</span>
                                </div>
                            </div>
                            <button @click="openFeedback(api)" 
                                    class="text-gray-400 hover:text-gray-600">
                                <i class="ri-alert-line text-lg"></i>
                            </button>
                        </div>
                        <p class="mt-4 text-gray-600 text-sm">{{ api.desc }}</p>
                        <div class="mt-6 flex items-center justify-between">
                            <div class="text-sm text-gray-500 flex items-center space-x-1">
                                <i class="ri-pie-chart-line"></i>
                                <span>调用 {{ api.access }} 次</span>
                            </div>
                            <a :href="'?action=doc&id=' + api.id" target="_blank" 
                               class="px-4 py-2 bg-indigo-500 hover:bg-indigo-600 text-white rounded-lg flex items-center">
                                <span>文档</span>
                                <i class="ri-external-link-line ml-2"></i>
                            </a>
                        </div>
                    </div>
                </div>
            </div>

            <div v-if="filteredApis.length === 0" class="text-center py-12">
                <div class="mb-4 text-gray-400 text-6xl"><i class="ri-cloud-off-line"></i></div>
                <h3 class="text-xl font-semibold text-gray-900">暂时没有可用接口</h3>
                <p class="text-gray-600 mt-2">新的接口正在开发中,敬请期待</p>
            </div>
        </div>

        <div v-if="showFeedback" class="dialog-overlay" @click.self="showFeedback = false">
            <div class="dialog-content">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-lg font-semibold">问题反馈 - {{ feedback.name }}</h3>
                    <button @click="showFeedback = false" class="text-gray-500 hover:text-gray-700 close-btn">
                        <i class="ri-close-line"></i>
                    </button>
                </div>
                <div class="space-y-4">
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">反馈标题</label>
                        <input v-model="feedback.title" type="text" class="w-full px-3 py-2 border rounded-md" required>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">反馈内容</label>
                        <textarea v-model="feedback.content" rows="4" class="w-full px-3 py-2 border rounded-md" required></textarea>
                    </div>
                    <div>
                        <label class="block text-sm font-medium text-gray-700 mb-1">联系邮箱</label>
                        <input v-model="feedback.email" type="email" class="w-full px-3 py-2 border rounded-md" required>
                    </div>
                    <button @click="submitFeedback" class="w-full bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700">
                        提交反馈
                    </button>
                </div>
            </div>
        </div>

        <div v-if="showSuccess" class="dialog-overlay">
            <div class="success-dialog">
                <div class="success-icon">
                    <i class="ri-checkbox-circle-fill"></i>
                </div>
                <h3 class="text-lg font-semibold mb-2">反馈提交成功!</h3>
                <p class="text-gray-600 text-sm">我们已收到您的反馈,将在1-3个工作日内邮件回复</p>
                <div class="success-progress"></div>
            </div>
        </div>

        <div v-if="showApiTest" class="dialog-overlay">
            <div class="api-test-dialog">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-lg font-semibold">接口在线调试 - 通用版</h3>
                    <button @click="showApiTest = false" class="text-gray-500 hover:text-gray-700 close-btn">
                        <i class="ri-close-line"></i>
                    </button>
                </div>
                
                <div class="mb-4">
                    <label class="block text-sm font-medium text-gray-700 mb-1">请求URL</label>
                    <input v-model="apiTest.url" type="text" placeholder="请输入完整的API地址,例如:https://api.jkyai.top/API/hqdqsj.php" class="w-full px-3 py-2 border rounded-md">
                </div>
                
                <div class="mb-4">
                    <label class="block text-sm font-medium text-gray-700 mb-1">请求方法</label>
                    <select v-model="apiTest.method" class="w-full px-3 py-2 border rounded-md">
                        <option value="GET">GET</option>
                        <option value="POST">POST</option>
                    </select>
                </div>
                
                <div class="mb-4">
                    <label class="block text-sm font-medium text-gray-700 mb-1">请求参数</label>
                    <div v-for="(param, index) in apiTest.params" :key="'param-'+index" class="param-row">
                        <input v-model="param.key" placeholder="参数名" class="param-input px-3 py-2 border rounded-md">
                        <input v-model="param.value" placeholder="参数值" class="param-input px-3 py-2 border rounded-md">
                        <button @click="removeParam(index)" class="remove-btn">
                            <i class="ri-delete-bin-line"></i>
                        </button>
                    </div>
                    <button @click="addParam" class="add-btn">
                        <i class="ri-add-line mr-1"></i> 添加参数
                    </button>
                </div>
                
                <div class="mb-4">
                    <label class="block text-sm font-medium text-gray-700 mb-1">请求头</label>
                    <div v-for="(header, index) in apiTest.headers" :key="'header-'+index" class="header-row">
                        <input v-model="header.key" placeholder="键" class="header-input px-3 py-2 border rounded-md">
                        <input v-model="header.value" placeholder="值" class="header-input px-3 py-2 border rounded-md">
                        <button @click="removeHeader(index)" class="remove-btn">
                            <i class="ri-delete-bin-line"></i>
                        </button>
                    </div>
                    <button @click="addHeader" class="add-btn">
                        <i class="ri-add-line mr-1"></i> 添加请求头
                    </button>
                </div>
                
                <button @click="sendApiRequest" class="w-full bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700 mb-4">
                    发送请求
                </button>
                
                <div v-if="apiTest.response" class="response-container">
                    <div class="response-header">
                        <span class="response-title">响应结果</span>
                        <span class="response-status">状态: {{ apiTest.response.status }}</span>
                    </div>
                    <div class="response-time">耗时: {{ apiTest.response.time }}ms</div>
                    <div class="response-content">{{ apiTest.response.data }}</div>
                </div>
            </div>
        </div>

        <!-- 搜索模块 -->
        <button @click="showSearch = true" class="search-button floating-btn">
            <i class="ri-search-line text-xl"></i>
        </button>

        <!-- 请求模块 -->
        <button @click="openApiTest" class="api-test-button floating-btn">
            <i class="ri-terminal-line text-xl"></i>
        </button>

        <button id="backToTop" class="back-to-top floating-btn">
            <i class="ri-arrow-up-line text-xl"></i>
        </button>

        <div v-if="showSearch" class="search-overlay">
            <div class="search-dialog">
                <div class="flex justify-between items-center mb-4">
                    <h3 class="text-lg font-semibold">搜索接口【实时】</h3>
                    <button @click="showSearch = false" class="text-gray-500 hover:text-gray-700 close-btn">
                        <i class="ri-close-line"></i>
                    </button>
                </div>
                <input v-model="searchQuery" type="text" placeholder="输入要搜索的接口名称 (๑o₃o๑)" class="w-full px-3 py-2 border rounded-md mb-4">
                
                <div class="search-results-container" v-if="searchResults.length > 0">
                    <div v-for="(api, index) in searchResults" :key="api.id" class="search-result-item" :class="{ 'mb-0': index === 4 && searchResults.length > 5 }">
                        <h4 class="font-semibold">{{ api.name }}</h4>
                        <p class="text-sm text-gray-600">{{ api.desc }}</p>
                        <a :href="'?action=doc&id=' + api.id" target="_blank" class="text-indigo-600 hover:text-indigo-800 text-sm mt-2 inline-block">查看接口文档</a>
                    </div>
                    
                    <div v-if="searchResults.length > 5" class="more-results">
                        耶!共查找到 {{ searchResults.length - 5 }} 个API接口
                    </div>
                </div>
                
                <div v-else-if="searchQuery" class="text-center py-4 text-gray-600">
                    啊偶~接口被恐龙吃掉啦!
                </div>
            </div>
        </div>
    </main>
    <div class="icp-number">
        <a href="https://beian.miit.gov.cn/" target="_blank">
            <img src="/china.svg" class="h-4 mr-1" alt="中国国徽图标">
            Copyright©云智API 湘ICP备2025109107号
        </a>
    </div>

    <script src="/assets/js/vue.js"></script>
    <script>
        // 初始化Vue应用和关键功能
        const app = new Vue({
            el: '#app',
            data() {
                return {
                    apis: [],
                    RandAdvertise: null,
                    loading: true,
                    showFeedback: false,
                    showSuccess: false,
                    showSearch: false,
                    showApiTest: false,
                    searchQuery: '',
                    feedback: {
                        id: '',
                        name: '',
                        title: '',
                        content: '',
                        email: ''
                    },
                    apiTest: {
                        url: '',
                        method: 'GET',
                        params: [],
                        headers: [
                            { key: 'User-Agent', value: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36' }
                        ],
                        response: null
                    }
                }
            },
            computed: {
                filteredApis() {
                    return this.apis;
                },
                searchResults() {
                    if (!this.searchQuery) return [];
                    
                    const query = this.searchQuery.toLowerCase();
                    return this.apis.filter(api => 
                        api.name.toLowerCase().includes(query) || 
                        api.desc.toLowerCase().includes(query)
                    );
                }
            },
            methods: {
                async loadData() {
                    try {
                        // 搜索和反馈功能
                        this.initSearchAndFeedback();
                        
                        // 异步加载API数据
                        const [apisRes, adRes] = await Promise.all([
                            fetch('/Data/api.php?type=getAllApi').then(r => r.json()),
                            fetch('/Data/api.php?type=getRandAdvertising').then(r => r.json())
                        ]);
                        
                        this.apis = apisRes.code === 0 ? apisRes.data || [] : [];
                        this.RandAdvertise = adRes.code === 0 ? adRes.data[0] || null : null;
                    } catch (error) {
                        console.error('数据加载失败:', error);
                    } finally {
                        this.loading = false;
                    }
                },

                initSearchAndFeedback() {
                    // 初始化搜索和反馈功能
                    this.searchQuery = '';
                    this.feedback = {
                        id: '',
                        name: '',
                        title: '',
                        content: '',
                        email: ''
                    };
                },

                openFeedback(api) {
                    this.feedback = {
                        id: api.id,
                        name: api.name,
                        title: `问题反馈 - ${api.name}`,
                        content: '',
                        email: ''
                    };
                    this.showFeedback = true;
                },

                async submitFeedback() {
                    if (!this.validateFeedback()) return;

                    try {
                        const apiUrl = new URL('https://api.jkyai.top/Template/Home/stmp');
                        apiUrl.searchParams.set('mtie', this.feedback.title);
                        apiUrl.searchParams.set('content', `${this.feedback.content}\n\n联系方式:${this.feedback.email}`);

                        const response = await fetch(apiUrl.toString());
                        const result = await response.text();
                        
                        if (result.includes('发送成功')) {
                            this.showSuccess = true;
                            setTimeout(() => {
                                this.showSuccess = false;
                                this.showFeedback = false;
                                this.resetFeedbackForm();
                            }, 2500);
                        } else {
                            console.error('邮件发送失败:', result);
                        }
                    } catch (error) {
                        console.error('网络请求失败:', error);
                    }
                },

                validateFeedback() {
                    if (!this.feedback.title.trim()) {
                        return false;
                    }
                    if (!this.feedback.content.trim()) {
                        return false;
                    }
                    if (!/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(this.feedback.email)) {
                        return false;
                    }
                    return true;
                },

                resetFeedbackForm() {
                    this.feedback = {
                        id: '',
                        name: '',
                        title: '',
                        content: '',
                        email: ''
                    };
                },

                Advertise(id) {
                    window.open(`/?action=ad&title=${encodeURIComponent(this.RandAdvertise.name)}&id=${id}`, '_blank');
                },

                endAdvertise() {
                    this.RandAdvertise = null;
                },

                // API测试相关方法
                openApiTest() {
                    this.showApiTest = true;
                },

                addParam() {
                    this.apiTest.params.push({ key: '', value: '' });
                },

                removeParam(index) {
                    this.apiTest.params.splice(index, 1);
                },

                addHeader() {
                    this.apiTest.headers.push({ key: '', value: '' });
                },

                removeHeader(index) {
                    this.apiTest.headers.splice(index, 1);
                },

                async sendApiRequest() {
                    if (!this.apiTest.url) {
                        alert('请求失败,缺少必要信息!');
                        return;
                    }

                    try {
                        const startTime = Date.now();
                        let url = this.apiTest.url;
                        const options = {
                            method: this.apiTest.method,
                            headers: {}
                        };

                        // 处理请求头
                        this.apiTest.headers.forEach(header => {
                            if (header.key && header.value) {
                                options.headers[header.key] = header.value;
                            }
                        });

                        // 处理GET参数
                        if (this.apiTest.method === 'GET' && this.apiTest.params.length > 0) {
                            const urlObj = new URL(url);
                            this.apiTest.params.forEach(param => {
                                if (param.key) {
                                    urlObj.searchParams.append(param.key, param.value || '');
                                }
                            });
                            url = urlObj.toString();
                        }

                        // 处理POST参数
                        if (this.apiTest.method === 'POST' && this.apiTest.params.length > 0) {
                            const formData = new FormData();
                            this.apiTest.params.forEach(param => {
                                if (param.key) {
                                    formData.append(param.key, param.value || '');
                                }
                            });
                            options.body = formData;
                        }

                        const response = await fetch(url, options);
                        const data = await response.text();
                        const endTime = Date.now();

                        this.apiTest.response = {
                            status: response.status,
                            data: data,
                            time: endTime - startTime
                        };
                    } catch (error) {
                        this.apiTest.response = {
                            status: 'Error',
                            data: error.message,
                            time: 0
                        };
                    }
                }
            },
            mounted() {
                // 初始化关键功能
                this.initSearchAndFeedback();
                
                // 加载数据
                this.loadData();
                
                // 滚动监听
                window.addEventListener('scroll', () => {
                    const scrollPercent = (window.scrollY / (document.documentElement.scrollHeight - window.innerHeight)) * 100;
                    document.getElementById('percentageCounter').style.width = scrollPercent + '%';
                });
            }
        });
    </script>
    
    <!-- 加载非关键资源 -->
    <script src="/assets/js/jquery.min.js"></script>
    <script src="/assets/js/sweetalert.min.js"></script>
    <script>
        // 滚动和返回顶部
        $(window).scroll(function () {
            const scrollTop = $(window).scrollTop();
            const docHeight = $(document).height();
            const winHeight = $(window).height();
            let scrollPercent = (scrollTop / (docHeight - winHeight)) * 100;
            scrollPercent = scrollPercent.toFixed(1);
            $("#percentageCounter").css({ width: scrollPercent + "%" });
            
            if (scrollTop > 300) {
                $('#backToTop').addClass('show');
            } else {
                $('#backToTop').removeClass('show');
            }
        }).trigger("scroll");

        $('#backToTop').click(function() {
            $('html, body').animate({scrollTop: 0}, 500);
        });
    </script>
    <script type="text/javascript" id="myhk" src="https://myhkw.cn/api/player/170740920443" key="170740920443" m="1"></script>
    <!--统计访客数量,先暂时不用。<script>(new Image()).src = 'https://api.jkyai.top/API/tjfksl/tongji.php?text=api.jkyai.top';</script>-->
    <link href="/js/a.css" rel="stylesheet"/>
</body>
</html>