(url: string)
| 473 | |
| 474 | const fetchingRemoteConfig = ref(false) |
| 475 | const fetchRemoteConfigAPI = async (url: string) => { |
| 476 | fetchingRemoteConfig.value = true |
| 477 | try { |
| 478 | if (useControlInfo().hasFeature('profiles')) { |
| 479 | // Server/desktop: import the URL as a persisted remote profile and |
| 480 | // activate it. The agent fetches it (correct UA + subscription-userinfo), |
| 481 | // writes the active config, and restarts the kernel — so the fetched |
| 482 | // config survives a restart, unlike PUT /configs which only loads it into |
| 483 | // the running kernel and is lost on the next restart (#2070). This also |
| 484 | // works on a fresh server with no profile yet, and surfaces the import in |
| 485 | // the Profiles page for later refresh/management. |
| 486 | const api = useControlApi() |
| 487 | const meta = await api.importProfile(url) |
| 488 | await api.activateProfile(meta.id) |
| 489 | return |
| 490 | } |
| 491 | // Plain remote mihomo backend (no agent): hot-load into the running kernel. |
| 492 | const response = await ky.get(url) |
| 493 | const payload = await response.text() |
| 494 | await useRequest().put('configs', { |
| 495 | searchParams: { force: true }, |
| 496 | json: { path: '', payload }, |
| 497 | }) |
| 498 | } catch (error) { |
| 499 | console.error('Failed to fetch remote config:', error) |
| 500 | throw error |
| 501 | } finally { |
| 502 | fetchingRemoteConfig.value = false |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | const flushFakeIPDataAPI = async () => { |
| 507 | const request = useRequest() |
nothing calls this directly
no test coverage detected