2022-07-03 14:40:02 +09:00
|
|
|
<template>
|
|
|
|
<span v-if="!fetching" class="nmidsaqw">
|
|
|
|
<template v-if="display === 'marquee'">
|
2022-12-30 13:37:14 +09:00
|
|
|
<Transition name="change" mode="default">
|
2022-07-03 14:40:02 +09:00
|
|
|
<MarqueeText :key="key" :duration="marqueeDuration" :reverse="marqueeReverse">
|
|
|
|
<span v-for="instance in instances" :key="instance.id" class="item" :class="{ colored }" :style="{ background: colored ? instance.themeColor : null }">
|
2022-12-08 17:33:04 +09:00
|
|
|
<img class="icon" :src="getInstanceIcon(instance)" alt=""/>
|
2022-07-03 14:40:02 +09:00
|
|
|
<MkA :to="`/instance-info/${instance.host}`" class="host _monospace">
|
|
|
|
{{ instance.host }}
|
|
|
|
</MkA>
|
|
|
|
<span class="divider"></span>
|
|
|
|
</span>
|
|
|
|
</MarqueeText>
|
2022-12-30 13:37:14 +09:00
|
|
|
</Transition>
|
2022-07-03 14:40:02 +09:00
|
|
|
</template>
|
|
|
|
<template v-else-if="display === 'oneByOne'">
|
|
|
|
<!-- TODO -->
|
|
|
|
</template>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import { computed, defineAsyncComponent, ref, toRef, watch } from 'vue';
|
|
|
|
import * as misskey from 'misskey-js';
|
2022-08-31 00:24:33 +09:00
|
|
|
import MarqueeText from '@/components/MkMarquee.vue';
|
2022-07-03 14:40:02 +09:00
|
|
|
import * as os from '@/os';
|
|
|
|
import { useInterval } from '@/scripts/use-interval';
|
|
|
|
import { getNoteSummary } from '@/scripts/get-note-summary';
|
|
|
|
import { notePage } from '@/filters/note';
|
2022-12-08 17:33:04 +09:00
|
|
|
import { getProxiedImageUrlNullable } from '@/scripts/media-proxy';
|
2022-07-03 14:40:02 +09:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
display?: 'marquee' | 'oneByOne';
|
|
|
|
colored?: boolean;
|
|
|
|
marqueeDuration?: number;
|
|
|
|
marqueeReverse?: boolean;
|
|
|
|
oneByOneInterval?: number;
|
|
|
|
refreshIntervalSec?: number;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const instances = ref<misskey.entities.Instance[]>([]);
|
|
|
|
const fetching = ref(true);
|
|
|
|
let key = $ref(0);
|
|
|
|
|
|
|
|
const tick = () => {
|
|
|
|
os.api('federation/instances', {
|
|
|
|
sort: '+lastCommunicatedAt',
|
|
|
|
limit: 30,
|
|
|
|
}).then(res => {
|
|
|
|
instances.value = res;
|
|
|
|
fetching.value = false;
|
|
|
|
key++;
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
useInterval(tick, Math.max(5000, props.refreshIntervalSec * 1000), {
|
|
|
|
immediate: true,
|
|
|
|
afterMounted: true,
|
|
|
|
});
|
2022-12-08 17:33:04 +09:00
|
|
|
|
|
|
|
function getInstanceIcon(instance): string {
|
|
|
|
return getProxiedImageUrlNullable(instance.iconUrl, 'preview') ?? getProxiedImageUrlNullable(instance.faviconUrl, 'preview') ?? '/client-assets/dummy.png';
|
|
|
|
}
|
2022-07-03 14:40:02 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.change-enter-active, .change-leave-active {
|
|
|
|
position: absolute;
|
|
|
|
top: 0;
|
|
|
|
transition: all 1s ease;
|
|
|
|
}
|
|
|
|
.change-enter-from {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(-100%);
|
|
|
|
}
|
|
|
|
.change-leave-to {
|
|
|
|
opacity: 0;
|
|
|
|
transform: translateY(100%);
|
|
|
|
}
|
|
|
|
|
|
|
|
.nmidsaqw {
|
|
|
|
display: inline-block;
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
::v-deep(.item) {
|
|
|
|
display: inline-block;
|
|
|
|
vertical-align: bottom;
|
2022-07-07 17:28:21 +09:00
|
|
|
margin-right: 5em;
|
2022-07-03 14:40:02 +09:00
|
|
|
|
|
|
|
> .icon {
|
|
|
|
display: inline-block;
|
|
|
|
height: var(--height);
|
|
|
|
aspect-ratio: 1;
|
|
|
|
vertical-align: bottom;
|
|
|
|
margin-right: 1em;
|
|
|
|
}
|
|
|
|
|
|
|
|
> .host {
|
|
|
|
vertical-align: bottom;
|
|
|
|
}
|
|
|
|
|
|
|
|
&.colored {
|
|
|
|
padding-right: 1em;
|
|
|
|
color: #fff;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|