pstream is dead; long live pstream taciturnaxolotl.github.io/pstream-ng/
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Revert "admin page add m3u8 workers"

This reverts commit 81b67dae9098751c1dc54fef09715b41fd65aa71.

Pas f1065e96 467c4ea2

+9 -114
+9 -114
src/pages/parts/admin/M3U8TestPart.tsx
··· 6 6 import { Toggle } from "@/components/buttons/Toggle"; 7 7 import { Icon, Icons } from "@/components/Icon"; 8 8 import { Box } from "@/components/layout/Box"; 9 - import { AuthInputBox } from "@/components/text-inputs/AuthInputBox"; 10 9 import { Divider } from "@/components/utils/Divider"; 11 10 import { Heading2 } from "@/components/utils/Text"; 12 11 import { getM3U8ProxyUrls } from "@/utils/proxyUrls"; 13 - 14 - interface M3U8Proxy { 15 - id: string; 16 - url: string; 17 - } 18 12 19 13 export function M3U8ProxyItem(props: { 20 14 name: string; ··· 63 57 } 64 58 65 59 export function M3U8TestPart() { 66 - const defaultProxyList = useMemo(() => { 60 + const m3u8ProxyList = useMemo(() => { 67 61 return getM3U8ProxyUrls().map((v, ind) => ({ 68 62 id: ind.toString(), 69 63 url: v, 70 64 })); 71 65 }, []); 72 66 73 - // Load editable proxy list from localStorage 74 - const [m3u8ProxyList, setM3u8ProxyList] = useState<M3U8Proxy[]>(() => { 75 - const saved = localStorage.getItem("m3u8-proxy-list"); 76 - if (saved) { 77 - try { 78 - return JSON.parse(saved); 79 - } catch { 80 - return defaultProxyList; 81 - } 82 - } 83 - return defaultProxyList; 84 - }); 85 - 86 67 // Load enabled proxies from localStorage 87 68 const [enabledProxies, setEnabledProxies] = useState<Record<string, boolean>>( 88 69 () => { ··· 99 80 }, 100 81 ); 101 82 102 - // Save proxy list to localStorage 103 - useEffect(() => { 104 - localStorage.setItem("m3u8-proxy-list", JSON.stringify(m3u8ProxyList)); 105 - }, [m3u8ProxyList]); 106 - 107 83 // Save enabled proxies to localStorage 108 84 useEffect(() => { 109 85 localStorage.setItem("m3u8-proxy-enabled", JSON.stringify(enabledProxies)); ··· 130 106 setProxyState([]); 131 107 132 108 const activeProxies = m3u8ProxyList.filter( 133 - (proxy: M3U8Proxy) => enabledProxies[proxy.id], 109 + (proxy) => enabledProxies[proxy.id], 134 110 ); 135 - const proxyPromises = activeProxies.map(async (proxy: M3U8Proxy) => { 111 + const proxyPromises = activeProxies.map(async (proxy) => { 136 112 try { 137 113 if (proxy.url.endsWith("/")) { 138 114 updateProxy(proxy.id, { ··· 177 153 })); 178 154 }; 179 155 180 - const addProxy = () => { 181 - const newId = Date.now().toString(); 182 - setM3u8ProxyList((prev: M3U8Proxy[]) => [...prev, { id: newId, url: "" }]); 183 - setEnabledProxies((prev) => ({ ...prev, [newId]: true })); 184 - }; 185 - 186 - const changeProxy = (id: string, url: string) => { 187 - setM3u8ProxyList((prev: M3U8Proxy[]) => 188 - prev.map((proxy: M3U8Proxy) => 189 - proxy.id === id ? { ...proxy, url } : proxy, 190 - ), 191 - ); 192 - }; 193 - 194 - const removeProxy = (id: string) => { 195 - setM3u8ProxyList((prev: M3U8Proxy[]) => 196 - prev.filter((proxy: M3U8Proxy) => proxy.id !== id), 197 - ); 198 - setEnabledProxies((prev) => { 199 - const newEnabled = { ...prev }; 200 - delete newEnabled[id]; 201 - return newEnabled; 202 - }); 203 - }; 204 - 205 - const resetProxies = () => { 206 - setM3u8ProxyList(defaultProxyList); 207 - setEnabledProxies( 208 - Object.fromEntries( 209 - defaultProxyList.map((proxy: M3U8Proxy) => [proxy.id, true]), 210 - ), 211 - ); 212 - }; 213 - 214 - const allEnabled = m3u8ProxyList.every( 215 - (proxy: M3U8Proxy) => enabledProxies[proxy.id], 216 - ); 217 - const noneEnabled = m3u8ProxyList.every( 218 - (proxy: M3U8Proxy) => !enabledProxies[proxy.id], 219 - ); 156 + const allEnabled = m3u8ProxyList.every((proxy) => enabledProxies[proxy.id]); 157 + const noneEnabled = m3u8ProxyList.every((proxy) => !enabledProxies[proxy.id]); 220 158 221 159 const handleToggleAll = () => { 222 160 if (allEnabled) { 223 161 // Disable all 224 162 setEnabledProxies( 225 - Object.fromEntries( 226 - m3u8ProxyList.map((proxy: M3U8Proxy) => [proxy.id, false]), 227 - ), 163 + Object.fromEntries(m3u8ProxyList.map((proxy) => [proxy.id, false])), 228 164 ); 229 165 } else { 230 166 // Enable all 231 167 setEnabledProxies( 232 - Object.fromEntries( 233 - m3u8ProxyList.map((proxy: M3U8Proxy) => [proxy.id, true]), 234 - ), 168 + Object.fromEntries(m3u8ProxyList.map((proxy) => [proxy.id, true])), 235 169 ); 236 170 } 237 171 }; 238 172 239 173 const enabledCount = m3u8ProxyList.filter( 240 - (proxy: M3U8Proxy) => enabledProxies[proxy.id], 174 + (proxy) => enabledProxies[proxy.id], 241 175 ).length; 242 176 243 177 return ( 244 178 <> 245 - <Heading2 className="!mb-0 mt-12">M3U8 Proxy Configuration</Heading2> 246 - <Box> 247 - <p className="text-white font-bold mb-3">M3U8 Proxy URLs</p> 248 - </Box> 249 - 250 179 <Heading2 className="!mb-0 mt-12">M3U8 Proxy tests</Heading2> 251 180 <div className="flex items-center justify-between mb-8 mt-2"> 252 181 <p> ··· 262 191 </Button> 263 192 </div> 264 193 <Box> 265 - {m3u8ProxyList.map((v: M3U8Proxy, i: number) => { 194 + {m3u8ProxyList.map((v, i) => { 266 195 const s = proxyState.find((segment) => segment.id === v.id); 267 196 const name = `M3U8 Proxy ${i + 1}`; 268 197 const enabled = enabledProxies[v.id]; ··· 379 308 Test M3U8 proxies 380 309 </Button> 381 310 )} 382 - </div> 383 - <Divider /> 384 - <div className="my-6 space-y-2"> 385 - {m3u8ProxyList.length === 0 ? ( 386 - <p>No M3U8 proxies configured.</p> 387 - ) : ( 388 - m3u8ProxyList.map((proxy: M3U8Proxy) => ( 389 - <div 390 - key={proxy.id} 391 - className="grid grid-cols-[1fr,auto] items-center gap-2" 392 - > 393 - <AuthInputBox 394 - value={proxy.url} 395 - onChange={(url) => changeProxy(proxy.id, url)} 396 - placeholder="https://" 397 - /> 398 - <button 399 - type="button" 400 - onClick={() => removeProxy(proxy.id)} 401 - className="h-full scale-90 hover:scale-100 rounded-full aspect-square bg-authentication-inputBg hover:bg-authentication-inputBgHover flex justify-center items-center transition-transform duration-200 hover:text-white cursor-pointer" 402 - > 403 - <Icon className="text-xl" icon={Icons.X} /> 404 - </button> 405 - </div> 406 - )) 407 - )} 408 - </div> 409 - <div className="flex gap-2"> 410 - <Button theme="purple" onClick={addProxy}> 411 - Add Proxy 412 - </Button> 413 - <Button theme="secondary" onClick={resetProxies}> 414 - Reset to Default 415 - </Button> 416 311 </div> 417 312 </Box> 418 313 </>