fix message switchs

This commit is contained in:
jxxghp
2023-07-14 07:24:33 +08:00
parent 0a7ce0fa95
commit a2b3ede80c
@@ -1,9 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
import api from "@/api"; import api from "@/api";
import { NotificationSwitch } from "@/api/types"; import { NotificationSwitch } from "@/api/types";
import { useToast } from "vue-toast-notification";
const messagemTypes = ref<NotificationSwitch[]>([]); const messagemTypes = ref<NotificationSwitch[]>([]);
// 提示框
const $toast = useToast();
// 调用API查询消息开关 // 调用API查询消息开关
const loadNotificationSwitchs = async () => { const loadNotificationSwitchs = async () => {
try { try {
@@ -14,6 +18,21 @@ const loadNotificationSwitchs = async () => {
} }
}; };
// 调用API保存消息开关
const saveNotificationSwitchs = async () => {
try {
const result: { [key: string]: any } = await api.post("message/switchs", messagemTypes.value);
if (result.success) {
$toast.success("保存通知消息设置成功");
} else {
$toast.error("保存通知消息设置失败!");
}
messagemTypes.value = messagemTypes.value;
} catch (error) {
console.log(error);
}
};
onMounted(() => { onMounted(() => {
loadNotificationSwitchs(); loadNotificationSwitchs();
}); });
@@ -57,7 +76,7 @@ onMounted(() => {
<VCardText> <VCardText>
<VForm @submit.prevent="() => { }"> <VForm @submit.prevent="() => { }">
<div class="d-flex flex-wrap gap-4 mt-4"> <div class="d-flex flex-wrap gap-4 mt-4">
<VBtn mtype="submit"> 保存 </VBtn> <VBtn mtype="submit" @click="saveNotificationSwitchs"> 保存 </VBtn>
</div> </div>
</VForm> </VForm>
</VCardText> </VCardText>