refactor(frontend): os.select, MkSelectのitem指定をオブジェクトによる定義に統一し、型を狭める (#16475)

* refactor(frontend): MkSelectのitem指定をオブジェクトによる定義に統一

* fix

* spdx

* fix

* fix os.select

* fix lint

* add comment

* fix

* fix: os.select対応漏れを修正

* fix

* fix

* fix: MkSelectのmodelに対する型チェックを厳格化

* fix

* fix

* fix

* Update packages/frontend/src/components/MkEmbedCodeGenDialog.vue

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>

* fix

* fix types

* fix

* fix

* Update packages/frontend/src/pages/admin/roles.editor.vue

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>

* fix: MkSelectに直接配列を指定している場合に正常に型が解決されるように

---------

Co-authored-by: syuilo <4439005+syuilo@users.noreply.github.com>
This commit is contained in:
かっこかり
2025-09-13 21:00:33 +09:00
committed by GitHub
parent b7da6cad87
commit d4654dd7bd
64 changed files with 1171 additions and 765 deletions

View File

@@ -30,7 +30,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</div>
<div :class="$style.controls">
<div class="_spacer _gaps">
<MkSelect v-model="type" :items="[{ label: i18n.ts._watermarkEditor.text, value: 'text' }, { label: i18n.ts._watermarkEditor.image, value: 'image' }, { label: i18n.ts._watermarkEditor.advanced, value: 'advanced' }]">
<MkSelect v-model="type" :items="typeDef">
<template #label>{{ i18n.ts._watermarkEditor.type }}</template>
</MkSelect>
@@ -86,6 +86,7 @@ import * as os from '@/os.js';
import { deepClone } from '@/utility/clone.js';
import { ensureSignin } from '@/i.js';
import { genId } from '@/utility/id.js';
import { useMkSelect } from '@/composables/use-mkselect.js';
const $i = ensureSignin();
@@ -186,7 +187,18 @@ async function cancel() {
dialog.value?.close();
}
const type = ref(preset.layers.length > 1 ? 'advanced' : preset.layers[0].type);
const {
model: type,
def: typeDef,
} = useMkSelect({
items: [
{ label: i18n.ts._watermarkEditor.text, value: 'text' },
{ label: i18n.ts._watermarkEditor.image, value: 'image' },
{ label: i18n.ts._watermarkEditor.advanced, value: 'advanced' },
],
initialValue: preset.layers.length > 1 ? 'advanced' : preset.layers[0].type,
});
watch(type, () => {
if (type.value === 'text') {
preset.layers = [createTextLayer()];