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