monkeeShark/packages/frontend/src/ui/_common_/stream-indicator.vue

60 lines
1.3 KiB
Vue
Raw Normal View History

<template>
2023-01-15 04:46:09 +00:00
<div v-if="hasDisconnected && $store.state.serverDisconnectedBehavior === 'quiet'" :class="$style.root" class="_panel _shadow" @click="resetDisconnected">
2023-01-15 02:30:40 +00:00
<div><i class="ti ti-alert-triangle"></i> {{ i18n.ts.disconnectedFromServer }}</div>
<div :class="$style.command" class="_buttons">
<MkButton :class="$style.commandButton" small primary @click="reload">{{ i18n.ts.reload }}</MkButton>
<MkButton :class="$style.commandButton" small>{{ i18n.ts.doNothing }}</MkButton>
</div>
</div>
</template>
<script lang="ts" setup>
import { onUnmounted } from 'vue';
import { stream } from '@/stream';
2022-07-20 13:24:26 +00:00
import { i18n } from '@/i18n';
2023-01-15 02:30:40 +00:00
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os';
const zIndex = os.claimZIndex('high');
let hasDisconnected = $ref(false);
function onDisconnected() {
hasDisconnected = true;
}
function resetDisconnected() {
hasDisconnected = false;
}
function reload() {
location.reload();
}
stream.on('_disconnected_', onDisconnected);
onUnmounted(() => {
stream.off('_disconnected_', onDisconnected);
});
</script>
2023-01-15 02:30:40 +00:00
<style lang="scss" module>
.root {
position: fixed;
2023-01-15 02:30:40 +00:00
z-index: v-bind(zIndex);
bottom: calc(var(--minBottomSpacing) + var(--margin));
right: var(--margin);
margin: 0;
2023-01-15 02:30:40 +00:00
padding: 12px;
font-size: 0.9em;
max-width: 320px;
2023-01-15 02:30:40 +00:00
}
2023-01-15 02:30:40 +00:00
.command {
margin-top: 8px;
}
2023-01-15 02:30:40 +00:00
.commandButton {
}
</style>