fix: auto configure (#726)

This commit is contained in:
0xffffharry 2024-06-02 21:22:20 +08:00 committed by GitHub
parent 14215e20e5
commit ce4f67d650
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,11 +108,21 @@ export default () => {
}
onMount(() => {
const query = new URLSearchParams(location.search)
let search = location.search
if (search.length === 0) {
const searchList = location.hash.match(/\?.*$/)
if (searchList.length > 0 && searchList[0].length > 0) {
search = searchList[0].replace('?', '', 1)
}
}
const query = new URLSearchParams(search)
if (query.has('hostname')) {
void onSubmit({
url: `${window.location.protocol}//${query.get('hostname')}${
url: `${query.get('http') ? 'http:' : query.get('https') ? 'https:' : window.location.protocol}//${query.get('hostname')}${
query.get('port') ? `:${query.get('port')}` : ''
}`,
secret: query.get('secret') ?? '',