fix: 修复显示“认证失败,请重新登录”,却找不到登录框 #247 #255

This commit is contained in:
James Chen
2025-12-13 22:26:00 +08:00
parent c473581c26
commit 487c15d8b6

View File

@@ -2,6 +2,7 @@ import { create } from "zustand";
import { SettingsManager } from "@/services/storage";
import { api, ServerConfig } from "@/services/api";
import { storageConfig } from "@/services/storageConfig";
import AsyncStorage from "@react-native-async-storage/async-storage";
import Logger from "@/utils/Logger";
const logger = Logger.withTag('SettingsStore');
@@ -79,7 +80,8 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
setVideoSource: (config) => set({ videoSource: config }),
saveSettings: async () => {
const { apiBaseUrl, m3uUrl, remoteInputEnabled, videoSource } = get();
const currentSettings = await SettingsManager.get()
const currentApiBaseUrl = currentSettings.apiBaseUrl;
let processedApiBaseUrl = apiBaseUrl.trim();
if (processedApiBaseUrl.endsWith("/")) {
processedApiBaseUrl = processedApiBaseUrl.slice(0, -1);
@@ -105,6 +107,9 @@ export const useSettingsStore = create<SettingsState>((set, get) => ({
remoteInputEnabled,
videoSource,
});
if ( currentApiBaseUrl !== processedApiBaseUrl) {
await AsyncStorage.setItem('authCookies', '');
}
api.setBaseUrl(processedApiBaseUrl);
// Also update the URL in the state so the input field shows the processed URL
set({ isModalVisible: false, apiBaseUrl: processedApiBaseUrl });