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:
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 {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 {getSetting, setSetting} from "./settings";
|
||||||
|
import {CLASSWORKS_CLOUD_SERVERS} from "./constants";
|
||||||
|
|
||||||
export const formatResponse = (data) => data;
|
export const formatResponse = (data) => data;
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,7 @@
|
|||||||
import axios from "@/axios/axios";
|
import axios from "@/axios/axios";
|
||||||
import {formatResponse, formatError} from "../dataProvider";
|
import {formatResponse, formatError} from "../dataProvider";
|
||||||
import {getSetting} from "../settings";
|
import {getSetting} from "../settings";
|
||||||
|
import {CLASSWORKS_CLOUD_SERVERS} from "../constants";
|
||||||
// Classworks云服务器地址列表(按优先级从上到下)
|
|
||||||
const CLASSWORKS_CLOUD_SERVERS = [
|
|
||||||
"https://kv-service.houlang.cloud",
|
|
||||||
"https://kv-service.wuyuan.dev"
|
|
||||||
];
|
|
||||||
|
|
||||||
// 当前正在使用的服务器索引
|
// 当前正在使用的服务器索引
|
||||||
let currentServerIndex = 0;
|
let currentServerIndex = 0;
|
||||||
@ -52,7 +47,7 @@ const tryNextServer = () => {
|
|||||||
|
|
||||||
if (provider === "classworkscloud") {
|
if (provider === "classworkscloud") {
|
||||||
currentServerIndex = (currentServerIndex + 1) % CLASSWORKS_CLOUD_SERVERS.length;
|
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获取函数供其他模块使用
|
// 导出URL获取函数供其他模块使用
|
||||||
export { CLASSWORKS_CLOUD_SERVERS, getServerUrl };
|
export { getServerUrl };
|
||||||
|
|||||||
@ -64,11 +64,7 @@ const SETTINGS_STORAGE_KEY = "Classworks_settings";
|
|||||||
|
|
||||||
|
|
||||||
// 新增: Classworks云端存储的默认设置
|
// 新增: Classworks云端存储的默认设置
|
||||||
// Classworks云服务器地址列表(按优先级从上到下)
|
import {CLASSWORKS_CLOUD_SERVERS} from "./constants";
|
||||||
const CLASSWORKS_CLOUD_SERVERS = [
|
|
||||||
"https://kv-service.houlang.cloud",
|
|
||||||
"https://kv-service.wuyuan.dev"
|
|
||||||
];
|
|
||||||
|
|
||||||
const classworksCloudDefaults = {
|
const classworksCloudDefaults = {
|
||||||
"server.domain": import.meta.env.VITE_DEFAULT_KV_SERVER || CLASSWORKS_CLOUD_SERVERS[0],
|
"server.domain": import.meta.env.VITE_DEFAULT_KV_SERVER || CLASSWORKS_CLOUD_SERVERS[0],
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user