|
|
@@ -0,0 +1,122 @@
|
|
|
+<template>
|
|
|
+ <div class="full-container-p24">
|
|
|
+ <el-form
|
|
|
+ :model="ruleForm"
|
|
|
+ :rules="rules"
|
|
|
+ ref="ruleFormRef"
|
|
|
+ label-width="100px"
|
|
|
+ >
|
|
|
+ <el-form-item label="邮箱名称" prop="username">
|
|
|
+ <el-input
|
|
|
+ class="w500"
|
|
|
+ v-model="ruleForm.username"
|
|
|
+ placeholder="请输入用户名"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="新密码" prop="newPassword">
|
|
|
+ <el-input
|
|
|
+ class="w500"
|
|
|
+ v-model="ruleForm.newPassword"
|
|
|
+ placeholder="请输入新密码"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="发件人名称" prop="from">
|
|
|
+ <el-input
|
|
|
+ class="w500"
|
|
|
+ v-model="ruleForm.from"
|
|
|
+ placeholder="请输入邮箱地址"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="SMTP服务器" prop="smtpHost">
|
|
|
+ <el-input
|
|
|
+ class="w500"
|
|
|
+ v-model="ruleForm.smtpHost"
|
|
|
+ placeholder="请输入SMTP服务器"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="SMTP端口" prop="smtpPort">
|
|
|
+ <el-input
|
|
|
+ class="w500"
|
|
|
+ v-model="ruleForm.smtpPort"
|
|
|
+ placeholder="请输入SMTP端口"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="开启SSL加密" prop="enableSsl">
|
|
|
+ <el-switch
|
|
|
+ v-model="ruleForm.enableSsl"
|
|
|
+ active-text="开启"
|
|
|
+ :active-value="1"
|
|
|
+ inactive-text="关闭"
|
|
|
+ :inactive-value="0"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-button
|
|
|
+ style="margin-left: 480px"
|
|
|
+ type="primary"
|
|
|
+ @click="updateEmailConfig()"
|
|
|
+ >
|
|
|
+ 更新邮箱配置
|
|
|
+ </el-button>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script setup>
|
|
|
+import { ref, h, reactive, toRefs, onMounted } from "vue";
|
|
|
+import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
|
|
|
+import store from "../../store";
|
|
|
+import router from "../../router";
|
|
|
+import md5 from "md5";
|
|
|
+import api from "../../apis/fetch";
|
|
|
+
|
|
|
+const ruleFormRef = ref(null);
|
|
|
+const ruleForm = ref({
|
|
|
+ username: "",
|
|
|
+ from: "",
|
|
|
+ newPassword: "",
|
|
|
+ password: "",
|
|
|
+ smtpHost: "",
|
|
|
+ smtpPort: 0,
|
|
|
+ enableSsl: 0,
|
|
|
+});
|
|
|
+const rules = ref({});
|
|
|
+async function getEmailConfig() {
|
|
|
+ let { data } = await api.getEmailConfig();
|
|
|
+ ruleForm.value = data.result;
|
|
|
+ console.log(data);
|
|
|
+}
|
|
|
+async function updateEmailConfig() {
|
|
|
+ ElMessageBox.confirm("确认更新邮箱配置", "提示", {
|
|
|
+ confirmButtonText: "确认",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ }).then(async () => {
|
|
|
+ if (
|
|
|
+ md5(md5(ruleForm.value.newPassword)) === ruleForm.value.password ||
|
|
|
+ ruleForm.value.newPassword === ""
|
|
|
+ ) {
|
|
|
+ delete ruleForm.value.password;
|
|
|
+ delete ruleForm.value.newPassword;
|
|
|
+ } else {
|
|
|
+ ruleForm.value.password = md5(md5(ruleForm.value.newPassword));
|
|
|
+ delete ruleForm.value.newPassword;
|
|
|
+ }
|
|
|
+ let { data } = await api.updateEmailConfig({
|
|
|
+ ...ruleForm.value,
|
|
|
+ });
|
|
|
+ console.log(data);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ getEmailConfig();
|
|
|
+});
|
|
|
+</script>
|
|
|
+<style scoped>
|
|
|
+.title {
|
|
|
+ width: 140px;
|
|
|
+}
|
|
|
+
|
|
|
+.w500 {
|
|
|
+ width: 500px;
|
|
|
+}
|
|
|
+</style>
|