mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2026-02-04 16:03:10 +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:
parent
fd145e455c
commit
b5a2f2f4b7
6
src/utils/constants.js
Normal file
6
src/utils/constants.js
Normal file
@ -0,0 +1,6 @@
|
||||
// Classworks云服务器地址列表(按优先级从上到下)
|
||||
// 这个列表可以方便地更新服务器地址
|
||||
export const CLASSWORKS_CLOUD_SERVERS = [
|
||||
"https://kv-service.houlang.cloud",
|
||||
"https://kv-service.wuyuan.dev"
|
||||
];
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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 };
|
||||
|
||||
@ -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],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user