fix: 安装页端口只允许数字,安装按钮改为通栏
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from "vue";
|
||||
import { useRouter } from "vue-router";
|
||||
import { NAlert, NButton, NInput, NInputNumber } from "naive-ui";
|
||||
import { NAlert, NButton, NInput } from "naive-ui";
|
||||
import { api } from "../../shared/http";
|
||||
import { markInstalled } from "../../shared/installState";
|
||||
import ThemeButton from "../../shell/ThemeButton.vue";
|
||||
|
||||
const router = useRouter();
|
||||
const host = ref("127.0.0.1");
|
||||
const port = ref(5432);
|
||||
const port = ref("5432");
|
||||
const database = ref("decom");
|
||||
const username = ref("postgres");
|
||||
const password = ref("nixevol@242520");
|
||||
@@ -22,12 +22,21 @@ onMounted(async () => {
|
||||
const defaults = status.defaults;
|
||||
if (!defaults) return;
|
||||
if (defaults.host) host.value = defaults.host;
|
||||
if (defaults.port) port.value = defaults.port;
|
||||
if (defaults.port) port.value = String(defaults.port);
|
||||
if (defaults.database) database.value = defaults.database;
|
||||
if (defaults.username) username.value = defaults.username;
|
||||
});
|
||||
|
||||
function allowPort(value: string) {
|
||||
return /^\d{0,5}$/.test(value);
|
||||
}
|
||||
|
||||
async function submit() {
|
||||
const portNumber = Number(port.value);
|
||||
if (!port.value || portNumber < 1 || portNumber > 65535) {
|
||||
errorText.value = "端口需要在 1 到 65535 之间";
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
errorText.value = "";
|
||||
try {
|
||||
@@ -35,7 +44,7 @@ async function submit() {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
host: host.value,
|
||||
port: port.value,
|
||||
port: portNumber,
|
||||
database: database.value,
|
||||
username: username.value,
|
||||
password: password.value,
|
||||
@@ -66,7 +75,7 @@ async function submit() {
|
||||
<label>数据库主机</label>
|
||||
<n-input v-model:value="host" />
|
||||
<label>端口</label>
|
||||
<n-input-number v-model:value="port" :min="1" :max="65535" />
|
||||
<n-input v-model:value="port" :allow-input="allowPort" placeholder="5432" :input-props="{ inputmode: 'numeric', autocomplete: 'off' }" />
|
||||
<label>数据库名</label>
|
||||
<n-input v-model:value="database" />
|
||||
<label>数据库用户</label>
|
||||
@@ -78,9 +87,7 @@ async function submit() {
|
||||
<label>管理员密码</label>
|
||||
<n-input v-model:value="adminPassword" type="password" />
|
||||
</div>
|
||||
<div style="margin-top: 16px; display: flex; justify-content: flex-end;">
|
||||
<n-button type="primary" :loading="busy" @click="submit">完成安装</n-button>
|
||||
</div>
|
||||
<n-button class="install-submit" type="primary" :loading="busy" @click="submit">完成安装</n-button>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -99,6 +99,13 @@ button, input, select { font: inherit; }
|
||||
padding: 28px 28px 22px;
|
||||
}
|
||||
.gate-card.wide { width: min(560px, 100%); }
|
||||
.install-submit.n-button {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
margin-top: 24px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 0.12em;
|
||||
}
|
||||
.gate-brand {
|
||||
display: flex;
|
||||
gap: 14px;
|
||||
|
||||
Reference in New Issue
Block a user