wip
This commit is contained in:
parent
d9f3f0c972
commit
0e3022860b
|
@ -50,7 +50,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
<div :class="$style.noteHeaderInfo">
|
<div :class="$style.noteHeaderInfo">
|
||||||
<a :href="url" :class="$style.noteHeaderInstanceIconLink" target="_blank" rel="noopener noreferrer">
|
<a :href="url" :class="$style.noteHeaderInstanceIconLink" target="_blank" rel="noopener noreferrer">
|
||||||
<img :src="instance.iconUrl || '/favicon.ico'" alt="" :class="$style.noteHeaderInstanceIcon"/>
|
<img :src="serverMetadataiconUrl || '/favicon.ico'" alt="" :class="$style.noteHeaderInstanceIcon"/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -142,7 +142,7 @@ import { userPage } from '@/utils.js';
|
||||||
import { notePage } from '@/utils.js';
|
import { notePage } from '@/utils.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { shouldCollapsed } from '@/to-be-shared/collapsed.js';
|
import { shouldCollapsed } from '@/to-be-shared/collapsed.js';
|
||||||
import { instance } from '@/server-metadata.js';
|
import { serverMetadata } from '@/server-metadata.js';
|
||||||
import { url } from '@/config.js';
|
import { url } from '@/config.js';
|
||||||
import EmMfm from '@/components/EmMfm.js';
|
import EmMfm from '@/components/EmMfm.js';
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { misskeyApi } from '@/misskey-api.js';
|
|
||||||
|
|
||||||
const providedMetaEl = document.getElementById('misskey_meta');
|
|
||||||
|
|
||||||
const _instance = (providedMetaEl && providedMetaEl.textContent) ? JSON.parse(providedMetaEl.textContent) : null;
|
|
||||||
|
|
||||||
// NOTE: devモードのときしか _instance が null になることは無い
|
|
||||||
export const instance = _instance ?? await misskeyApi('meta', {
|
|
||||||
detail: true,
|
|
||||||
});
|
|
|
@ -19,7 +19,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<a :href="url" :class="$style.instanceIconLink" target="_blank" rel="noopener noreferrer">
|
<a :href="url" :class="$style.instanceIconLink" target="_blank" rel="noopener noreferrer">
|
||||||
<img
|
<img
|
||||||
:class="$style.instanceIcon"
|
:class="$style.instanceIcon"
|
||||||
:src="instance.iconUrl || '/favicon.ico'"
|
:src="serverMetadataiconUrl || '/favicon.ico'"
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -41,6 +41,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, computed, shallowRef, inject, onActivated } from 'vue';
|
import { ref, computed, shallowRef, inject, onActivated } from 'vue';
|
||||||
import * as Misskey from 'misskey-js';
|
import * as Misskey from 'misskey-js';
|
||||||
|
import { scrollToTop } from '@@/js/scroll.js';
|
||||||
import type { Paging } from '@/components/EmPagination.vue';
|
import type { Paging } from '@/components/EmPagination.vue';
|
||||||
import type { ParsedEmbedParams } from '@/embed-page.js';
|
import type { ParsedEmbedParams } from '@/embed-page.js';
|
||||||
import EmNotes from '@/components/EmNotes.vue';
|
import EmNotes from '@/components/EmNotes.vue';
|
||||||
|
@ -48,9 +49,8 @@ import XNotFound from '@/pages/not-found.vue';
|
||||||
import EmTimelineContainer from '@/components/EmTimelineContainer.vue';
|
import EmTimelineContainer from '@/components/EmTimelineContainer.vue';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { instance } from '@/server-metadata.js';
|
import { serverMetadata } from '@/server-metadata.js';
|
||||||
import { url, instanceName } from '@/config.js';
|
import { url, instanceName } from '@/config.js';
|
||||||
import { scrollToTop } from '@@/js/scroll.js';
|
|
||||||
import { isLink } from '@/scripts/is-link.js';
|
import { isLink } from '@/scripts/is-link.js';
|
||||||
import { defaultEmbedParams } from '@/embed-page.js';
|
import { defaultEmbedParams } from '@/embed-page.js';
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<a :href="url" :class="$style.instanceIconLink" target="_blank" rel="noopener noreferrer">
|
<a :href="url" :class="$style.instanceIconLink" target="_blank" rel="noopener noreferrer">
|
||||||
<img
|
<img
|
||||||
:class="$style.instanceIcon"
|
:class="$style.instanceIcon"
|
||||||
:src="instance.iconUrl || '/favicon.ico'"
|
:src="serverMetadataiconUrl || '/favicon.ico'"
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -39,15 +39,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, shallowRef, inject, onActivated } from 'vue';
|
import { computed, shallowRef, inject, onActivated } from 'vue';
|
||||||
|
import { scrollToTop } from '@@/js/scroll.js';
|
||||||
import type { Paging } from '@/components/MkPagination.vue';
|
import type { Paging } from '@/components/MkPagination.vue';
|
||||||
import type { ParsedEmbedParams } from '@/embed-page.js';
|
import type { ParsedEmbedParams } from '@/embed-page.js';
|
||||||
import EmNotes from '@/components/EmNotes.vue';
|
import EmNotes from '@/components/EmNotes.vue';
|
||||||
import XNotFound from '@/pages/not-found.vue';
|
import XNotFound from '@/pages/not-found.vue';
|
||||||
import EmTimelineContainer from '@/components/EmTimelineContainer.vue';
|
import EmTimelineContainer from '@/components/EmTimelineContainer.vue';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { instance } from '@/server-metadata.js';
|
import { serverMetadata } from '@/server-metadata.js';
|
||||||
import { url, instanceName } from '@/config.js';
|
import { url, instanceName } from '@/config.js';
|
||||||
import { scrollToTop } from '@@/js/scroll.js';
|
|
||||||
import { isLink } from '@/scripts/is-link.js';
|
import { isLink } from '@/scripts/is-link.js';
|
||||||
import { defaultEmbedParams } from '@/embed-page.js';
|
import { defaultEmbedParams } from '@/embed-page.js';
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<a :href="url" :class="$style.instanceIconLink" target="_blank" rel="noopener noreferrer">
|
<a :href="url" :class="$style.instanceIconLink" target="_blank" rel="noopener noreferrer">
|
||||||
<img
|
<img
|
||||||
:class="$style.instanceIcon"
|
:class="$style.instanceIcon"
|
||||||
:src="instance.iconUrl || '/favicon.ico'"
|
:src="serverMetadataiconUrl || '/favicon.ico'"
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,7 +62,7 @@ import XNotFound from '@/pages/not-found.vue';
|
||||||
import EmTimelineContainer from '@/components/EmTimelineContainer.vue';
|
import EmTimelineContainer from '@/components/EmTimelineContainer.vue';
|
||||||
import { misskeyApi } from '@/misskey-api.js';
|
import { misskeyApi } from '@/misskey-api.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { instance } from '@/server-metadata.js';
|
import { serverMetadata } from '@/server-metadata.js';
|
||||||
import { url, instanceName } from '@/config.js';
|
import { url, instanceName } from '@/config.js';
|
||||||
import { defaultEmbedParams } from '@/embed-page.js';
|
import { defaultEmbedParams } from '@/embed-page.js';
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { misskeyApi } from '@/misskey-api.js';
|
||||||
|
|
||||||
|
const providedMetaEl = document.getElementById('misskey_meta');
|
||||||
|
|
||||||
|
const _serverMetadata = (providedMetaEl && providedMetaEl.textContent) ? JSON.parse(providedMetaEl.textContent) : null;
|
||||||
|
|
||||||
|
// NOTE: devモードのときしか _serverMetadata が null になることは無い
|
||||||
|
export const serverMetadata = _serverMetadata ?? await misskeyApi('meta', {
|
||||||
|
detail: true,
|
||||||
|
});
|
|
@ -4,6 +4,8 @@
|
||||||
*/
|
*/
|
||||||
import type { ILocale, ParameterizedString } from '../../../locales/index.js';
|
import type { ILocale, ParameterizedString } from '../../../locales/index.js';
|
||||||
|
|
||||||
|
type TODO = any;
|
||||||
|
|
||||||
type FlattenKeys<T extends ILocale, TPrediction> = keyof {
|
type FlattenKeys<T extends ILocale, TPrediction> = keyof {
|
||||||
[K in keyof T as T[K] extends ILocale
|
[K in keyof T as T[K] extends ILocale
|
||||||
? FlattenKeys<T[K], TPrediction> extends infer C extends string
|
? FlattenKeys<T[K], TPrediction> extends infer C extends string
|
||||||
|
@ -116,7 +118,7 @@ export class I18n<T extends ILocale> {
|
||||||
return () => value;
|
return () => value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (arg) => {
|
return (arg: TODO) => {
|
||||||
let str = quasis[0];
|
let str = quasis[0];
|
||||||
|
|
||||||
for (let i = 0; i < expressions.length; i++) {
|
for (let i = 0; i < expressions.length; i++) {
|
||||||
|
@ -155,7 +157,7 @@ export class I18n<T extends ILocale> {
|
||||||
const value = target[k as keyof typeof target];
|
const value = target[k as keyof typeof target];
|
||||||
|
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
result[k] = build(value as ILocale);
|
(result as TODO)[k] = build(value as ILocale);
|
||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
const quasis: string[] = [];
|
const quasis: string[] = [];
|
||||||
const expressions: string[] = [];
|
const expressions: string[] = [];
|
||||||
|
@ -182,7 +184,7 @@ export class I18n<T extends ILocale> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
result[k] = (arg) => {
|
(result as TODO)[k] = (arg: TODO) => {
|
||||||
let str = quasis[0];
|
let str = quasis[0];
|
||||||
|
|
||||||
for (let i = 0; i < expressions.length; i++) {
|
for (let i = 0; i < expressions.length; i++) {
|
||||||
|
@ -211,7 +213,7 @@ export class I18n<T extends ILocale> {
|
||||||
let str: string | ParameterizedString | ILocale = this.locale;
|
let str: string | ParameterizedString | ILocale = this.locale;
|
||||||
|
|
||||||
for (const k of key.split('.')) {
|
for (const k of key.split('.')) {
|
||||||
str = str[k];
|
str = (str as TODO)[k];
|
||||||
|
|
||||||
if (this.devMode) {
|
if (this.devMode) {
|
||||||
if (typeof str === 'undefined') {
|
if (typeof str === 'undefined') {
|
||||||
|
|
Loading…
Reference in New Issue