refactor(frontend): remove $instance

This commit is contained in:
syuilo 2023-04-01 13:46:04 +09:00
parent c823cbe63b
commit 7a8a756789
13 changed files with 38 additions and 28 deletions

View File

@ -1,14 +1,12 @@
/// <reference types="vue/macros-global" /> /// <reference types="vue/macros-global" />
import type { $i } from '@/account'; import type { $i } from '@/account';
import type { defaultStore } from '@/store';
import type { instance } from '@/instance'; import type { instance } from '@/instance';
import type { i18n } from '@/i18n'; import type { i18n } from '@/i18n';
declare module 'vue' { declare module 'vue' {
interface ComponentCustomProperties { interface ComponentCustomProperties {
$i: typeof $i; $i: typeof $i;
$instance: typeof instance;
$t: typeof i18n['t']; $t: typeof i18n['t'];
$ts: typeof i18n['ts']; $ts: typeof i18n['ts'];
} }

View File

@ -14,7 +14,7 @@
<div :class="$style.text"> <div :class="$style.text">
<I18n :src="i18n.ts.pleaseDonate" tag="span"> <I18n :src="i18n.ts.pleaseDonate" tag="span">
<template #host> <template #host>
{{ $instance.name ?? host }} {{ instance.name ?? host }}
</template> </template>
</I18n> </I18n>
<div style="margin-top: 0.2em;"> <div style="margin-top: 0.2em;">
@ -37,6 +37,7 @@ import { host } from '@/config';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import * as os from '@/os'; import * as os from '@/os';
import { miLocalStorage } from '@/local-storage'; import { miLocalStorage } from '@/local-storage';
import { instance } from '@/instance';
const emit = defineEmits<{ const emit = defineEmits<{
(ev: 'closed'): void; (ev: 'closed'): void;

View File

@ -201,7 +201,6 @@ if (_DEV_) {
// TODO: 廃止 // TODO: 廃止
app.config.globalProperties = { app.config.globalProperties = {
$i, $i,
$instance: instance,
$t: i18n.t, $t: i18n.t,
$ts: i18n.ts, $ts: i18n.ts,
}; };

View File

@ -3,18 +3,18 @@
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template> <template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
<MkSpacer v-if="tab === 'overview'" :content-max="600" :margin-min="20"> <MkSpacer v-if="tab === 'overview'" :content-max="600" :margin-min="20">
<div class="_gaps_m"> <div class="_gaps_m">
<div class="fwhjspax" :style="{ backgroundImage: `url(${ $instance.bannerUrl })` }"> <div class="fwhjspax" :style="{ backgroundImage: `url(${ instance.bannerUrl })` }">
<div class="content"> <div class="content">
<img :src="$instance.iconUrl ?? $instance.faviconUrl ?? '/favicon.ico'" alt="" class="icon"/> <img :src="instance.iconUrl ?? instance.faviconUrl ?? '/favicon.ico'" alt="" class="icon"/>
<div class="name"> <div class="name">
<b>{{ $instance.name ?? host }}</b> <b>{{ instance.name ?? host }}</b>
</div> </div>
</div> </div>
</div> </div>
<MkKeyValue> <MkKeyValue>
<template #key>{{ i18n.ts.description }}</template> <template #key>{{ i18n.ts.description }}</template>
<template #value><div v-html="$instance.description"></div></template> <template #value><div v-html="instance.description"></div></template>
</MkKeyValue> </MkKeyValue>
<FormSection> <FormSection>
@ -23,7 +23,7 @@
<template #key>Misskey</template> <template #key>Misskey</template>
<template #value>{{ version }}</template> <template #value>{{ version }}</template>
</MkKeyValue> </MkKeyValue>
<div v-html="i18n.t('poweredByMisskeyDescription', { name: $instance.name ?? host })"> <div v-html="i18n.t('poweredByMisskeyDescription', { name: instance.name ?? host })">
</div> </div>
<FormLink to="/about-misskey">{{ i18n.ts.aboutMisskey }}</FormLink> <FormLink to="/about-misskey">{{ i18n.ts.aboutMisskey }}</FormLink>
</div> </div>
@ -34,14 +34,14 @@
<FormSplit> <FormSplit>
<MkKeyValue> <MkKeyValue>
<template #key>{{ i18n.ts.administrator }}</template> <template #key>{{ i18n.ts.administrator }}</template>
<template #value>{{ $instance.maintainerName }}</template> <template #value>{{ instance.maintainerName }}</template>
</MkKeyValue> </MkKeyValue>
<MkKeyValue> <MkKeyValue>
<template #key>{{ i18n.ts.contact }}</template> <template #key>{{ i18n.ts.contact }}</template>
<template #value>{{ $instance.maintainerEmail }}</template> <template #value>{{ instance.maintainerEmail }}</template>
</MkKeyValue> </MkKeyValue>
</FormSplit> </FormSplit>
<FormLink v-if="$instance.tosUrl" :to="$instance.tosUrl" external>{{ i18n.ts.tos }}</FormLink> <FormLink v-if="instance.tosUrl" :to="instance.tosUrl" external>{{ i18n.ts.tos }}</FormLink>
</div> </div>
</FormSection> </FormSection>
@ -101,6 +101,7 @@ import number from '@/filters/number';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';
import { claimAchievement } from '@/scripts/achievements'; import { claimAchievement } from '@/scripts/achievements';
import { instance } from '@/instance';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
initialTab?: string; initialTab?: string;

View File

@ -4,7 +4,7 @@
<MkSpacer :content-max="700" :margin-min="16"> <MkSpacer :content-max="700" :margin-min="16">
<div class="lxpfedzu"> <div class="lxpfedzu">
<div class="banner"> <div class="banner">
<img :src="$instance.iconUrl || '/favicon.ico'" alt="" class="icon"/> <img :src="instance.iconUrl || '/favicon.ico'" alt="" class="icon"/>
</div> </div>
<MkInfo v-if="thereIsUnresolvedAbuseReport" warn class="info">{{ i18n.ts.thereIsUnresolvedAbuseReportWarning }} <MkA to="/admin/abuses" class="_link">{{ i18n.ts.check }}</MkA></MkInfo> <MkInfo v-if="thereIsUnresolvedAbuseReport" warn class="info">{{ i18n.ts.thereIsUnresolvedAbuseReportWarning }} <MkA to="/admin/abuses" class="_link">{{ i18n.ts.check }}</MkA></MkInfo>
@ -221,7 +221,7 @@ onUnmounted(() => {
}); });
watch(router.currentRef, (to) => { watch(router.currentRef, (to) => {
if (to.route.path === "/admin" && to.child?.route.name == null && !narrow) { if (to.route.path === '/admin' && to.child?.route.name == null && !narrow) {
router.replace('/admin/overview'); router.replace('/admin/overview');
} }
}); });

View File

@ -14,7 +14,7 @@
</div> </div>
<div class="contents"> <div class="contents">
<div class="main"> <div class="main">
<img :src="$instance.iconUrl || $instance.faviconUrl || '/favicon.ico'" alt="" class="icon"/> <img :src="instance.iconUrl || instance.faviconUrl || '/favicon.ico'" alt="" class="icon"/>
<button class="_button _acrylic menu" @click="showMenu"><i class="ti ti-dots"></i></button> <button class="_button _acrylic menu" @click="showMenu"><i class="ti ti-dots"></i></button>
<div class="fg"> <div class="fg">
<h1> <h1>

View File

@ -2,9 +2,9 @@
<div class="kmwsukvl"> <div class="kmwsukvl">
<div class="body"> <div class="body">
<div class="top"> <div class="top">
<div class="banner" :style="{ backgroundImage: `url(${ $instance.bannerUrl })` }"></div> <div class="banner" :style="{ backgroundImage: `url(${ instance.bannerUrl })` }"></div>
<button v-click-anime class="item _button instance" @click="openInstanceMenu"> <button v-click-anime class="item _button instance" @click="openInstanceMenu">
<img :src="$instance.iconUrl || $instance.faviconUrl || '/favicon.ico'" alt="" class="icon"/> <img :src="instance.iconUrl || instance.faviconUrl || '/favicon.ico'" alt="" class="icon"/>
</button> </button>
</div> </div>
<div class="middle"> <div class="middle">
@ -50,6 +50,7 @@ import { navbarItemDef } from '@/navbar';
import { openAccountMenu as openAccountMenu_ } from '@/account'; import { openAccountMenu as openAccountMenu_ } from '@/account';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { instance } from '@/instance';
const menu = toRef(defaultStore.state, 'menu'); const menu = toRef(defaultStore.state, 'menu');
const otherMenuItemIndicated = computed(() => { const otherMenuItemIndicated = computed(() => {

View File

@ -2,9 +2,9 @@
<div class="mvcprjjd" :class="{ iconOnly }"> <div class="mvcprjjd" :class="{ iconOnly }">
<div class="body"> <div class="body">
<div class="top"> <div class="top">
<div class="banner" :style="{ backgroundImage: `url(${ $instance.bannerUrl })` }"></div> <div class="banner" :style="{ backgroundImage: `url(${ instance.bannerUrl })` }"></div>
<button v-click-anime v-tooltip.noDelay.right="$instance.name ?? i18n.ts.instance" class="item _button instance" @click="openInstanceMenu"> <button v-click-anime v-tooltip.noDelay.right="instance.name ?? i18n.ts.instance" class="item _button instance" @click="openInstanceMenu">
<img :src="$instance.iconUrl || $instance.faviconUrl || '/favicon.ico'" alt="" class="icon"/> <img :src="instance.iconUrl || instance.faviconUrl || '/favicon.ico'" alt="" class="icon"/>
</button> </button>
</div> </div>
<div class="middle"> <div class="middle">
@ -60,6 +60,7 @@ import { navbarItemDef } from '@/navbar';
import { $i, openAccountMenu as openAccountMenu_ } from '@/account'; import { $i, openAccountMenu as openAccountMenu_ } from '@/account';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { instance } from '@/instance';
const iconOnly = ref(false); const iconOnly = ref(false);

View File

@ -3,7 +3,7 @@
<div class="body"> <div class="body">
<div class="left"> <div class="left">
<button v-click-anime class="item _button instance" @click="openInstanceMenu"> <button v-click-anime class="item _button instance" @click="openInstanceMenu">
<img :src="$instance.iconUrl ?? $instance.faviconUrl ?? '/favicon.ico'" class="_ghost"/> <img :src="instance.iconUrl ?? instance.faviconUrl ?? '/favicon.ico'" class="_ghost"/>
</button> </button>
<MkA v-click-anime v-tooltip="$ts.timeline" class="item index" active-class="active" to="/" exact> <MkA v-click-anime v-tooltip="$ts.timeline" class="item index" active-class="active" to="/" exact>
<i class="ti ti-home ti-fw"></i> <i class="ti ti-home ti-fw"></i>
@ -51,6 +51,7 @@ import { openAccountMenu } from '@/account';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { mainRouter } from '@/router'; import { mainRouter } from '@/router';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import { instance } from '@/instance';
export default defineComponent({ export default defineComponent({
components: { components: {
@ -65,6 +66,7 @@ export default defineComponent({
navbarItemDef: navbarItemDef, navbarItemDef: navbarItemDef,
settingsWindowed: false, settingsWindowed: false,
defaultStore, defaultStore,
instance,
}; };
}, },

View File

@ -33,7 +33,7 @@
<div class="divider"></div> <div class="divider"></div>
<div class="about"> <div class="about">
<button v-click-anime class="item _button" @click="openInstanceMenu"> <button v-click-anime class="item _button" @click="openInstanceMenu">
<img :src="$instance.iconUrl ?? $instance.faviconUrl ?? '/favicon.ico'" class="_ghost"/> <img :src="instance.iconUrl ?? instance.faviconUrl ?? '/favicon.ico'" class="_ghost"/>
</button> </button>
</div> </div>
<!--<MisskeyLogo class="misskey"/>--> <!--<MisskeyLogo class="misskey"/>-->
@ -52,6 +52,7 @@ import { StickySidebar } from '@/scripts/sticky-sidebar';
import { mainRouter } from '@/router'; import { mainRouter } from '@/router';
//import MisskeyLogo from '@assets/client/misskey.svg'; //import MisskeyLogo from '@assets/client/misskey.svg';
import { defaultStore } from '@/store'; import { defaultStore } from '@/store';
import { instance } from '@/instance';
export default defineComponent({ export default defineComponent({
components: { components: {
@ -68,6 +69,7 @@ export default defineComponent({
iconOnly: false, iconOnly: false,
settingsWindowed: false, settingsWindowed: false,
defaultStore, defaultStore,
instance,
}; };
}, },

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="mk-app"> <div class="mk-app">
<div v-if="mainRouter.currentRoute?.name === 'index'" class="banner" :style="{ backgroundImage: `url(${ $instance.bannerUrl })` }"> <div v-if="mainRouter.currentRoute?.name === 'index'" class="banner" :style="{ backgroundImage: `url(${ instance.bannerUrl })` }">
<div> <div>
<h1 v-if="meta"><img v-if="meta.logoImageUrl" class="logo" :src="meta.logoImageUrl"><span v-else class="text">{{ instanceName }}</span></h1> <h1 v-if="meta"><img v-if="meta.logoImageUrl" class="logo" :src="meta.logoImageUrl"><span v-else class="text">{{ instanceName }}</span></h1>
<div v-if="meta" class="about"> <div v-if="meta" class="about">
@ -13,7 +13,7 @@
</div> </div>
</div> </div>
</div> </div>
<div v-else class="banner-mini" :style="{ backgroundImage: `url(${ $instance.bannerUrl })` }"> <div v-else class="banner-mini" :style="{ backgroundImage: `url(${ instance.bannerUrl })` }">
<div> <div>
<h1 v-if="meta"><img v-if="meta.logoImageUrl" class="logo" :src="meta.logoImageUrl"><span v-else class="text">{{ instanceName }}</span></h1> <h1 v-if="meta"><img v-if="meta.logoImageUrl" class="logo" :src="meta.logoImageUrl"><span v-else class="text">{{ instanceName }}</span></h1>
</div> </div>
@ -44,6 +44,7 @@ import * as os from '@/os';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { defaultStore, ColdDeviceStorage } from '@/store'; import { defaultStore, ColdDeviceStorage } from '@/store';
import { mainRouter } from '@/router'; import { mainRouter } from '@/router';
import { instance } from '@/instance';
const DESKTOP_THRESHOLD = 1100; const DESKTOP_THRESHOLD = 1100;
@ -67,6 +68,7 @@ export default defineComponent({
mainRouter, mainRouter,
isDesktop: window.innerWidth >= DESKTOP_THRESHOLD, isDesktop: window.innerWidth >= DESKTOP_THRESHOLD,
defaultStore, defaultStore,
instance,
}; };
}, },

View File

@ -1,6 +1,6 @@
<!-- eslint-disable vue/no-v-html --> <!-- eslint-disable vue/no-v-html -->
<template> <template>
<div class="rwqkcmrc" :style="{ backgroundImage: transparent ? 'none' : `url(${ $instance.backgroundImageUrl })` }"> <div class="rwqkcmrc" :style="{ backgroundImage: transparent ? 'none' : `url(${ instance.backgroundImageUrl })` }">
<div class="back" :class="{ transparent }"></div> <div class="back" :class="{ transparent }"></div>
<div class="contents"> <div class="contents">
<div class="wrapper"> <div class="wrapper">
@ -45,6 +45,7 @@ import MkPagination from '@/components/MkPagination.vue';
import XSigninDialog from '@/components/MkSigninDialog.vue'; import XSigninDialog from '@/components/MkSigninDialog.vue';
import XSignupDialog from '@/components/MkSignupDialog.vue'; import XSignupDialog from '@/components/MkSignupDialog.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { instance } from '@/instance';
export default defineComponent({ export default defineComponent({
components: { components: {
@ -81,6 +82,7 @@ export default defineComponent({
endpoint: 'announcements', endpoint: 'announcements',
limit: 10, limit: 10,
}, },
instance,
}; };
}, },

View File

@ -1,12 +1,12 @@
<template> <template>
<div class="_panel"> <div class="_panel">
<div :class="$style.container" :style="{ backgroundImage: $instance.bannerUrl ? `url(${ $instance.bannerUrl })` : null }"> <div :class="$style.container" :style="{ backgroundImage: instance.bannerUrl ? `url(${ instance.bannerUrl })` : null }">
<div :class="$style.iconContainer"> <div :class="$style.iconContainer">
<img :src="$instance.iconUrl ?? $instance.faviconUrl ?? '/favicon.ico'" alt="" :class="$style.icon"/> <img :src="instance.iconUrl ?? instance.faviconUrl ?? '/favicon.ico'" alt="" :class="$style.icon"/>
</div> </div>
<div :class="$style.bodyContainer"> <div :class="$style.bodyContainer">
<div :class="$style.body"> <div :class="$style.body">
<MkA :class="$style.name" to="/about" behavior="window">{{ $instance.name }}</MkA> <MkA :class="$style.name" to="/about" behavior="window">{{ instance.name }}</MkA>
<div :class="$style.host">{{ host }}</div> <div :class="$style.host">{{ host }}</div>
</div> </div>
</div> </div>
@ -18,6 +18,7 @@
import { useWidgetPropsManager, Widget, WidgetComponentExpose } from './widget'; import { useWidgetPropsManager, Widget, WidgetComponentExpose } from './widget';
import { GetFormResultType } from '@/scripts/form'; import { GetFormResultType } from '@/scripts/form';
import { host } from '@/config'; import { host } from '@/config';
import { instance } from '@/instance';
const name = 'instanceInfo'; const name = 'instanceInfo';