2021-04-22 22:29:33 +09:00
|
|
|
<template>
|
2022-06-20 17:38:49 +09:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header><XHeader :actions="headerActions" :tabs="headerTabs"/></template>
|
|
|
|
<MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
|
|
|
|
<FormSuspense :p="init">
|
2023-01-06 13:40:17 +09:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 21:04:56 +09:00
|
|
|
<FormSwitch v-model="enableEmail">
|
2022-06-21 19:48:28 +09:00
|
|
|
<template #label>{{ i18n.ts.enableEmail }} ({{ i18n.ts.recommended }})</template>
|
2022-06-20 17:38:49 +09:00
|
|
|
<template #caption>{{ i18n.ts.emailConfigInfo }}</template>
|
|
|
|
</FormSwitch>
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
<template v-if="enableEmail">
|
2023-01-05 21:04:56 +09:00
|
|
|
<FormInput v-model="email" type="email">
|
2022-06-20 17:38:49 +09:00
|
|
|
<template #label>{{ i18n.ts.emailAddress }}</template>
|
|
|
|
</FormInput>
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ i18n.ts.smtpConfig }}</template>
|
2023-01-05 21:04:56 +09:00
|
|
|
|
2023-01-06 13:40:17 +09:00
|
|
|
<div class="_gaps_m">
|
2023-01-05 21:04:56 +09:00
|
|
|
<FormSplit :min-width="280">
|
|
|
|
<FormInput v-model="smtpHost">
|
|
|
|
<template #label>{{ i18n.ts.smtpHost }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="smtpPort" type="number">
|
|
|
|
<template #label>{{ i18n.ts.smtpPort }}</template>
|
|
|
|
</FormInput>
|
|
|
|
</FormSplit>
|
|
|
|
<FormSplit :min-width="280">
|
|
|
|
<FormInput v-model="smtpUser">
|
|
|
|
<template #label>{{ i18n.ts.smtpUser }}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput v-model="smtpPass" type="password">
|
|
|
|
<template #label>{{ i18n.ts.smtpPass }}</template>
|
|
|
|
</FormInput>
|
|
|
|
</FormSplit>
|
|
|
|
<FormInfo>{{ i18n.ts.emptyToDisableSmtpAuth }}</FormInfo>
|
|
|
|
<FormSwitch v-model="smtpSecure">
|
|
|
|
<template #label>{{ i18n.ts.smtpSecure }}</template>
|
|
|
|
<template #caption>{{ i18n.ts.smtpSecureInfo }}</template>
|
|
|
|
</FormSwitch>
|
|
|
|
</div>
|
2022-06-20 17:38:49 +09:00
|
|
|
</FormSection>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</FormSuspense>
|
|
|
|
</MkSpacer>
|
|
|
|
</MkStickyContainer>
|
2021-04-22 22:29:33 +09:00
|
|
|
</template>
|
|
|
|
|
2022-05-14 21:36:12 +09:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { } from 'vue';
|
2022-06-20 17:38:49 +09:00
|
|
|
import XHeader from './_header_.vue';
|
2021-12-30 21:47:48 +09:00
|
|
|
import FormSwitch from '@/components/form/switch.vue';
|
|
|
|
import FormInput from '@/components/form/input.vue';
|
2022-09-06 18:21:49 +09:00
|
|
|
import FormInfo from '@/components/MkInfo.vue';
|
2021-12-30 21:47:48 +09:00
|
|
|
import FormSuspense from '@/components/form/suspense.vue';
|
|
|
|
import FormSplit from '@/components/form/split.vue';
|
|
|
|
import FormSection from '@/components/form/section.vue';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as os from '@/os';
|
2022-05-14 21:36:12 +09:00
|
|
|
import { fetchInstance, instance } from '@/instance';
|
|
|
|
import { i18n } from '@/i18n';
|
2022-06-20 17:38:49 +09:00
|
|
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-05-14 21:36:12 +09:00
|
|
|
let enableEmail: boolean = $ref(false);
|
|
|
|
let email: any = $ref(null);
|
|
|
|
let smtpSecure: boolean = $ref(false);
|
|
|
|
let smtpHost: string = $ref('');
|
|
|
|
let smtpPort: number = $ref(0);
|
|
|
|
let smtpUser: string = $ref('');
|
|
|
|
let smtpPass: string = $ref('');
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-05-14 21:36:12 +09:00
|
|
|
async function init() {
|
|
|
|
const meta = await os.api('admin/meta');
|
|
|
|
enableEmail = meta.enableEmail;
|
|
|
|
email = meta.email;
|
|
|
|
smtpSecure = meta.smtpSecure;
|
|
|
|
smtpHost = meta.smtpHost;
|
|
|
|
smtpPort = meta.smtpPort;
|
|
|
|
smtpUser = meta.smtpUser;
|
|
|
|
smtpPass = meta.smtpPass;
|
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-05-14 21:36:12 +09:00
|
|
|
async function testEmail() {
|
|
|
|
const { canceled, result: destination } = await os.inputText({
|
|
|
|
title: i18n.ts.destination,
|
|
|
|
type: 'email',
|
2022-06-20 17:38:49 +09:00
|
|
|
placeholder: instance.maintainerEmail,
|
2022-05-14 21:36:12 +09:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
|
|
|
os.apiWithDialog('admin/send-email', {
|
|
|
|
to: destination,
|
|
|
|
subject: 'Test email',
|
2022-06-20 17:38:49 +09:00
|
|
|
text: 'Yo',
|
2022-05-14 21:36:12 +09:00
|
|
|
});
|
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-05-14 21:36:12 +09:00
|
|
|
function save() {
|
|
|
|
os.apiWithDialog('admin/update-meta', {
|
|
|
|
enableEmail,
|
|
|
|
email,
|
|
|
|
smtpSecure,
|
|
|
|
smtpHost,
|
|
|
|
smtpPort,
|
|
|
|
smtpUser,
|
|
|
|
smtpPass,
|
|
|
|
}).then(() => {
|
|
|
|
fetchInstance();
|
|
|
|
});
|
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2022-06-20 17:38:49 +09:00
|
|
|
const headerActions = $computed(() => [{
|
|
|
|
asFullButton: true,
|
|
|
|
text: i18n.ts.testEmail,
|
|
|
|
handler: testEmail,
|
|
|
|
}, {
|
|
|
|
asFullButton: true,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-check',
|
2022-06-20 17:38:49 +09:00
|
|
|
text: i18n.ts.save,
|
|
|
|
handler: save,
|
|
|
|
}]);
|
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.emailServer,
|
2022-12-19 19:01:30 +09:00
|
|
|
icon: 'ti ti-mail',
|
2021-04-22 22:29:33 +09:00
|
|
|
});
|
|
|
|
</script>
|