forked from FoundKeyGang/FoundKey
client: use cached instance information
This commit is contained in:
parent
4f9504d135
commit
2c411d59f4
5 changed files with 12 additions and 39 deletions
|
@ -1,17 +1,9 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="meta" class="xfbouadm" :style="{ backgroundImage: `url(${ meta.backgroundImageUrl })` }"></div>
|
<div class="xfbouadm" :style="{ backgroundImage: `url(${ instance.backgroundImageUrl })` }"></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref } from 'vue';
|
import { instance } from '@/instance';
|
||||||
import * as foundkey from 'foundkey-js';
|
|
||||||
import * as os from '@/os';
|
|
||||||
|
|
||||||
const meta = ref<foundkey.entities.DetailedInstanceMetadata>();
|
|
||||||
|
|
||||||
os.api('meta', { detail: true }).then(gotMeta => {
|
|
||||||
meta.value = gotMeta;
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<div v-show="loaded" class="mjndxjch">
|
<div v-show="loaded" class="mjndxjch">
|
||||||
<img src="https://xn--931a.moe/assets/error.jpg" class="_ghost"/>
|
<img src="https://xn--931a.moe/assets/error.jpg" class="_ghost"/>
|
||||||
<p><b><i class="fas fa-exclamation-triangle"></i> {{ i18n.ts.pageLoadError }}</b></p>
|
<p><b><i class="fas fa-exclamation-triangle"></i> {{ i18n.ts.pageLoadError }}</b></p>
|
||||||
<p v-if="meta && (version === meta.version)">{{ i18n.ts.pageLoadErrorDescription }}</p>
|
<p v-if="version === instance.version">{{ i18n.ts.pageLoadErrorDescription }}</p>
|
||||||
<p v-else-if="serverIsDead">{{ i18n.ts.serverIsDead }}</p>
|
<p v-else-if="serverIsDead">{{ i18n.ts.serverIsDead }}</p>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<p>{{ i18n.ts.newVersionOfClientAvailable }}</p>
|
<p>{{ i18n.ts.newVersionOfClientAvailable }}</p>
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
import * as foundkey from 'foundkey-js';
|
import * as foundkey from 'foundkey-js';
|
||||||
import MkButton from '@/components/ui/button.vue';
|
import MkButton from '@/components/ui/button.vue';
|
||||||
import { version } from '@/config';
|
import { version } from '@/config';
|
||||||
|
import { instance } from '@/instance';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { unisonReload } from '@/scripts/unison-reload';
|
import { unisonReload } from '@/scripts/unison-reload';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
|
@ -34,15 +35,11 @@ withDefaults(defineProps<{
|
||||||
|
|
||||||
let loaded = $ref(false);
|
let loaded = $ref(false);
|
||||||
let serverIsDead = $ref(false);
|
let serverIsDead = $ref(false);
|
||||||
let meta = $ref<foundkey.entities.LiteInstanceMetadata | null>(null);
|
|
||||||
|
|
||||||
os.api('meta', {
|
// just checking whether the server is alive or dead
|
||||||
detail: false,
|
os.api('ping').then(() => {
|
||||||
}).then(res => {
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
serverIsDead = false;
|
serverIsDead = false;
|
||||||
meta = res;
|
|
||||||
localStorage.setItem('v', res.version);
|
|
||||||
}, () => {
|
}, () => {
|
||||||
loaded = true;
|
loaded = true;
|
||||||
serverIsDead = true;
|
serverIsDead = true;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="meta" class="rsqzvsbo">
|
<div class="rsqzvsbo">
|
||||||
<div class="top">
|
<div class="top">
|
||||||
<MkFeaturedPhotos class="bg"/>
|
<MkFeaturedPhotos class="bg"/>
|
||||||
<XTimeline class="tl"/>
|
<XTimeline class="tl"/>
|
||||||
|
@ -19,12 +19,12 @@
|
||||||
<div class="fg">
|
<div class="fg">
|
||||||
<h1>
|
<h1>
|
||||||
<!-- 背景色によってはロゴが見えなくなるのでとりあえず無効に -->
|
<!-- 背景色によってはロゴが見えなくなるのでとりあえず無効に -->
|
||||||
<!-- <img class="logo" v-if="meta.logoImageUrl" :src="meta.logoImageUrl"><span v-else class="text">{{ instanceName }}</span> -->
|
<!-- <img class="logo" v-if="instance.logoImageUrl" :src="instance.logoImageUrl"><span v-else class="text">{{ instanceName }}</span> -->
|
||||||
<span class="text">{{ instanceName }}</span>
|
<span class="text">{{ instanceName }}</span>
|
||||||
</h1>
|
</h1>
|
||||||
<div class="about">
|
<div class="about">
|
||||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||||
<div class="desc" v-html="meta.description || i18n.ts.headlineMisskey"></div>
|
<div class="desc" v-html="instance.description || i18n.ts.headlineMisskey"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="action">
|
<div class="action">
|
||||||
<MkButton inline rounded gradate data-cy-signup style="margin-right: 12px;" @click="signup()">{{ i18n.ts.signup }}</MkButton>
|
<MkButton inline rounded gradate data-cy-signup style="margin-right: 12px;" @click="signup()">{{ i18n.ts.signup }}</MkButton>
|
||||||
|
@ -58,17 +58,13 @@ import { host, instanceName } from '@/config';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import number from '@/filters/number';
|
import number from '@/filters/number';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
|
import { instance } from '@/instance';
|
||||||
|
|
||||||
let meta = $ref();
|
|
||||||
let stats = $ref();
|
let stats = $ref();
|
||||||
let tags = $ref();
|
let tags = $ref();
|
||||||
let onlineUsersCount = $ref();
|
let onlineUsersCount = $ref();
|
||||||
let instances = $ref();
|
let instances = $ref();
|
||||||
|
|
||||||
os.api('meta', { detail: true }).then(_meta => {
|
|
||||||
meta = _meta;
|
|
||||||
});
|
|
||||||
|
|
||||||
os.api('stats').then(_stats => {
|
os.api('stats').then(_stats => {
|
||||||
stats = _stats;
|
stats = _stats;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div v-if="meta">
|
<XSetup v-if="instance.requireSetup"/>
|
||||||
<XSetup v-if="meta.requireSetup"/>
|
|
||||||
<XEntrance v-else/>
|
<XEntrance v-else/>
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
@ -10,15 +8,10 @@ import { computed } from 'vue';
|
||||||
import XSetup from './welcome.setup.vue';
|
import XSetup from './welcome.setup.vue';
|
||||||
import XEntrance from './welcome.entrance.a.vue';
|
import XEntrance from './welcome.entrance.a.vue';
|
||||||
import { instanceName } from '@/config';
|
import { instanceName } from '@/config';
|
||||||
|
import { instance } from '@/instance';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
|
|
||||||
let meta = $ref(null);
|
|
||||||
|
|
||||||
os.api('meta', { detail: true }).then(res => {
|
|
||||||
meta = res;
|
|
||||||
});
|
|
||||||
|
|
||||||
definePageMetadata(computed(() => ({
|
definePageMetadata(computed(() => ({
|
||||||
title: instanceName,
|
title: instanceName,
|
||||||
icon: null,
|
icon: null,
|
||||||
|
|
|
@ -80,7 +80,6 @@ const announcements = {
|
||||||
let showMenu = $ref(false);
|
let showMenu = $ref(false);
|
||||||
let isDesktop = $ref(window.innerWidth >= DESKTOP_THRESHOLD);
|
let isDesktop = $ref(window.innerWidth >= DESKTOP_THRESHOLD);
|
||||||
let narrow = $ref(window.innerWidth < 1280);
|
let narrow = $ref(window.innerWidth < 1280);
|
||||||
let meta = $ref();
|
|
||||||
|
|
||||||
const keymap = $computed(() => {
|
const keymap = $computed(() => {
|
||||||
return {
|
return {
|
||||||
|
@ -94,10 +93,6 @@ const keymap = $computed(() => {
|
||||||
|
|
||||||
const root = $computed(() => mainRouter.currentRoute.value.name === 'index');
|
const root = $computed(() => mainRouter.currentRoute.value.name === 'index');
|
||||||
|
|
||||||
os.api('meta', { detail: true }).then(res => {
|
|
||||||
meta = res;
|
|
||||||
});
|
|
||||||
|
|
||||||
function signin() {
|
function signin() {
|
||||||
os.popup(XSigninDialog, {
|
os.popup(XSigninDialog, {
|
||||||
autoSet: true,
|
autoSet: true,
|
||||||
|
|
Loading…
Reference in a new issue