2
0
mirror of https://github.com/acepanel/panel.git synced 2026-02-04 10:17:17 +08:00

fix: 数据库host填写不了

This commit is contained in:
2026-01-16 22:15:37 +08:00
parent 918d8c2104
commit f437740438
2 changed files with 30 additions and 10 deletions

View File

@@ -16,11 +16,21 @@ const createModel = ref({
const servers = ref<{ label: string; value: string }[]>([])
const hostType = [
const hostTypeOptions = [
{ label: $gettext('Local (localhost)'), value: 'localhost' },
{ label: $gettext('All (%)'), value: '%' },
{ label: $gettext('Specific'), value: '' }
{ label: $gettext('Specific'), value: 'specific' }
]
const hostType = ref('localhost')
// 监听 hostType 变化,同步到 createModel.host
watch(hostType, (val) => {
if (val !== 'specific') {
createModel.value.host = val
} else {
createModel.value.host = ''
}
})
const handleCreate = () => {
useRequest(() => database.create(createModel.value)).onSuccess(() => {
@@ -110,14 +120,14 @@ watch(
</n-form-item>
<n-form-item v-if="createModel.create_user" path="host-select" :label="$gettext('Host')">
<n-select
v-model:value="createModel.host"
v-model:value="hostType"
@keydown.enter.prevent
:placeholder="$gettext('Select host')"
:options="hostType"
:options="hostTypeOptions"
/>
</n-form-item>
<n-form-item
v-if="createModel.create_user && createModel.host === ''"
v-if="createModel.create_user && hostType === 'specific'"
path="host"
:label="$gettext('Specific Host')"
>

View File

@@ -16,11 +16,21 @@ const createModel = ref({
const servers = ref<{ label: string; value: string }[]>([])
const hostType = [
const hostTypeOptions = [
{ label: $gettext('Local (localhost)'), value: 'localhost' },
{ label: $gettext('All (%)'), value: '%' },
{ label: $gettext('Specific'), value: '' }
{ label: $gettext('Specific'), value: 'specific' }
]
const hostType = ref('localhost')
// 监听 hostType 变化,同步到 createModel.host
watch(hostType, (val) => {
if (val !== 'specific') {
createModel.value.host = val
} else {
createModel.value.host = ''
}
})
const handleCreate = () => {
useRequest(() => database.userCreate(createModel.value)).onSuccess(() => {
@@ -93,13 +103,13 @@ watch(
</n-form-item>
<n-form-item path="host-select" :label="$gettext('Host (MySQL only)')">
<n-select
v-model:value="createModel.host"
v-model:value="hostType"
@keydown.enter.prevent
:placeholder="$gettext('Select host')"
:options="hostType"
:options="hostTypeOptions"
/>
</n-form-item>
<n-form-item v-if="createModel.host === ''" path="host" :label="$gettext('Specific Host')">
<n-form-item v-if="hostType === 'specific'" path="host" :label="$gettext('Specific Host')">
<n-input
v-model:value="createModel.host"
type="text"