elk/components/user/UserSignIn.vue

49 wiersze
1.5 KiB
Vue
Czysty Zwykły widok Historia

2022-11-23 03:06:56 +00:00
<script setup lang="ts">
import { DEFAULT_SERVER } from '~/constants'
2022-11-29 12:04:16 +00:00
const input = $ref<HTMLInputElement>()
2022-11-23 09:06:32 +00:00
let server = $ref<string>('')
2022-11-23 03:06:56 +00:00
async function oauth() {
2022-11-27 09:29:25 +00:00
if (server)
server = server.split('/')[0]
2022-11-23 09:06:32 +00:00
location.href = `/api/${server || DEFAULT_SERVER}/login`
}
async function handleInput() {
if (server.startsWith('https://'))
server = server.replace('https://', '')
2022-11-23 03:06:56 +00:00
}
2022-11-29 12:04:16 +00:00
onMounted(() => {
input?.focus()
})
2022-11-23 03:06:56 +00:00
</script>
2022-11-23 02:53:22 +00:00
<template>
2022-11-30 01:45:52 +00:00
<form text-center justify-center items-center w-150 py6 flex="~ col gap-3" @submit.prevent="oauth">
<div flex="~ center" mb2>
<img src="/logo.svg" w-12 h-12 mxa alt="logo">
<div text-3xl>
{{ $t('action.sign_in') }}
</div>
</div>
<div>{{ $t('user.server_address_label') }}</div>
<div flex bg-gray:10 px4 py2 mxa rounded border="~ base" items-center font-mono focus:outline-none focus:ring="2 primary inset">
<span text-secondary-light mr1>https://</span>
<input ref="input" v-model="server" outline-none bg-transparent @input="handleInput">
2022-11-23 02:53:22 +00:00
</div>
2022-11-30 01:45:52 +00:00
<div text-secondary text-sm flex>
<div i-ri:lightbulb-line mr-1 />
<span>
<i18n-t keypath="user.tip_no_account">
<a href="https://joinmastodon.org/servers" target="_blank" hover="underline text-primary">{{ $t('user.tip_register_account') }}</a>
</i18n-t>
</span>
2022-11-23 03:06:56 +00:00
</div>
2022-11-30 01:45:52 +00:00
<button btn-solid mt2 :disabled="!server">
{{ $t('action.sign_in') }}
2022-11-23 03:06:56 +00:00
</button>
</form>
2022-11-23 02:53:22 +00:00
</template>