generated from VLADIMIR/template_frontend
add storage
This commit is contained in:
@@ -12,7 +12,14 @@
|
||||
<n-input v-model:value="password" type="password" placeholder="********" />
|
||||
<div class="form-button-wrapper">
|
||||
<div class="form-label">
|
||||
<n-button @click="signin" :disabled="email.length == 0 || password.length == 0">Вход</n-button>
|
||||
<n-button @click="signin" :disabled="email.length == 0 || password.length == 0">
|
||||
<span v-if="!authStore.isLoading">
|
||||
Вход
|
||||
</span>
|
||||
<span v-else>
|
||||
Подождите...
|
||||
</span>
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</n-space>
|
||||
@@ -36,8 +43,14 @@
|
||||
</div>
|
||||
<div class="form-button-wrapper">
|
||||
<div class="form-label">
|
||||
<n-button @click="signup"
|
||||
:disabled="username.length == 0 || password.length == 0 || !approval">Регистрация</n-button>
|
||||
<n-button @click="signup" :disabled="username.length == 0 || password.length == 0 || !approval">
|
||||
<span v-if="!authStore.isLoading">
|
||||
Регистрация
|
||||
</span>
|
||||
<span v-else>
|
||||
Подождите...
|
||||
</span>
|
||||
</n-button>
|
||||
</div>
|
||||
</div>
|
||||
</n-space>
|
||||
@@ -50,7 +63,15 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue'
|
||||
|
||||
import { NCard, NTabs, NTabPane, NCheckbox, NButton, NSpace, NInput, NAutoComplete } from 'naive-ui'
|
||||
import { NCard, NTabs, NTabPane, NCheckbox, NButton, NSpace, NInput, NAutoComplete, useMessage } from 'naive-ui'
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
const username = ref('')
|
||||
const email = ref('')
|
||||
@@ -68,15 +89,27 @@ const options = computed(() => {
|
||||
})
|
||||
})
|
||||
|
||||
function signin() {
|
||||
console.log(email.value)
|
||||
console.log(password.value)
|
||||
async function signin() {
|
||||
const res = await authStore.login(email.value, password.value)
|
||||
|
||||
if (!res && authStore.error != null) {
|
||||
message.error(authStore.error)
|
||||
return
|
||||
}
|
||||
|
||||
router.push('/office')
|
||||
}
|
||||
|
||||
function signup() {
|
||||
console.log(username.value)
|
||||
console.log(email.value)
|
||||
console.log(approval.value)
|
||||
async function signup() {
|
||||
if (!approval.value) {
|
||||
return
|
||||
}
|
||||
const res = await authStore.signup(username.value, email.value)
|
||||
if (!res && authStore.error != null) {
|
||||
message.error(authStore.error)
|
||||
return
|
||||
}
|
||||
message.error("Пароль отправлен на почту")
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user