From c0dd5aa9646a18cfef857adfe79a34714f1dd533 Mon Sep 17 00:00:00 2001 From: ThatOneCalculator Date: Fri, 2 Jun 2023 23:28:21 -0700 Subject: [PATCH] =?UTF-8?q?perf:=20=E3=82=A4=E3=83=B3=E3=82=B9=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=82=B9=E3=83=87=E3=83=95=E3=82=A9=E3=83=AB=E3=83=88?= =?UTF-8?q?=E3=83=86=E3=83=BC=E3=83=9E=E3=82=92=E4=BA=88=E3=82=81json5=20-?= =?UTF-8?q?>=20json=E3=81=AB=E5=A4=89=E6=8F=9B=E3=81=97=E3=81=A6=E3=81=8A?= =?UTF-8?q?=E3=81=8F=E3=81=93=E3=81=A8=E3=81=A7json5=E3=82=92=E5=88=9D?= =?UTF-8?q?=E6=9C=9F=E3=83=90=E3=83=B3=E3=83=89=E3=83=AB=E3=81=AB=E5=90=AB?= =?UTF-8?q?=E3=82=81=E3=81=9A=E3=81=AB=E6=B8=88=E3=82=80=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Syuilo --- packages/backend/src/server/api/endpoints/meta.ts | 10 ++++++++-- packages/client/src/init.ts | 5 ++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/backend/src/server/api/endpoints/meta.ts b/packages/backend/src/server/api/endpoints/meta.ts index 139afc88b..23cfe4018 100644 --- a/packages/backend/src/server/api/endpoints/meta.ts +++ b/packages/backend/src/server/api/endpoints/meta.ts @@ -1,3 +1,4 @@ +import * as JSON5 from "json5"; import { IsNull, MoreThan } from "typeorm"; import config from "@/config/index.js"; import { fetchMeta } from "@/misc/fetch-meta.js"; @@ -462,8 +463,13 @@ export default define(meta, paramDef, async (ps, me) => { maxNoteTextLength: MAX_NOTE_TEXT_LENGTH, // 後方互換性のため maxCaptionTextLength: MAX_CAPTION_TEXT_LENGTH, emojis: instance.privateMode && !me ? [] : await Emojis.packMany(emojis), - 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: instance.privateMode && !me ? [] diff --git a/packages/client/src/init.ts b/packages/client/src/init.ts index 7a004688d..5d9ae12f3 100644 --- a/packages/client/src/init.ts +++ b/packages/client/src/init.ts @@ -27,7 +27,6 @@ import { defineAsyncComponent, } from "vue"; import { compareVersions } from "compare-versions"; -import JSON5 from "json5"; import widgets from "@/widgets"; import directives from "@/directives"; @@ -312,12 +311,12 @@ import { getAccountFromId } from "@/scripts/get-account-from-id"; if (instance.defaultLightTheme != null) ColdDeviceStorage.set( "lightTheme", - JSON5.parse(instance.defaultLightTheme), + JSON.parse(instance.defaultLightTheme), ); if (instance.defaultDarkTheme != null) ColdDeviceStorage.set( "darkTheme", - JSON5.parse(instance.defaultDarkTheme), + JSON.parse(instance.defaultDarkTheme), ); defaultStore.set("themeInitial", false); }