mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-19 06:21:56 +08:00
parent
47be9c2469
commit
15e97f0200
@ -12,6 +12,10 @@ export function removeLocalStorageItem (key: string) {
|
|||||||
|
|
||||||
export function noop () {}
|
export function noop () {}
|
||||||
|
|
||||||
|
export function getSearchParam(key: string) {
|
||||||
|
return new URLSearchParams(window.location.search).get(key)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* to return Promise<[T, Error]>
|
* to return Promise<[T, Error]>
|
||||||
* @param {Promise<T>} promise
|
* @param {Promise<T>} promise
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { getLocalStorageItem, to } from '@lib/helper'
|
import { getLocalStorageItem, getSearchParam, to } from '@lib/helper'
|
||||||
import { isClashX, jsBridge } from '@lib/jsBridge'
|
import { isClashX, jsBridge } from '@lib/jsBridge'
|
||||||
import { createAsyncSingleton } from '@lib/asyncSingleton'
|
import { createAsyncSingleton } from '@lib/asyncSingleton'
|
||||||
import { Log } from '@models/Log'
|
import { Log } from '@models/Log'
|
||||||
@ -119,10 +119,10 @@ export async function getExternalControllerConfig () {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const hostname = getLocalStorageItem('externalControllerAddr', url?.hostname ?? '127.0.0.1')
|
const hostname = getSearchParam('host') ?? getLocalStorageItem('externalControllerAddr', url?.hostname ?? '127.0.0.1')
|
||||||
const port = getLocalStorageItem('externalControllerPort', url?.port ?? '9090')
|
const port = getSearchParam('port') ?? getLocalStorageItem('externalControllerPort', url?.port ?? '9090')
|
||||||
const secret = getLocalStorageItem('secret', url?.username ?? '')
|
const secret = getSearchParam('secret') ?? getLocalStorageItem('secret', url?.username ?? '')
|
||||||
const protocol = hostname === '127.0.0.1' ? 'http:' : (url?.protocol ?? window.location.protocol)
|
const protocol = getSearchParam('protocol') ?? hostname === '127.0.0.1' ? 'http:' : (url?.protocol ?? window.location.protocol)
|
||||||
|
|
||||||
if (!hostname || !port) {
|
if (!hostname || !port) {
|
||||||
throw new Error('can\'t get hostname or port')
|
throw new Error('can\'t get hostname or port')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user