mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-07-12 16:01:35 +08:00
message sse
This commit is contained in:
22
src/App.vue
22
src/App.vue
@@ -1,5 +1,27 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { useToast } from "vue-toast-notification";
|
||||||
|
import store from "./store";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
const $toast = useToast();
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
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;
|
||||||
|
$toast.info(message);
|
||||||
|
});
|
||||||
|
|
||||||
|
onBeforeUnmount(() => {
|
||||||
|
eventSource.close();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -26,7 +26,12 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VCard :height="props.height" :width="props.width" :flat="!props.site?.is_active" class="overflow-hidden">
|
<VCard
|
||||||
|
:height="props.height"
|
||||||
|
:width="props.width"
|
||||||
|
:flat="!props.site?.is_active"
|
||||||
|
class="overflow-hidden"
|
||||||
|
>
|
||||||
<template #image>
|
<template #image>
|
||||||
<VAvatar class="absolute right-2 bottom-2" variant="flat" rounded="0">
|
<VAvatar class="absolute right-2 bottom-2" variant="flat" rounded="0">
|
||||||
<VImg :src="siteIcon" />
|
<VImg :src="siteIcon" />
|
||||||
@@ -79,6 +84,7 @@ onMounted(() => {
|
|||||||
<VCardActions>
|
<VCardActions>
|
||||||
<VBtn>更新</VBtn>
|
<VBtn>更新</VBtn>
|
||||||
<VBtn>编辑</VBtn>
|
<VBtn>编辑</VBtn>
|
||||||
|
<VBtn>测试</VBtn>
|
||||||
</VCardActions>
|
</VCardActions>
|
||||||
</VCard>
|
</VCard>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user