mirror of
https://github.com/ZeroCatDev/Classworks.git
synced 2026-02-04 07:53:11 +00:00
Update api.js to use tryWithPrimaryServer and clean up unused imports
Co-authored-by: Sunwuyuan <88357633+Sunwuyuan@users.noreply.github.com>
This commit is contained in:
parent
b3969d1fd7
commit
45c48cdf82
@ -1,6 +1,6 @@
|
|||||||
import axios from "@/axios/axios";
|
import axios from "@/axios/axios";
|
||||||
import {getSetting} from "@/utils/settings";
|
import {getSetting} from "@/utils/settings";
|
||||||
import {tryWithRotation, isRotationEnabled} from "@/utils/serverRotation";
|
import {tryWithPrimaryServer, isRotationEnabled} from "@/utils/serverRotation";
|
||||||
|
|
||||||
// Helper function to check if provider is valid for API calls
|
// Helper function to check if provider is valid for API calls
|
||||||
const isValidProvider = () => {
|
const isValidProvider = () => {
|
||||||
@ -35,9 +35,9 @@ export const getNamespaceInfo = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Use rotation for classworkscloud provider
|
// Use primary server with fallback for classworkscloud provider
|
||||||
if (isRotationEnabled()) {
|
if (isRotationEnabled()) {
|
||||||
const response = await tryWithRotation(async (serverUrl) => {
|
const response = await tryWithPrimaryServer(async (serverUrl) => {
|
||||||
return await axios.get(`${serverUrl}/kv/_info`, {
|
return await axios.get(`${serverUrl}/kv/_info`, {
|
||||||
headers: getHeaders(),
|
headers: getHeaders(),
|
||||||
});
|
});
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import {io} from 'socket.io-client';
|
import {io} from 'socket.io-client';
|
||||||
import {getSetting} from '@/utils/settings';
|
import {getSetting} from '@/utils/settings';
|
||||||
import {getEffectiveServerUrl, isRotationEnabled, tryWithRotation} from '@/utils/serverRotation';
|
import {getEffectiveServerUrl, isRotationEnabled} from '@/utils/serverRotation';
|
||||||
|
|
||||||
let socket = null;
|
let socket = null;
|
||||||
let connectedDomain = null;
|
let connectedDomain = null;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user