2020-02-19 18:42:36 +00:00
|
|
|
<template>
|
2023-04-01 04:42:40 +00:00
|
|
|
<div v-if="hasDisconnected && defaultStore.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>
|
2020-02-19 18:42:36 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
2022-01-15 23:38:55 +00:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onUnmounted } from 'vue';
|
2021-12-29 13:13:09 +00:00
|
|
|
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';
|
2023-04-01 04:42:40 +00:00
|
|
|
import { defaultStore } from '@/store';
|
2023-01-15 02:30:40 +00:00
|
|
|
|
|
|
|
const zIndex = os.claimZIndex('high');
|
2020-02-19 18:42:36 +00:00
|
|
|
|
2022-01-15 23:38:55 +00:00
|
|
|
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);
|
2020-02-19 18:42:36 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2023-01-15 02:30:40 +00:00
|
|
|
<style lang="scss" module>
|
|
|
|
.root {
|
2020-02-19 18:42:36 +00:00
|
|
|
position: fixed;
|
2023-01-15 02:30:40 +00:00
|
|
|
z-index: v-bind(zIndex);
|
2023-01-10 04:50:34 +00:00
|
|
|
bottom: calc(var(--minBottomSpacing) + var(--margin));
|
|
|
|
right: var(--margin);
|
2020-02-19 18:42:36 +00:00
|
|
|
margin: 0;
|
2023-01-15 02:30:40 +00:00
|
|
|
padding: 12px;
|
2020-02-19 18:42:36 +00:00
|
|
|
font-size: 0.9em;
|
|
|
|
max-width: 320px;
|
2023-01-15 02:30:40 +00:00
|
|
|
}
|
2020-02-19 18:42:36 +00:00
|
|
|
|
2023-01-15 02:30:40 +00:00
|
|
|
.command {
|
|
|
|
margin-top: 8px;
|
|
|
|
}
|
2020-02-19 18:42:36 +00:00
|
|
|
|
2023-01-15 02:30:40 +00:00
|
|
|
.commandButton {
|
2020-02-19 18:42:36 +00:00
|
|
|
}
|
|
|
|
</style>
|