60sapi接口搭建完毕,数据库连接测试成功,登录注册部分简单完成

This commit is contained in:
2025-09-02 19:45:50 +08:00
parent b139fb14d9
commit e1f8885c6c
150 changed files with 53045 additions and 8 deletions

View File

@@ -1,4 +1,7 @@
// API接口列表
// 本地后端API接口
const LOCAL_API_BASE = 'http://localhost:5000/api/60s';
// API接口列表备用
const API_ENDPOINTS = [
"https://60s-cf.viki.moe",
"https://60s.viki.moe",
@@ -9,6 +12,7 @@ const API_ENDPOINTS = [
// 当前使用的API索引
let currentApiIndex = 0;
let useLocalApi = true;
// DOM元素
const loadingElement = document.getElementById('loading');
@@ -46,6 +50,30 @@ async function loadHotList() {
// 获取数据
async function fetchData() {
// 优先尝试本地API
if (useLocalApi) {
try {
const response = await fetch(`${LOCAL_API_BASE}/douyin`, {
method: 'GET',
headers: {
'Accept': 'application/json',
},
timeout: 10000
});
if (response.ok) {
const data = await response.json();
if (data.code === 200 && data.data) {
return data;
}
}
} catch (error) {
console.warn('本地API请求失败切换到外部API:', error);
useLocalApi = false;
}
}
// 使用外部API作为备用
for (let i = 0; i < API_ENDPOINTS.length; i++) {
const apiUrl = API_ENDPOINTS[currentApiIndex];

View File

@@ -5,4 +5,4 @@
5.返回接口.json储存了网页api返回的数据格式
6.严格按照用户要求执行,不得随意添加什么注解,如“以下数据来自...”
7.接口集合.json保存了所有已知的后端API接口一个访问不了尝试自动切换另一个
8.在css中有关背景的css单独一个css文件方便我直接迁移
8.在css中有关背景的css单独一个css文件方便我直接迁移