import React, { useState, useEffect, useRef } from 'react';
import { StatusBar, Alert, ActivityIndicator, Image, ImageBackground, StyleSheet, Text, View } from 'react-native';
import { NavigationContainer, useNavigation } from '@react-navigation/native';
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import { Audio, AVPlaybackStatus } from 'expo-av';
import * as SplashScreen from 'expo-splash-screen';
import Svg, { Path } from 'react-native-svg';
import { theme } from './theme';
import { Track, RepeatMode, CacheInfo, UserConfig, SortMode } from './types';
import * as API from './api';
import * as Cache from './utils/cache';
import { PlayerScreen } from './screens/PlayerScreen';
import { PlaylistScreen } from './screens/PlaylistScreen';
import { SettingsScreen } from './screens/SettingsScreen';
import { LoginScreen } from './screens/LoginScreen';
// 安全地编码 URL 中的路径部分
const encodeUrlPath = (url: string): string => {
try {
const parsedUrl = new URL(url);
const pathParts = parsedUrl.pathname.split('/');
const encodedPathParts = pathParts.map((part, index) => {
if (part === '') return part;
return encodeURIComponent(decodeURIComponent(part));
});
parsedUrl.pathname = encodedPathParts.join('/');
return parsedUrl.toString();
} catch (error) {
console.error('[URL] 编码失败:', error);
try {
return encodeURI(url);
} catch {
return url;
}
}
};
const Tab = createBottomTabNavigator();
void SplashScreen.preventAutoHideAsync().catch(() => {});
SplashScreen.setOptions({
duration: 500,
fade: true,
});
const PlayIconNav = ({ color, size }: { color: string; size: number }) => (
);
const ListIconNav = ({ color, size }: { color: string; size: number }) => (
);
const SettingsIconNav = ({ color, size }: { color: string; size: number }) => (
);
const StartupLoadingScreen = () => (
观空禅音
正在加载歌单与缓存...
);
const TabNavigator = () => {
const [tracks, setTracks] = useState