mirror of
https://github.com/zimplexing/OrionTV.git
synced 2026-02-04 03:36:29 +08:00
feat: enhance login status management and improve error logging across services
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import useAuthStore from "@/stores/authStore";
|
||||
|
||||
// region: --- Interface Definitions ---
|
||||
export interface DoubanItem {
|
||||
@@ -97,7 +96,6 @@ export class API {
|
||||
const response = await fetch(`${this.baseURL}${url}`, options);
|
||||
|
||||
if (response.status === 401) {
|
||||
useAuthStore.getState().showLoginModal();
|
||||
throw new Error("UNAUTHORIZED");
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ export const fetchAndParseM3u = async (m3uUrl: string): Promise<Channel[]> => {
|
||||
const m3uText = await response.text();
|
||||
return parseM3U(m3uText);
|
||||
} catch (error) {
|
||||
console.error("Error fetching or parsing M3U:", error);
|
||||
console.info("Error fetching or parsing M3U:", error);
|
||||
return []; // Return empty array on error
|
||||
}
|
||||
};
|
||||
|
||||
@@ -25,7 +25,7 @@ const getRemotePageHTML = () => {
|
||||
</div>
|
||||
<script>
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
fetch('/handshake', { method: 'POST' }).catch(console.error);
|
||||
fetch('/handshake', { method: 'POST' }).catch(console.info);
|
||||
});
|
||||
function send() {
|
||||
const input = document.getElementById("text");
|
||||
@@ -36,7 +36,7 @@ const getRemotePageHTML = () => {
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ message: value })
|
||||
})
|
||||
.catch(err => console.error(err));
|
||||
.catch(err => console.info(err));
|
||||
input.value = '';
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class RemoteControlService {
|
||||
body: JSON.stringify({ status: "ok" }),
|
||||
};
|
||||
} catch (parseError) {
|
||||
console.error("[RemoteControl] Failed to parse message body:", parseError);
|
||||
console.info("[RemoteControl] Failed to parse message body:", parseError);
|
||||
return {
|
||||
statusCode: 400,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -102,7 +102,7 @@ class RemoteControlService {
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("[RemoteControl] Request handler error:", error);
|
||||
console.info("[RemoteControl] Request handler error:", error);
|
||||
return {
|
||||
statusCode: 500,
|
||||
headers: { "Content-Type": "application/json" },
|
||||
@@ -125,7 +125,7 @@ class RemoteControlService {
|
||||
console.log(`[RemoteControl] Server started successfully at: ${url}`);
|
||||
return url;
|
||||
} catch (error) {
|
||||
console.error("[RemoteControl] Failed to start server:", error);
|
||||
console.info("[RemoteControl] Failed to start server:", error);
|
||||
throw new Error(error instanceof Error ? error.message : "Failed to start server");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ export class PlayerSettingsManager {
|
||||
const data = await AsyncStorage.getItem(STORAGE_KEYS.PLAYER_SETTINGS);
|
||||
return data ? JSON.parse(data) : {};
|
||||
} catch (error) {
|
||||
console.error("Failed to get all player settings:", error);
|
||||
console.info("Failed to get all player settings:", error);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
@@ -192,13 +192,13 @@ export class SettingsManager {
|
||||
sources: {},
|
||||
},
|
||||
m3uUrl:
|
||||
"https://ghfast.top/https://raw.githubusercontent.com/sjnhnp/adblock/refs/heads/main/filtered_http_only_valid.m3u",
|
||||
"",
|
||||
};
|
||||
try {
|
||||
const data = await AsyncStorage.getItem(STORAGE_KEYS.SETTINGS);
|
||||
return data ? { ...defaultSettings, ...JSON.parse(data) } : defaultSettings;
|
||||
} catch (error) {
|
||||
console.error("Failed to get settings:", error);
|
||||
console.info("Failed to get settings:", error);
|
||||
return defaultSettings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class TCPHttpServer {
|
||||
|
||||
return { method, url, headers, body };
|
||||
} catch (error) {
|
||||
console.error('[TCPHttpServer] Error parsing HTTP request:', error);
|
||||
console.info('[TCPHttpServer] Error parsing HTTP request:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -140,7 +140,7 @@ class TCPHttpServer {
|
||||
socket.write(errorResponse);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('[TCPHttpServer] Error handling request:', error);
|
||||
console.info('[TCPHttpServer] Error handling request:', error);
|
||||
const errorResponse = this.formatHttpResponse({
|
||||
statusCode: 500,
|
||||
headers: { 'Content-Type': 'text/plain' },
|
||||
@@ -155,7 +155,7 @@ class TCPHttpServer {
|
||||
});
|
||||
|
||||
socket.on('error', (error: Error) => {
|
||||
console.error('[TCPHttpServer] Socket error:', error);
|
||||
console.info('[TCPHttpServer] Socket error:', error);
|
||||
});
|
||||
|
||||
socket.on('close', () => {
|
||||
@@ -170,13 +170,13 @@ class TCPHttpServer {
|
||||
});
|
||||
|
||||
this.server.on('error', (error: Error) => {
|
||||
console.error('[TCPHttpServer] Server error:', error);
|
||||
console.info('[TCPHttpServer] Server error:', error);
|
||||
this.isRunning = false;
|
||||
reject(error);
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error('[TCPHttpServer] Failed to start server:', error);
|
||||
console.info('[TCPHttpServer] Failed to start server:', error);
|
||||
reject(error);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user