es lint fix

This commit is contained in:
thofx
2023-07-22 16:09:07 +08:00
parent 48749b29fe
commit 018778488a
80 changed files with 3994 additions and 2981 deletions
+38 -36
View File
@@ -1,67 +1,69 @@
<script lang="ts" setup>
import avatar1 from "@images/avatars/avatar-1.png";
import { useToast } from "vue-toast-notification";
import api from "./api";
import { User } from "./api/types";
import store from "./store";
import { useToast } from 'vue-toast-notification'
import api from './api'
import type { User } from './api/types'
import store from './store'
import avatar1 from '@images/avatars/avatar-1.png'
// 路由
const route = useRoute();
const route = useRoute()
// 提示框
const $toast = useToast();
const $toast = useToast()
// SSE持续接收消息
const startSSEMessager = () => {
const token = store.state.auth.token;
function startSSEMessager() {
const token = store.state.auth.token
if (token) {
const eventSource = new EventSource(
`${import.meta.env.VITE_API_BASE_URL}system/message?token=${token}`
);
eventSource.addEventListener("message", (event) => {
const message = event.data;
if (message) {
$toast.info(message);
}
});
`${import.meta.env.VITE_API_BASE_URL}system/message?token=${token}`,
)
eventSource.addEventListener('message', (event) => {
const message = event.data
if (message)
$toast.info(message)
})
onBeforeUnmount(() => {
eventSource.close();
});
eventSource.close()
})
}
};
}
// 当前用户信息
const accountInfo = ref<User>({
id: 0,
name: "",
password: "",
email: "",
name: '',
password: '',
email: '',
is_active: false,
is_superuser: false,
avatar: avatar1,
});
})
// 调用API,加载当前用户数据
const loadAccountInfo = async () => {
async function loadAccountInfo() {
try {
const user: User = await api.get(`user/current`);
accountInfo.value = user;
if (!accountInfo.value.avatar) accountInfo.value.avatar = avatar1;
} catch (error) {
console.log(error);
const user: User = await api.get('user/current')
accountInfo.value = user
if (!accountInfo.value.avatar)
accountInfo.value.avatar = avatar1
}
};
catch (error) {
console.log(error)
}
}
// 页面加载时,加载当前用户数据
onMounted(() => {
loadAccountInfo();
startSSEMessager();
});
loadAccountInfo()
startSSEMessager()
})
// 提供给所有元素复用
provide("accountInfo", accountInfo);
provide('accountInfo', accountInfo)
</script>
<template>