2021-04-22 22:29:33 +09:00
|
|
|
<template>
|
2023-04-08 09:01:42 +09:00
|
|
|
<MkStickyContainer>
|
|
|
|
<template #header
|
|
|
|
><MkPageHeader
|
|
|
|
:actions="headerActions"
|
|
|
|
:tabs="headerTabs"
|
|
|
|
:display-back-button="true"
|
|
|
|
/></template>
|
|
|
|
<MkSpacer :content-max="700" :margin-min="16" :margin-max="32">
|
|
|
|
<FormSuspense :p="init">
|
|
|
|
<div class="_formRoot">
|
|
|
|
<FormSwitch v-model="enableEmail" class="_formBlock">
|
|
|
|
<template #label
|
|
|
|
>{{ i18n.ts.enableEmail }} ({{
|
|
|
|
i18n.ts.recommended
|
|
|
|
}})</template
|
|
|
|
>
|
|
|
|
<template #caption>{{
|
|
|
|
i18n.ts.emailConfigInfo
|
|
|
|
}}</template>
|
|
|
|
</FormSwitch>
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
<template v-if="enableEmail">
|
|
|
|
<FormInput
|
|
|
|
v-model="email"
|
|
|
|
type="email"
|
|
|
|
class="_formBlock"
|
|
|
|
>
|
|
|
|
<template #label>{{
|
|
|
|
i18n.ts.emailAddress
|
|
|
|
}}</template>
|
|
|
|
</FormInput>
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
<FormSection>
|
|
|
|
<template #label>{{ i18n.ts.smtpConfig }}</template>
|
|
|
|
<FormSplit :min-width="280">
|
|
|
|
<FormInput
|
|
|
|
v-model="smtpHost"
|
|
|
|
class="_formBlock"
|
|
|
|
>
|
|
|
|
<template #label>{{
|
|
|
|
i18n.ts.smtpHost
|
|
|
|
}}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput
|
|
|
|
v-model="smtpPort"
|
|
|
|
type="number"
|
|
|
|
class="_formBlock"
|
|
|
|
>
|
|
|
|
<template #label>{{
|
|
|
|
i18n.ts.smtpPort
|
|
|
|
}}</template>
|
|
|
|
</FormInput>
|
|
|
|
</FormSplit>
|
|
|
|
<FormSplit :min-width="280">
|
|
|
|
<FormInput
|
|
|
|
v-model="smtpUser"
|
|
|
|
class="_formBlock"
|
|
|
|
>
|
|
|
|
<template #label>{{
|
|
|
|
i18n.ts.smtpUser
|
|
|
|
}}</template>
|
|
|
|
</FormInput>
|
|
|
|
<FormInput
|
|
|
|
v-model="smtpPass"
|
|
|
|
type="password"
|
|
|
|
class="_formBlock"
|
|
|
|
>
|
|
|
|
<template #label>{{
|
|
|
|
i18n.ts.smtpPass
|
|
|
|
}}</template>
|
|
|
|
</FormInput>
|
|
|
|
</FormSplit>
|
|
|
|
<FormInfo class="_formBlock">{{
|
|
|
|
i18n.ts.emptyToDisableSmtpAuth
|
|
|
|
}}</FormInfo>
|
|
|
|
<FormSwitch v-model="smtpSecure" class="_formBlock">
|
|
|
|
<template #label>{{
|
|
|
|
i18n.ts.smtpSecure
|
|
|
|
}}</template>
|
|
|
|
<template #caption>{{
|
|
|
|
i18n.ts.smtpSecureInfo
|
|
|
|
}}</template>
|
|
|
|
</FormSwitch>
|
|
|
|
</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>
|
2023-04-08 09:01:42 +09:00
|
|
|
import {} from "vue";
|
|
|
|
import FormSwitch from "@/components/form/switch.vue";
|
|
|
|
import FormInput from "@/components/form/input.vue";
|
|
|
|
import FormInfo from "@/components/MkInfo.vue";
|
|
|
|
import FormSuspense from "@/components/form/suspense.vue";
|
|
|
|
import FormSplit from "@/components/form/split.vue";
|
|
|
|
import FormSection from "@/components/form/section.vue";
|
|
|
|
import * as os from "@/os";
|
|
|
|
import { fetchInstance, instance } from "@/instance";
|
|
|
|
import { i18n } from "@/i18n";
|
|
|
|
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);
|
2023-04-08 09:01:42 +09:00
|
|
|
let smtpHost: string = $ref("");
|
2022-05-14 21:36:12 +09:00
|
|
|
let smtpPort: number = $ref(0);
|
2023-04-08 09:01:42 +09:00
|
|
|
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() {
|
2023-04-08 09:01:42 +09:00
|
|
|
const meta = await os.api("admin/meta");
|
2022-05-14 21:36:12 +09:00
|
|
|
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,
|
2023-04-08 09:01:42 +09:00
|
|
|
type: "email",
|
2022-06-20 17:38:49 +09:00
|
|
|
placeholder: instance.maintainerEmail,
|
2022-05-14 21:36:12 +09:00
|
|
|
});
|
|
|
|
if (canceled) return;
|
2023-04-08 09:01:42 +09:00
|
|
|
os.apiWithDialog("admin/send-email", {
|
2022-05-14 21:36:12 +09:00
|
|
|
to: destination,
|
2023-04-08 09:01:42 +09:00
|
|
|
subject: "Test email",
|
|
|
|
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() {
|
2023-04-08 09:01:42 +09:00
|
|
|
os.apiWithDialog("admin/update-meta", {
|
2022-05-14 21:36:12 +09:00
|
|
|
enableEmail,
|
|
|
|
email,
|
|
|
|
smtpSecure,
|
|
|
|
smtpHost,
|
|
|
|
smtpPort,
|
|
|
|
smtpUser,
|
|
|
|
smtpPass,
|
|
|
|
}).then(() => {
|
|
|
|
fetchInstance();
|
|
|
|
});
|
|
|
|
}
|
2021-04-22 22:29:33 +09:00
|
|
|
|
2023-04-08 09:01:42 +09:00
|
|
|
const headerActions = $computed(() => [
|
|
|
|
{
|
|
|
|
asFullButton: true,
|
|
|
|
icon: "ph-test-tube ph-bold ph-lg",
|
|
|
|
text: i18n.ts.testEmail,
|
|
|
|
handler: testEmail,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
asFullButton: true,
|
|
|
|
icon: "ph-check ph-bold ph-lg",
|
|
|
|
text: i18n.ts.save,
|
|
|
|
handler: save,
|
|
|
|
},
|
|
|
|
]);
|
2022-06-20 17:38:49 +09:00
|
|
|
|
|
|
|
const headerTabs = $computed(() => []);
|
|
|
|
|
|
|
|
definePageMetadata({
|
|
|
|
title: i18n.ts.emailServer,
|
2023-04-08 09:01:42 +09:00
|
|
|
icon: "ph-envelope-simple-open ph-bold ph-lg",
|
2021-04-22 22:29:33 +09:00
|
|
|
});
|
|
|
|
</script>
|