Skip to content

Commit

Permalink
fix: host save for setup & style
Browse files Browse the repository at this point in the history
  • Loading branch information
Zephyruso committed Dec 9, 2024
1 parent 7e31034 commit cd24cd9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/components/proxies/ProxyNodeCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div
:class="
twMerge(
'flex cursor-pointer flex-wrap items-center justify-end gap-1 rounded-btn bg-base-200 p-2 shadow-lg shadow-md sm:hover:scale-105',
'flex cursor-pointer flex-wrap items-center justify-end gap-1 rounded-btn bg-base-200 p-2 shadow-md sm:hover:scale-105',
active && 'bg-primary text-primary-content',
truncateProxyName && isTruncated && 'tooltip text-left',
)
Expand Down
56 changes: 37 additions & 19 deletions src/views/SetupPage.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<div class="flex h-full w-full items-center justify-center">
<div
class="flex h-full w-full items-center justify-center bg-base-200/40"
@keydown.enter="handleSubmit(form)"
>
<div
class="toast toast-start toast-top max-w-64 whitespace-normal text-sm"
v-if="tipShowModel"
Expand All @@ -16,14 +19,14 @@
<div class="absolute bottom-4 right-4">
<LanguageSelect />
</div>
<div class="card p-6">
<div class="card px-6 py-2">
<h1 class="mb-4 text-2xl font-semibold">{{ $t('setup') }}</h1>
<div class="form-control mb-4">
<label class="label">
<span class="label-text">{{ $t('protocol') }}</span>
</label>
<select
class="select select-bordered w-full"
class="select select-bordered select-sm w-full"
v-model="form.protocol"
>
<option value="http">HTTP</option>
Expand All @@ -36,7 +39,9 @@
</label>
<input
type="text"
class="input input-bordered w-full"
class="input input-sm input-bordered w-full"
name="username"
autocomplete="username"
v-model="form.host"
/>
</div>
Expand All @@ -46,7 +51,7 @@
</label>
<input
type="text"
class="input input-bordered w-full"
class="input input-sm input-bordered w-full"
v-model="form.port"
/>
</div>
Expand All @@ -56,7 +61,7 @@
</label>
<input
type="password"
class="input input-bordered w-full"
class="input input-sm input-bordered w-full"
v-model="form.password"
/>
</div>
Expand Down Expand Up @@ -127,24 +132,37 @@ const handleSubmit = async (
showTip('protocolTips')
}
const data = await fetch(`${protocol}://${host}:${port}/version`, {
method: 'GET',
headers: {
Authorization: `Bearer ${password}`,
},
})
try {
const data = await fetch(`${protocol}://${host}:${port}/version`, {
method: 'GET',
headers: {
Authorization: `Bearer ${password}`,
},
})
if (data.status !== 200) {
if (!quiet) {
alert(data.statusText)
}
return
}
const { version, message } = await data.json()
const { version, message } = await data.json()
if (!version) {
if (!version) {
if (!quiet) {
alert(message)
}
return
}
addBackend(form)
router.push({ name: 'proxies' })
} catch (e) {
if (!quiet) {
alert(message)
alert(e)
}
return
}
addBackend(form)
router.push({ name: 'proxies' })
}
const query = new URLSearchParams(
Expand Down

0 comments on commit cd24cd9

Please sign in to comment.