1
0
mirror of https://github.com/ZeroCatDev/Classworks.git synced 2026-02-04 07:53:11 +00:00

Address code review feedback: Extract server list to constants file and improve logging

Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-01-19 11:12:53 +00:00
parent fd145e455c
commit b5a2f2f4b7
4 changed files with 13 additions and 15 deletions

6
src/utils/constants.js Normal file
View File

@ -0,0 +1,6 @@
// Classworks云服务器地址列表按优先级从上到下
// 这个列表可以方便地更新服务器地址
export const CLASSWORKS_CLOUD_SERVERS = [
"https://kv-service.houlang.cloud",
"https://kv-service.wuyuan.dev"
];

View File

@ -1,6 +1,7 @@
import {kvLocalProvider} from "./providers/kvLocalProvider";
import {kvServerProvider, getServerUrl, CLASSWORKS_CLOUD_SERVERS} from "./providers/kvServerProvider";
import {kvServerProvider, getServerUrl} from "./providers/kvServerProvider";
import {getSetting, setSetting} from "./settings";
import {CLASSWORKS_CLOUD_SERVERS} from "./constants";
export const formatResponse = (data) => data;

View File

@ -1,12 +1,7 @@
import axios from "@/axios/axios";
import {formatResponse, formatError} from "../dataProvider";
import {getSetting} from "../settings";
// Classworks云服务器地址列表按优先级从上到下
const CLASSWORKS_CLOUD_SERVERS = [
"https://kv-service.houlang.cloud",
"https://kv-service.wuyuan.dev"
];
import {CLASSWORKS_CLOUD_SERVERS} from "../constants";
// 当前正在使用的服务器索引
let currentServerIndex = 0;
@ -52,7 +47,7 @@ const tryNextServer = () => {
if (provider === "classworkscloud") {
currentServerIndex = (currentServerIndex + 1) % CLASSWORKS_CLOUD_SERVERS.length;
console.log(`切换到备用服务器: ${CLASSWORKS_CLOUD_SERVERS[currentServerIndex]}`);
console.warn(`切换到备用服务器: ${CLASSWORKS_CLOUD_SERVERS[currentServerIndex]}`);
}
};
@ -234,5 +229,5 @@ export const kvServerProvider = {
},
};
// 导出服务器列表和URL获取函数供其他模块使用
export { CLASSWORKS_CLOUD_SERVERS, getServerUrl };
// 导出URL获取函数供其他模块使用
export { getServerUrl };

View File

@ -64,11 +64,7 @@ const SETTINGS_STORAGE_KEY = "Classworks_settings";
// 新增: Classworks云端存储的默认设置
// Classworks云服务器地址列表按优先级从上到下
const CLASSWORKS_CLOUD_SERVERS = [
"https://kv-service.houlang.cloud",
"https://kv-service.wuyuan.dev"
];
import {CLASSWORKS_CLOUD_SERVERS} from "./constants";
const classworksCloudDefaults = {
"server.domain": import.meta.env.VITE_DEFAULT_KV_SERVER || CLASSWORKS_CLOUD_SERVERS[0],