mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-30 20:23:46 +02:00
replace ElNotification
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { ElNotification } from 'element-plus';
|
||||
import { defineStore } from 'pinia';
|
||||
import { toast } from 'vue-sonner';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { formatDateFilter, openExternalLink } from '../shared/utils';
|
||||
@@ -26,6 +26,14 @@ export const useVrcStatusStore = defineStore('VrcStatus', () => {
|
||||
return lastStatus.value;
|
||||
});
|
||||
|
||||
function dismissAlert() {
|
||||
if (!alertRef.value) {
|
||||
return;
|
||||
}
|
||||
toast.dismiss(alertRef.value);
|
||||
alertRef.value = null;
|
||||
}
|
||||
|
||||
function updateAlert() {
|
||||
if (lastStatusText.value === statusText.value) {
|
||||
return;
|
||||
@@ -34,32 +42,28 @@ export const useVrcStatusStore = defineStore('VrcStatus', () => {
|
||||
|
||||
if (!statusText.value) {
|
||||
if (alertRef.value) {
|
||||
alertRef.value.close();
|
||||
alertRef.value = ElNotification({
|
||||
title: t('status.title'),
|
||||
message: `${formatDateFilter(lastStatusTime.value, 'short')}: All Systems Operational`,
|
||||
type: 'success',
|
||||
duration: 5000,
|
||||
showClose: true,
|
||||
dismissAlert();
|
||||
alertRef.value = toast.success(t('status.title'), {
|
||||
description: `${formatDateFilter(lastStatusTime.value, 'short')}: All Systems Operational`,
|
||||
position: 'bottom-right',
|
||||
onClick: () => {
|
||||
openStatusPage();
|
||||
action: {
|
||||
label: 'Open',
|
||||
onClick: () => openStatusPage()
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
alertRef.value?.close();
|
||||
alertRef.value = ElNotification({
|
||||
title: t('status.title'),
|
||||
message: `${formatDateFilter(lastStatusTime.value, 'short')}: ${statusText.value}`,
|
||||
type: 'warning',
|
||||
duration: 0,
|
||||
showClose: true,
|
||||
dismissAlert();
|
||||
alertRef.value = toast.warning(t('status.title'), {
|
||||
description: `${formatDateFilter(lastStatusTime.value, 'short')}: ${statusText.value}`,
|
||||
duration: Infinity,
|
||||
closeButton: true,
|
||||
position: 'bottom-right',
|
||||
onClick: () => {
|
||||
openStatusPage();
|
||||
action: {
|
||||
label: 'Open',
|
||||
onClick: () => openStatusPage()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user