This commit is contained in:
eric
2026-03-25 16:14:50 -05:00
parent e884d5691e
commit e764abb32a
14 changed files with 198 additions and 235 deletions

View File

@@ -1,6 +1,5 @@
import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'
import { Platform } from 'react-native'
import { isExpoEasyTierVpnAvailable, saveAndPrepareTunnel } from '@/lib/easyTierVpn'
import type { BindPayload } from '@/lib/types'
import { clearBindPayload, loadBindPayload, saveBindPayload } from '@/lib/storage'
@@ -27,22 +26,13 @@ export function BindProvider({ children }: { children: React.ReactNode }) {
useEffect(() => {
if (!ready || !bind) return
if (Platform.OS === 'android' && isExpoEasyTierVpnAvailable()) {
void saveAndPrepareTunnel(bind.easytier).catch(() => {})
}
// 现在仅做 baseUrl/token 的远程控制绑定,不再在 App 内启动 EasyTier 数据面
}, [ready, bind])
const setBind = useCallback(async (p: BindPayload | null) => {
setBindState(p)
if (p) await saveBindPayload(p)
else await clearBindPayload()
if (p && Platform.OS === 'android' && isExpoEasyTierVpnAvailable()) {
try {
await saveAndPrepareTunnel(p.easytier)
} catch {
/* 组网内核未就绪或用户未授权 VPN 时不阻断配对 */
}
}
}, [])
const clear = useCallback(async () => {