2020-10-17 20:12:00 +09:00
|
|
|
<template>
|
2021-11-19 19:36:12 +09:00
|
|
|
<component :is="popup.component"
|
|
|
|
v-for="popup in popups"
|
2020-10-17 20:12:00 +09:00
|
|
|
:key="popup.id"
|
|
|
|
v-bind="popup.props"
|
|
|
|
v-on="popup.events"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<XUpload v-if="uploads.length > 0"/>
|
|
|
|
|
2020-10-25 01:21:41 +09:00
|
|
|
<XStreamIndicator/>
|
|
|
|
|
2021-11-19 19:36:12 +09:00
|
|
|
<div v-if="pendingApiRequestsCount > 0" id="wait"></div>
|
2022-03-03 01:17:37 +09:00
|
|
|
|
|
|
|
<div v-if="dev" id="devTicker"><span>DEV BUILD</span></div>
|
2020-10-17 20:12:00 +09:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { defineAsyncComponent, defineComponent } from 'vue';
|
2022-04-28 11:14:03 +09:00
|
|
|
import { popup, popups, pendingApiRequestsCount } from '@/os';
|
|
|
|
import { uploads } from '@/scripts/upload';
|
2021-11-12 02:02:25 +09:00
|
|
|
import * as sound from '@/scripts/sound';
|
|
|
|
import { $i } from '@/account';
|
2022-04-30 21:52:07 +09:00
|
|
|
import { swInject } from './sw-inject';
|
2021-12-29 22:13:09 +09:00
|
|
|
import { stream } from '@/stream';
|
2020-10-17 20:12:00 +09:00
|
|
|
|
|
|
|
export default defineComponent({
|
|
|
|
components: {
|
2020-10-25 01:21:41 +09:00
|
|
|
XStreamIndicator: defineAsyncComponent(() => import('./stream-indicator.vue')),
|
|
|
|
XUpload: defineAsyncComponent(() => import('./upload.vue')),
|
2020-10-17 20:12:00 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
setup() {
|
2020-11-03 15:59:13 +09:00
|
|
|
const onNotification = notification => {
|
2020-12-19 10:55:52 +09:00
|
|
|
if ($i.mutingNotificationTypes.includes(notification.type)) return;
|
2020-11-03 15:59:13 +09:00
|
|
|
|
|
|
|
if (document.visibilityState === 'visible') {
|
|
|
|
stream.send('readNotification', {
|
|
|
|
id: notification.id
|
|
|
|
});
|
|
|
|
|
2022-05-01 22:51:07 +09:00
|
|
|
popup(defineAsyncComponent(() => import('@/components/notification-toast.vue')), {
|
2020-11-03 15:59:13 +09:00
|
|
|
notification
|
|
|
|
}, {}, 'closed');
|
|
|
|
}
|
|
|
|
|
2020-11-25 21:31:34 +09:00
|
|
|
sound.play('notification');
|
2020-11-03 15:59:13 +09:00
|
|
|
};
|
|
|
|
|
2020-12-19 10:55:52 +09:00
|
|
|
if ($i) {
|
2021-05-28 22:57:04 +09:00
|
|
|
const connection = stream.useChannel('main', null, 'UI');
|
2020-11-03 15:59:13 +09:00
|
|
|
connection.on('notification', onNotification);
|
2022-04-30 21:52:07 +09:00
|
|
|
|
|
|
|
//#region Listen message from SW
|
|
|
|
if ('serviceWorker' in navigator) {
|
|
|
|
swInject();
|
|
|
|
}
|
2020-11-03 15:59:13 +09:00
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
return {
|
|
|
|
uploads,
|
|
|
|
popups,
|
|
|
|
pendingApiRequestsCount,
|
2022-03-03 01:17:37 +09:00
|
|
|
dev: _DEV_,
|
2020-10-17 20:12:00 +09:00
|
|
|
};
|
|
|
|
},
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
2022-03-03 01:17:37 +09:00
|
|
|
@keyframes dev-ticker-blink {
|
|
|
|
0% { opacity: 1; }
|
|
|
|
50% { opacity: 0; }
|
|
|
|
100% { opacity: 1; }
|
|
|
|
}
|
|
|
|
|
|
|
|
@keyframes progress-spinner {
|
|
|
|
0% {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
transform: rotate(360deg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-17 20:12:00 +09:00
|
|
|
#wait {
|
|
|
|
display: block;
|
|
|
|
position: fixed;
|
2021-12-18 12:12:47 +09:00
|
|
|
z-index: 4000000;
|
2020-10-17 20:12:00 +09:00
|
|
|
top: 15px;
|
|
|
|
right: 15px;
|
|
|
|
|
|
|
|
&:before {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
width: 18px;
|
|
|
|
height: 18px;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border: solid 2px transparent;
|
|
|
|
border-top-color: var(--accent);
|
|
|
|
border-left-color: var(--accent);
|
|
|
|
border-radius: 50%;
|
|
|
|
animation: progress-spinner 400ms linear infinite;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-03 01:17:37 +09:00
|
|
|
#devTicker {
|
|
|
|
position: fixed;
|
|
|
|
top: 0;
|
|
|
|
left: 0;
|
|
|
|
z-index: 2147483647;
|
|
|
|
color: #ff0;
|
|
|
|
background: rgba(0, 0, 0, 0.5);
|
|
|
|
padding: 4px 5px;
|
|
|
|
font-size: 14px;
|
|
|
|
pointer-events: none;
|
2022-03-06 23:21:25 +09:00
|
|
|
user-select: none;
|
2022-03-03 01:17:37 +09:00
|
|
|
|
|
|
|
> span {
|
|
|
|
animation: dev-ticker-blink 2s infinite;
|
2020-10-17 20:12:00 +09:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|