🎨新增用户头像更换、客户端邮件通知

This commit is contained in:
coward 2024-06-13 11:28:34 +08:00
parent 9d67b38796
commit 0ef9dfab57
4 changed files with 52 additions and 3 deletions

View File

@ -47,3 +47,8 @@ export const getClientConnects = () => {
export const offlineClient = (id: string) => {
return http.request<any>("post", baseUri("/client/offline/" + id));
};
// 发送邮件
export const sendMail = (id: string) => {
return http.request<any>("post", baseUri("/client/to-email/" + id));
};

View File

@ -1,5 +1,6 @@
import { http } from "@/utils/http";
import { baseUri } from "@/api/utils";
import { data } from "autoprefixer";
// 获取当前登陆用户信息
export const getUser = () => {
@ -30,3 +31,8 @@ export const deleteUser = (userId: string) => {
export const changePassword = (data?: object) => {
return http.request("post", baseUri("/user/change-password"), { data });
};
// 生成头像
export const generateAvatar = () => {
return http.request<any>("post", baseUri("/user/change-avatar"));
};

View File

@ -1,6 +1,7 @@
<script setup lang="ts">
import { ref } from "vue";
import { FormInstance } from "element-plus";
import { generateAvatar } from "@/api/user";
// props
export interface FormProps {
@ -41,11 +42,29 @@ function getUserEditFormRef() {
return userEditFormRef.value;
}
//
const changeAvatar = () => {
generateAvatar().then(res => {
if (res.code === 200) {
userEditForm.value.avatar = res.data;
}
});
};
defineExpose({ getUserEditFormRef });
</script>
<template>
<el-form ref="userEditFormRef" :model="userEditForm" label-width="20%">
<el-form-item prop="avatar">
<el-avatar
style="cursor: pointer; margin-left: 25%"
size="large"
fit="cover"
:src="userEditForm.avatar"
@click="changeAvatar()"
/>
</el-form-item>
<el-form-item
prop="name"
label="名称"

View File

@ -4,7 +4,8 @@ import {
downloadClient,
generateClientIP,
getClients,
saveClient
saveClient,
sendMail
} from "@/api/clients";
import { h, reactive, ref } from "vue";
import { addDialog } from "@/components/ReDialog/index";
@ -15,6 +16,7 @@ import "plus-pro-components/es/components/search/style/css";
import { storageLocal } from "@pureadmin/utils";
import { ArrowDown } from "@element-plus/icons-vue";
import { ElMessageBox } from "element-plus";
import { message } from "@/utils/message";
defineOptions({
// name name
@ -152,7 +154,7 @@ const openAddClientDialog = () => {
}
});
const serverInfo = storageLocal().getItem("server-info");
const restartRule = storageLocal().getItem("restart-rule") ? 1 : 0;
const restartRule = !storageLocal().getItem("restart-rule") ? 1 : 0;
addDialog({
width: "40%",
title: "新增",
@ -280,6 +282,15 @@ const ellipsis = (str: string) => {
return str;
};
//
const sendToEmail = (clientID: string) => {
sendMail(clientID).then(res => {
if (res.code === 200) {
message("发送邮件成功", { type: "success" });
}
});
};
getClientsApi(clientSearchForm.value);
</script>
@ -310,7 +321,10 @@ getClientsApi(clientSearchForm.value);
</div>
<div class="content">
<el-card body-style="padding: inherit" shadow="hover">
<div class="flex flex-wrap gap-4" style="display: flex;justify-content: center;">
<div
class="flex flex-wrap gap-4"
style="display: flex; justify-content: center"
>
<el-card
v-for="val in clientsList.data"
style="float: left; width: 500px"
@ -339,6 +353,11 @@ getClientsApi(clientSearchForm.value);
>下载</el-button
>
</el-dropdown-item>
<el-dropdown-item>
<el-button type="success" @click="sendToEmail(val.id)"
>邮件</el-button
>
</el-dropdown-item>
<el-dropdown-item>
<el-button
type="danger"