fix: UI admin page show modal when no need password (#419)

This commit is contained in:
Dream Hunter
2024-08-17 23:54:03 +08:00
committed by GitHub
parent 34e3e1b439
commit 6d4783e1cd
2 changed files with 9 additions and 9 deletions

View File

@@ -1,5 +1,5 @@
<script setup>
import { onMounted } from 'vue';
import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n'
import { useGlobalState } from '../store'
@@ -30,6 +30,7 @@ const message = useMessage()
const authFunc = async () => {
try {
adminAuth.value = tmpAdminAuth.value;
location.reload()
} catch (error) {
message.error(error.message || "error");
@@ -85,22 +86,21 @@ const { t } = useI18n({
}
});
const showAdminPasswordModal = computed(() => !showAdminPage.value || showAdminAuth.value)
const tmpAdminAuth = ref('')
onMounted(async () => {
// make sure user_id is fetched
if (!userSettings.value.user_id) await api.getUserSettings(message);
if (!showAdminPage.value) {
showAdminAuth.value = true;
return;
}
})
</script>
<template>
<div>
<n-modal v-model:show="showAdminAuth" :closable="false" :closeOnEsc="false" :maskClosable="false" preset="dialog"
:title="t('accessHeader')">
<n-modal v-model:show="showAdminPasswordModal" :closable="false" :closeOnEsc="false" :maskClosable="false"
preset="dialog" :title="t('accessHeader')">
<p>{{ t('accessTip') }}</p>
<n-input v-model:value="adminAuth" type="textarea" :autosize="{ minRows: 3 }" />
<n-input v-model:value="tmpAdminAuth" type="password" show-password-on="click" />
<template #action>
<n-button @click="authFunc" type="primary" :loading="loading">
{{ t('ok') }}

View File

@@ -260,7 +260,7 @@ onMounted(async () => {
<n-modal v-model:show="showAuth" :closable="false" :closeOnEsc="false" :maskClosable="false" preset="dialog"
:title="t('accessHeader')">
<p>{{ t('accessTip') }}</p>
<n-input v-model:value="auth" type="textarea" :autosize="{ minRows: 3 }" />
<n-input v-model:value="auth" type="password" show-password-on="click" />
<template #action>
<n-button :loading="loading" @click="authFunc" type="primary">
{{ t('ok') }}