summaryrefslogtreecommitdiff
path: root/packages
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2023-05-30 11:51:29 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2023-05-30 11:51:29 +0900
commit8f14b42e81ba891744cad19e4c6aa0d2d30f5e53 (patch)
tree616362cfeb09ac80db82d9d8f2039e0742788b2a /packages
parentvue-plyrやめるなど (diff)
downloadmisskey-8f14b42e81ba891744cad19e4c6aa0d2d30f5e53.tar.gz
misskey-8f14b42e81ba891744cad19e4c6aa0d2d30f5e53.tar.bz2
misskey-8f14b42e81ba891744cad19e4c6aa0d2d30f5e53.zip
perf: インスタンスデフォルトテーマを予めjson5 -> jsonに変換しておくことでjson5を初期バンドルに含めずに済むように
Diffstat (limited to 'packages')
-rw-r--r--packages/backend/src/server/api/endpoints/meta.ts6
-rw-r--r--packages/frontend/src/boot/common.ts5
2 files changed, 6 insertions, 5 deletions
diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts
index 584ea07c3b..53d724a9dd 100644
--- a/packages/backend/src/server/api/endpoints/meta.ts
+++ b/packages/backend/src/server/api/endpoints/meta.ts
@@ -1,5 +1,6 @@
import { IsNull, LessThanOrEqual, MoreThan } from 'typeorm';
import { Inject, Injectable } from '@nestjs/common';
+import * as JSON5 from 'json5';
import type { AdsRepository, UsersRepository } from '@/models/index.js';
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
import { Endpoint } from '@/server/api/endpoint-base.js';
@@ -292,8 +293,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
backgroundImageUrl: instance.backgroundImageUrl,
logoImageUrl: instance.logoImageUrl,
maxNoteTextLength: MAX_NOTE_TEXT_LENGTH,
- defaultLightTheme: instance.defaultLightTheme,
- defaultDarkTheme: instance.defaultDarkTheme,
+ // クライアントの手間を減らすためあらかじめJSONに変換しておく
+ defaultLightTheme: instance.defaultLightTheme ? JSON.stringify(JSON5.parse(instance.defaultLightTheme)) : null,
+ defaultDarkTheme: instance.defaultDarkTheme ? JSON.stringify(JSON5.parse(instance.defaultDarkTheme)) : null,
ads: ads.map(ad => ({
id: ad.id,
url: ad.url,
diff --git a/packages/frontend/src/boot/common.ts b/packages/frontend/src/boot/common.ts
index e9d6586f85..e1b12fe7d6 100644
--- a/packages/frontend/src/boot/common.ts
+++ b/packages/frontend/src/boot/common.ts
@@ -1,6 +1,5 @@
import { computed, createApp, watch, markRaw, version as vueVersion, defineAsyncComponent, App } from 'vue';
import { compareVersions } from 'compare-versions';
-import JSON5 from 'json5';
import widgets from '@/widgets';
import directives from '@/directives';
import components from '@/components';
@@ -180,8 +179,8 @@ export async function common(createVue: () => App<Element>) {
fetchInstanceMetaPromise.then(() => {
if (defaultStore.state.themeInitial) {
- if (instance.defaultLightTheme != null) ColdDeviceStorage.set('lightTheme', JSON5.parse(instance.defaultLightTheme));
- if (instance.defaultDarkTheme != null) ColdDeviceStorage.set('darkTheme', JSON5.parse(instance.defaultDarkTheme));
+ if (instance.defaultLightTheme != null) ColdDeviceStorage.set('lightTheme', JSON.parse(instance.defaultLightTheme));
+ if (instance.defaultDarkTheme != null) ColdDeviceStorage.set('darkTheme', JSON.parse(instance.defaultDarkTheme));
defaultStore.set('themeInitial', false);
}
});