From c5bb88143850fb0544054d67e505171674887e8c Mon Sep 17 00:00:00 2001 From: syuilo <4439005+syuilo@users.noreply.github.com> Date: Wed, 27 Aug 2025 12:40:11 +0900 Subject: [PATCH] refactor --- packages/frontend/src/aiscript/ui.ts | 8 +++----- packages/frontend/src/pages/scratchpad.vue | 10 ++++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/frontend/src/aiscript/ui.ts b/packages/frontend/src/aiscript/ui.ts index a27ece512e..9c330da3c5 100644 --- a/packages/frontend/src/aiscript/ui.ts +++ b/packages/frontend/src/aiscript/ui.ts @@ -4,11 +4,11 @@ */ import { utils, values } from '@syuilo/aiscript'; -import { genId } from '@/utility/id.js'; import { ref } from 'vue'; -import type { Ref } from 'vue'; import * as Misskey from 'misskey-js'; import { assertStringAndIsIn } from './common.js'; +import type { Ref } from 'vue'; +import { genId } from '@/utility/id.js'; const ALIGNS = ['left', 'center', 'right'] as const; const FONTS = ['serif', 'sans-serif', 'monospace'] as const; @@ -21,16 +21,15 @@ type BorderStyle = (typeof BORDER_STYLES)[number]; export type AsUiComponentBase = { id: string; hidden?: boolean; + children?: AsUiComponent['id'][]; }; export type AsUiRoot = AsUiComponentBase & { type: 'root'; - children: AsUiComponent['id'][]; }; export type AsUiContainer = AsUiComponentBase & { type: 'container'; - children?: AsUiComponent['id'][]; align?: Align; bgColor?: string; fgColor?: string; @@ -123,7 +122,6 @@ export type AsUiSelect = AsUiComponentBase & { export type AsUiFolder = AsUiComponentBase & { type: 'folder'; - children?: AsUiComponent['id'][]; title?: string; opened?: boolean; }; diff --git a/packages/frontend/src/pages/scratchpad.vue b/packages/frontend/src/pages/scratchpad.vue index 751a67190a..7fb64c2947 100644 --- a/packages/frontend/src/pages/scratchpad.vue +++ b/packages/frontend/src/pages/scratchpad.vue @@ -82,10 +82,10 @@ const logs = ref<{ text: string; print: boolean; }[]>([]); -const root = ref(); +const root = ref(); const components = ref[]>([]); const uiKey = ref(0); -const uiInspectorOpenedComponents = ref(new Map); +const uiInspectorOpenedComponents = ref(new Map, boolean>); const saved = miLocalStorage.getItem('scratchpad'); if (saved) { @@ -186,11 +186,13 @@ const headerActions = computed(() => []); const headerTabs = computed(() => []); const showns = computed(() => { + if (root.value == null) return new Set(); const result = new Set(); (function addChildrenToResult(c: AsUiComponent) { result.add(c.id); - if (c.children) { - const childComponents = components.value.filter(v => c.children.includes(v.value.id)); + const children = c.children; + if (children) { + const childComponents = components.value.filter(v => children.includes(v.value.id)); for (const child of childComponents) { addChildrenToResult(child.value); }