elk/components/user/UserSignIn.vue

38 lines
1,020 B
Vue
Raw Normal View History

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>
<form text-center justify-center items-center flex="~ col gap2" @submit.prevent="oauth">
2022-11-23 03:48:01 +00:00
<div text-3xl mb2>
{{ $t('action.sign_in') }}
2022-11-23 02:53:22 +00:00
</div>
2022-11-23 03:48:01 +00:00
<div>Mastodon Server Name</div>
2022-11-26 03:53:23 +00:00
<div flex bg-gray:10 px2 py1 mxa rounded border="~ border" text-xl items-center>
<span text-secondary-light mr1 text-sm>https://</span>
2022-11-29 12:04:16 +00:00
<input ref="input" v-model="server" :placeholder="DEFAULT_SERVER" outline-none bg-transparent @input="handleInput">
2022-11-23 03:06:56 +00:00
</div>
<button btn-solid mt2>
{{ $t('action.sign_in') }}
2022-11-23 03:06:56 +00:00
</button>
</form>
2022-11-23 02:53:22 +00:00
</template>