2022-12-03 03:20:49 +00:00
|
|
|
<script>
|
|
|
|
import { RouterLink } from "vue-router";
|
2022-12-04 05:19:41 +00:00
|
|
|
import { useVuelidate } from "@vuelidate/core";
|
|
|
|
import { required, helpers } from "@vuelidate/validators";
|
|
|
|
import utils from "../assets/utils";
|
|
|
|
import _ from "lodash/collection";
|
|
|
|
import axios from "axios";
|
2022-12-03 03:20:49 +00:00
|
|
|
|
|
|
|
export default {
|
2022-12-04 05:19:41 +00:00
|
|
|
setup() {
|
|
|
|
return {
|
|
|
|
v$: useVuelidate(),
|
|
|
|
};
|
|
|
|
},
|
2022-12-03 03:20:49 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
server: "",
|
|
|
|
};
|
|
|
|
},
|
2022-12-04 05:19:41 +00:00
|
|
|
validations() {
|
|
|
|
return {
|
|
|
|
server: {
|
|
|
|
required: helpers.withMessage("アドレスを入力してください", required),
|
|
|
|
hostname: helpers.withMessage(
|
|
|
|
"有効なアドレスを入力してください",
|
|
|
|
utils.validators.fqdn
|
|
|
|
),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
serverErrors() {
|
|
|
|
const errors = this.v$.server.$errors;
|
|
|
|
return _.map(errors, (e) => e.$message);
|
|
|
|
},
|
|
|
|
},
|
2022-12-03 03:20:49 +00:00
|
|
|
methods: {
|
2022-12-04 05:19:41 +00:00
|
|
|
async onSubmit() {
|
|
|
|
const isFormCorrect = await this.v$.$validate();
|
|
|
|
if (!isFormCorrect) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const response = await axios.postForm("/api/login", { server: this.server });
|
|
|
|
if (response.status === 201) {
|
|
|
|
// this.$router.push(response.data)
|
|
|
|
location.assign(response.data)
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2022-12-03 03:20:49 +00:00
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<h1>Audon</h1>
|
2022-12-04 05:19:41 +00:00
|
|
|
<v-form ref="form" @submit.prevent="onSubmit" class="my-3" lazy-validation>
|
2022-12-03 03:20:49 +00:00
|
|
|
<v-text-field
|
|
|
|
v-model="server"
|
|
|
|
name="server"
|
2022-12-04 05:19:41 +00:00
|
|
|
label="Mastodon / Pleroma サーバー"
|
2022-12-03 03:20:49 +00:00
|
|
|
placeholder="mastodon.example"
|
|
|
|
class="mb-2"
|
2022-12-04 05:19:41 +00:00
|
|
|
:error-messages="serverErrors"
|
|
|
|
@input="v$.server.$touch"
|
|
|
|
@blur="v$.server.$touch"
|
2022-12-03 03:20:49 +00:00
|
|
|
clearable
|
|
|
|
/>
|
2022-12-04 05:19:41 +00:00
|
|
|
<v-btn block @click="onSubmit" :disabled="!v$.$dirty || v$.$error"
|
|
|
|
>ログイン</v-btn
|
|
|
|
>
|
2022-12-03 03:20:49 +00:00
|
|
|
</v-form>
|
|
|
|
<div class="w-100 text-right">
|
|
|
|
<RouterLink to="/about">利用規約</RouterLink>
|
|
|
|
</div>
|
|
|
|
</template>
|