refactor(frontend): MkRadiosの指定をpropsから行うように

This commit is contained in:
kakkokari-gtyih 2025-10-04 18:14:57 +09:00
parent 3954837cfa
commit 7307893ee4
30 changed files with 552 additions and 268 deletions

View File

@ -47,7 +47,8 @@ import MkModal from '@/components/MkModal.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue'; import MkInput from '@/components/MkInput.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
import type { MkSelectItem, OptionValue } from '@/components/MkSelect.vue'; import type { MkSelectItem } from '@/components/MkSelect.vue';
import type { OptionValue } from '@/types/option-value.js';
import { useMkSelect } from '@/composables/use-mkselect.js'; import { useMkSelect } from '@/composables/use-mkselect.js';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';

View File

@ -42,9 +42,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSelect v-else-if="v.type === 'enum'" v-model="values[k]" :items="getMkSelectDef(v)"> <MkSelect v-else-if="v.type === 'enum'" v-model="values[k]" :items="getMkSelectDef(v)">
<template #label><span v-text="v.label || k"></span><span v-if="v.required === false"> ({{ i18n.ts.optional }})</span></template> <template #label><span v-text="v.label || k"></span><span v-if="v.required === false"> ({{ i18n.ts.optional }})</span></template>
</MkSelect> </MkSelect>
<MkRadios v-else-if="v.type === 'radio'" v-model="values[k]"> <MkRadios v-else-if="v.type === 'radio'" v-model="values[k]" :options="getRadioOptionsDef(v)">
<template #label><span v-text="v.label || k"></span><span v-if="v.required === false"> ({{ i18n.ts.optional }})</span></template> <template #label><span v-text="v.label || k"></span><span v-if="v.required === false"> ({{ i18n.ts.optional }})</span></template>
<option v-for="option in v.options" :key="getRadioKey(option)" :value="option.value">{{ option.label }}</option>
</MkRadios> </MkRadios>
<MkRange v-else-if="v.type === 'range'" v-model="values[k]" :min="v.min" :max="v.max" :step="v.step" :textConverter="v.textConverter"> <MkRange v-else-if="v.type === 'range'" v-model="values[k]" :min="v.min" :max="v.max" :step="v.step" :textConverter="v.textConverter">
<template #label><span v-text="v.label || k"></span><span v-if="v.required === false"> ({{ i18n.ts.optional }})</span></template> <template #label><span v-text="v.label || k"></span><span v-if="v.required === false"> ({{ i18n.ts.optional }})</span></template>
@ -77,6 +76,7 @@ import MkButton from './MkButton.vue';
import MkRadios from './MkRadios.vue'; import MkRadios from './MkRadios.vue';
import XFile from './MkFormDialog.file.vue'; import XFile from './MkFormDialog.file.vue';
import type { MkSelectItem } from '@/components/MkSelect.vue'; import type { MkSelectItem } from '@/components/MkSelect.vue';
import type { RadioOption } from '@/components/MkRadios.vue';
import type { Form, EnumFormItem, RadioFormItem } from '@/utility/form.js'; import type { Form, EnumFormItem, RadioFormItem } from '@/utility/form.js';
import MkModalWindow from '@/components/MkModalWindow.vue'; import MkModalWindow from '@/components/MkModalWindow.vue';
import { i18n } from '@/i18n.js'; import { i18n } from '@/i18n.js';
@ -130,7 +130,13 @@ function getMkSelectDef(def: EnumFormItem): MkSelectItem[] {
}); });
} }
function getRadioKey(e: RadioFormItem['options'][number]) { function getRadioOptionsDef(def: RadioFormItem): RadioOption[] {
return typeof e.value === 'string' ? e.value : JSON.stringify(e.value); return def.options.map<RadioOption>((v) => {
if (typeof v === 'string') {
return { value: v, label: v };
} else {
return { value: v.value, label: v.label };
}
});
} }
</script> </script>

View File

@ -28,13 +28,9 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>{{ v.label ?? k }}</template> <template #label>{{ v.label ?? k }}</template>
<template v-if="v.caption != null" #caption>{{ v.caption }}</template> <template v-if="v.caption != null" #caption>{{ v.caption }}</template>
</MkRange> </MkRange>
<MkRadios v-else-if="v.type === 'number:enum'" v-model="params[k]"> <MkRadios v-else-if="v.type === 'number:enum'" v-model="params[k]" :options="v.enum">
<template #label>{{ v.label ?? k }}</template> <template #label>{{ v.label ?? k }}</template>
<template v-if="v.caption != null" #caption>{{ v.caption }}</template> <template v-if="v.caption != null" #caption>{{ v.caption }}</template>
<option v-for="item in v.enum" :value="item.value">
<i v-if="item.icon" :class="item.icon"></i>
<template v-else>{{ item.label }}</template>
</option>
</MkRadios> </MkRadios>
<div v-else-if="v.type === 'seed'"> <div v-else-if="v.type === 'seed'">
<MkRange v-model="params[k]" continuousUpdate type="number" :min="0" :max="10000" :step="1"> <MkRange v-model="params[k]" continuousUpdate type="number" :min="0" :max="10000" :step="1">

View File

@ -24,7 +24,8 @@ SPDX-License-Identifier: AGPL-3.0-only
</div> </div>
</template> </template>
<script lang="ts" setup generic="T extends unknown"> <script lang="ts" setup generic="T extends OptionValue | null">
import type { OptionValue } from '@/types/option-value.js';
import { computed } from 'vue'; import { computed } from 'vue';
const props = defineProps<{ const props = defineProps<{

View File

@ -3,99 +3,110 @@ SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only SPDX-License-Identifier: AGPL-3.0-only
--> -->
<template>
<div :class="{ [$style.vertical]: vertical }">
<div :class="$style.label">
<slot name="label"></slot>
</div>
<div :class="$style.body">
<MkRadio
v-for="option in options"
v-model="model"
:key="getKey(option.value)"
:disabled="option.disabled"
:value="option.value"
>
<div :class="$style.optionContent">
<i v-if="option.icon" :class="[$style.optionIcon, option.icon]" :style="option.iconStyle"></i>
<div>
<div :style="option.labelStyle">{{ option.label ?? option.value }}</div>
<div v-if="option.caption" :class="$style.optionCaption">{{ option.caption }}</div>
</div>
</div>
</MkRadio>
</div>
<div :class="$style.caption">
<slot name="caption"></slot>
</div>
</div>
</template>
<script lang="ts"> <script lang="ts">
import { defineComponent, h, ref, watch } from 'vue'; import type { StyleValue } from 'vue';
import MkRadio from './MkRadio.vue'; import type { OptionValue } from '@/types/option-value.js';
import type { VNode } from 'vue';
export default defineComponent({ export type RadioOption<T = OptionValue> = {
props: { value: T;
modelValue: { label?: string;
required: false, labelStyle?: StyleValue;
}, icon?: string;
vertical: { iconStyle?: StyleValue;
type: Boolean, caption?: string;
default: false, disabled?: boolean;
}, };
},
setup(props, context) {
const value = ref(props.modelValue);
watch(value, () => {
context.emit('update:modelValue', value.value);
});
watch(() => props.modelValue, v => {
value.value = v;
});
if (!context.slots.default) return null;
let options = context.slots.default();
const label = context.slots.label && context.slots.label();
const caption = context.slots.caption && context.slots.caption();
// Fragment
if (options.length === 1 && options[0].props == null) options = options[0].children as VNode[];
// vnodev-if=false(trueoptiontype)
options = options.filter(vnode => !(typeof vnode.type === 'symbol' && vnode.type.description === 'v-cmt' && vnode.children === 'v-if'));
return () => h('div', {
class: [
'novjtcto',
...(props.vertical ? ['vertical'] : []),
],
}, [
...(label ? [h('div', {
class: 'label',
}, label)] : []),
h('div', {
class: 'body',
}, options.map(option => h(MkRadio, {
key: option.key as string,
value: option.props?.value,
disabled: option.props?.disabled,
modelValue: value.value,
'onUpdate:modelValue': _v => value.value = _v,
}, () => option.children)),
),
...(caption ? [h('div', {
class: 'caption',
}, caption)] : []),
]);
},
});
</script> </script>
<style lang="scss"> <script setup lang="ts" generic="const T extends RadioOption">
.novjtcto { import MkRadio from './MkRadio.vue';
> .label {
font-size: 0.85em;
padding: 0 0 8px 0;
user-select: none;
&:empty { defineProps<{
display: none; options: T[];
} vertical?: boolean;
} }>();
> .body { const model = defineModel<T['value']>({ required: true });
display: flex;
gap: 10px;
flex-wrap: wrap;
}
> .caption { function getKey(value: OptionValue): PropertyKey {
font-size: 0.85em; if (value === null) return 'null';
padding: 8px 0 0 0; return value;
color: color(from var(--MI_THEME-fg) srgb r g b / 0.75); }
</script>
&:empty { <style lang="scss" module>
display: none; .label {
} font-size: 0.85em;
} padding: 0 0 8px 0;
user-select: none;
&.vertical { &:empty {
> .body { display: none;
flex-direction: column;
}
} }
} }
.body {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.caption {
font-size: 0.85em;
padding: 8px 0 0 0;
color: color(from var(--MI_THEME-fg) srgb r g b / 0.75);
&:empty {
display: none;
}
}
.optionContent {
display: flex;
align-items: center;
gap: 4px;
line-height: 1.1;
}
.optionCaption {
font-size: 0.85em;
padding: 4px 0 0 0;
color: color(from var(--MI_THEME-fg) srgb r g b / 0.75);
}
.optionIcon {
flex-shrink: 0;
}
.vertical > .body {
flex-direction: column;
}
</style> </style>

View File

@ -0,0 +1,107 @@
<!--
SPDX-FileCopyrightText: syuilo and misskey-project
SPDX-License-Identifier: AGPL-3.0-only
-->
<!--
古いMkRadiosの実装特殊な使い方をしていたため移行できなかった game.setting.vue でのみ使用
TODO: 移行して廃止
-->
<script lang="ts">
import { defineComponent, h, ref, watch } from 'vue';
import MkRadio from './MkRadio.vue';
import type { VNode } from 'vue';
import type { OptionValue } from '@/types/option-value';
export default defineComponent({
props: {
modelValue: {
required: false,
},
vertical: {
type: Boolean,
default: false,
},
},
setup(props, context) {
const value = ref(props.modelValue);
watch(value, () => {
context.emit('update:modelValue', value.value);
});
watch(() => props.modelValue, v => {
value.value = v;
});
if (!context.slots.default) return null;
let options = context.slots.default();
const label = context.slots.label && context.slots.label();
const caption = context.slots.caption && context.slots.caption();
// Fragment
if (options.length === 1 && options[0].props == null) options = options[0].children as VNode[];
// vnodev-if=false(trueoptiontype)
options = options.filter(vnode => !(typeof vnode.type === 'symbol' && vnode.type.description === 'v-cmt' && vnode.children === 'v-if'));
return () => h('div', {
class: [
'novjtcto',
...(props.vertical ? ['vertical'] : []),
],
}, [
...(label ? [h('div', {
class: 'label',
}, label)] : []),
h('div', {
class: 'body',
}, options.map(option => h(MkRadio, {
key: option.key as string,
value: option.props?.value,
disabled: option.props?.disabled,
modelValue: value.value as OptionValue,
'onUpdate:modelValue': _v => value.value = _v,
}, () => option.children)),
),
...(caption ? [h('div', {
class: 'caption',
}, caption)] : []),
]);
},
});
</script>
<style lang="scss">
.novjtcto {
> .label {
font-size: 0.85em;
padding: 0 0 8px 0;
user-select: none;
&:empty {
display: none;
}
}
> .body {
display: flex;
gap: 10px;
flex-wrap: wrap;
}
> .caption {
font-size: 0.85em;
padding: 8px 0 0 0;
color: color(from var(--MI_THEME-fg) srgb r g b / 0.75);
&:empty {
display: none;
}
}
&.vertical {
> .body {
flex-direction: column;
}
}
}
</style>

View File

@ -40,7 +40,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template> </template>
<script lang="ts"> <script lang="ts">
export type OptionValue = string | number | null; import type { OptionValue } from '@/types/option-value.js';
export type ItemOption<T extends OptionValue = OptionValue> = { export type ItemOption<T extends OptionValue = OptionValue> = {
type?: 'option'; type?: 'option';

View File

@ -14,19 +14,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #icon><i class="ti ti-settings-question"></i></template> <template #icon><i class="ti ti-settings-question"></i></template>
<div class="_gaps_s"> <div class="_gaps_s">
<MkRadios v-model="q_use" :vertical="true"> <MkRadios
<option value="single"> v-model="q_use"
<div><i class="ti ti-user"></i> <b>{{ i18n.ts._serverSetupWizard._use.single }}</b></div> :options="[
<div>{{ i18n.ts._serverSetupWizard._use.single_description }}</div> { value: 'single', label: i18n.ts._serverSetupWizard._use.single, icon: 'ti ti-user', caption: i18n.ts._serverSetupWizard._use.single_description },
</option> { value: 'group', label: i18n.ts._serverSetupWizard._use.group, icon: 'ti ti-lock', caption: i18n.ts._serverSetupWizard._use.group_description },
<option value="group"> { value: 'open', label: i18n.ts._serverSetupWizard._use.open, icon: 'ti ti-world', caption: i18n.ts._serverSetupWizard._use.open_description },
<div><i class="ti ti-lock"></i> <b>{{ i18n.ts._serverSetupWizard._use.group }}</b></div> ]"
<div>{{ i18n.ts._serverSetupWizard._use.group_description }}</div> vertical
</option> >
<option value="open">
<div><i class="ti ti-world"></i> <b>{{ i18n.ts._serverSetupWizard._use.open }}</b></div>
<div>{{ i18n.ts._serverSetupWizard._use.open_description }}</div>
</option>
</MkRadios> </MkRadios>
<MkInfo v-if="q_use === 'single'">{{ i18n.ts._serverSetupWizard._use.single_youCanCreateMultipleAccounts }}</MkInfo> <MkInfo v-if="q_use === 'single'">{{ i18n.ts._serverSetupWizard._use.single_youCanCreateMultipleAccounts }}</MkInfo>
@ -40,7 +36,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #icon><i class="ti ti-users"></i></template> <template #icon><i class="ti ti-users"></i></template>
<div class="_gaps_s"> <div class="_gaps_s">
<MkRadios v-model="q_scale" :vertical="true"> <MkRadios
v-model="q_scale"
:options="[
{ value: 'small', label: i18n.ts._serverSetupWizard._scale.small, icon: 'ti ti-user' },
{ value: 'medium', label: i18n.ts._serverSetupWizard._scale.medium, icon: 'ti ti-users' },
{ value: 'large', label: i18n.ts._serverSetupWizard._scale.large, icon: 'ti ti-users-group' },
]"
vertical
>
<option value="small"><i class="ti ti-user"></i> {{ i18n.ts._serverSetupWizard._scale.small }}</option> <option value="small"><i class="ti ti-user"></i> {{ i18n.ts._serverSetupWizard._scale.small }}</option>
<option value="medium"><i class="ti ti-users"></i> {{ i18n.ts._serverSetupWizard._scale.medium }}</option> <option value="medium"><i class="ti ti-users"></i> {{ i18n.ts._serverSetupWizard._scale.medium }}</option>
<option value="large"><i class="ti ti-users-group"></i> {{ i18n.ts._serverSetupWizard._scale.large }}</option> <option value="large"><i class="ti ti-users-group"></i> {{ i18n.ts._serverSetupWizard._scale.large }}</option>
@ -57,9 +61,14 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_gaps_s"> <div class="_gaps_s">
<div>{{ i18n.ts._serverSetupWizard.doYouConnectToFediverse_description1 }}<br>{{ i18n.ts._serverSetupWizard.doYouConnectToFediverse_description2 }}<br><MkLink target="_blank" url="https://wikipedia.org/wiki/Fediverse">{{ i18n.ts.learnMore }}</MkLink></div> <div>{{ i18n.ts._serverSetupWizard.doYouConnectToFediverse_description1 }}<br>{{ i18n.ts._serverSetupWizard.doYouConnectToFediverse_description2 }}<br><MkLink target="_blank" url="https://wikipedia.org/wiki/Fediverse">{{ i18n.ts.learnMore }}</MkLink></div>
<MkRadios v-model="q_federation" :vertical="true"> <MkRadios
<option value="yes">{{ i18n.ts.yes }}</option> v-model="q_federation"
<option value="no">{{ i18n.ts.no }}</option> :options="[
{ value: 'yes', label: i18n.ts.yes },
{ value: 'no', label: i18n.ts.no },
]"
vertical
>
</MkRadios> </MkRadios>
<MkInfo v-if="q_federation === 'yes'">{{ i18n.ts._serverSetupWizard.youCanConfigureMoreFederationSettingsLater }}</MkInfo> <MkInfo v-if="q_federation === 'yes'">{{ i18n.ts._serverSetupWizard.youCanConfigureMoreFederationSettingsLater }}</MkInfo>
@ -212,9 +221,9 @@ const props = withDefaults(defineProps<{
}); });
const q_name = ref(''); const q_name = ref('');
const q_use = ref('single'); const q_use = ref<'single' | 'group' | 'open'>('single');
const q_scale = ref('small'); const q_scale = ref<'small' | 'medium' | 'large'>('small');
const q_federation = ref('yes'); const q_federation = ref<'yes' | 'no'>('no');
const q_remoteContentsCleaning = ref(true); const q_remoteContentsCleaning = ref(true);
const q_adminName = ref(''); const q_adminName = ref('');
const q_adminEmail = ref(''); const q_adminEmail = ref('');

View File

@ -22,18 +22,26 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkTextarea v-model="text"> <MkTextarea v-model="text">
<template #label>{{ i18n.ts.text }}</template> <template #label>{{ i18n.ts.text }}</template>
</MkTextarea> </MkTextarea>
<MkRadios v-model="icon"> <MkRadios
v-model="icon"
:options="[
{ value: 'info', icon: 'ti ti-info-circle' },
{ value: 'warning', icon: 'ti ti-alert-triangle', iconStyle: 'color: var(--MI_THEME-warn);' },
{ value: 'error', icon: 'ti ti-circle-x', iconStyle: 'color: var(--MI_THEME-error);' },
{ value: 'success', icon: 'ti ti-check', iconStyle: 'color: var(--MI_THEME-success);' },
]"
>
<template #label>{{ i18n.ts.icon }}</template> <template #label>{{ i18n.ts.icon }}</template>
<option value="info"><i class="ti ti-info-circle"></i></option>
<option value="warning"><i class="ti ti-alert-triangle" style="color: var(--MI_THEME-warn);"></i></option>
<option value="error"><i class="ti ti-circle-x" style="color: var(--MI_THEME-error);"></i></option>
<option value="success"><i class="ti ti-check" style="color: var(--MI_THEME-success);"></i></option>
</MkRadios> </MkRadios>
<MkRadios v-model="display"> <MkRadios
v-model="display"
:options="[
{ value: 'normal', label: i18n.ts.normal },
{ value: 'banner', label: i18n.ts.banner },
{ value: 'dialog', label: i18n.ts.dialog },
]"
>
<template #label>{{ i18n.ts.display }}</template> <template #label>{{ i18n.ts.display }}</template>
<option value="normal">{{ i18n.ts.normal }}</option>
<option value="banner">{{ i18n.ts.banner }}</option>
<option value="dialog">{{ i18n.ts.dialog }}</option>
</MkRadios> </MkRadios>
<MkSwitch v-model="needConfirmationToRead"> <MkSwitch v-model="needConfirmationToRead">
{{ i18n.ts._announcement.needConfirmationToRead }} {{ i18n.ts._announcement.needConfirmationToRead }}

View File

@ -5,7 +5,8 @@
import { ref } from 'vue'; import { ref } from 'vue';
import type { Ref, MaybeRefOrGetter } from 'vue'; import type { Ref, MaybeRefOrGetter } from 'vue';
import type { MkSelectItem, OptionValue, GetMkSelectValueTypesFromDef } from '@/components/MkSelect.vue'; import type { MkSelectItem, GetMkSelectValueTypesFromDef } from '@/components/MkSelect.vue';
import type { OptionValue } from '@/types/option-value.js';
type UnwrapReadonlyItems<T> = T extends readonly (infer U)[] ? U[] : T; type UnwrapReadonlyItems<T> = T extends readonly (infer U)[] ? U[] : T;

View File

@ -14,7 +14,8 @@ import type { Form, GetFormResultType } from '@/utility/form.js';
import type { MenuItem } from '@/types/menu.js'; import type { MenuItem } from '@/types/menu.js';
import type { PostFormProps } from '@/types/post-form.js'; import type { PostFormProps } from '@/types/post-form.js';
import type { UploaderFeatures } from '@/composables/use-uploader.js'; import type { UploaderFeatures } from '@/composables/use-uploader.js';
import type { MkSelectItem, OptionValue } from '@/components/MkSelect.vue'; import type { MkSelectItem } from '@/components/MkSelect.vue';
import type { OptionValue } from '@/types/option-value.js';
import type MkRoleSelectDialog_TypeReferenceOnly from '@/components/MkRoleSelectDialog.vue'; import type MkRoleSelectDialog_TypeReferenceOnly from '@/components/MkRoleSelectDialog.vue';
import type MkEmojiPickerDialog_TypeReferenceOnly from '@/components/MkEmojiPickerDialog.vue'; import type MkEmojiPickerDialog_TypeReferenceOnly from '@/components/MkEmojiPickerDialog.vue';
import { misskeyApi } from '@/utility/misskey-api.js'; import { misskeyApi } from '@/utility/misskey-api.js';

View File

@ -22,11 +22,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>{{ i18n.ts.imageUrl }}</template> <template #label>{{ i18n.ts.imageUrl }}</template>
</MkInput> </MkInput>
<MkRadios v-model="ad.place"> <MkRadios
v-model="ad.place"
:options="[
{ value: 'square' },
{ value: 'horizontal' },
{ value: 'horizontal-big' },
]"
>
<template #label>Form</template> <template #label>Form</template>
<option value="square">square</option>
<option value="horizontal">horizontal</option>
<option value="horizontal-big">horizontal-big</option>
</MkRadios> </MkRadios>
<!-- <!--
@ -109,7 +113,11 @@ import { i18n } from '@/i18n.js';
import { definePage } from '@/page.js'; import { definePage } from '@/page.js';
import { useMkSelect } from '@/composables/use-mkselect.js'; import { useMkSelect } from '@/composables/use-mkselect.js';
const ads = ref<Misskey.entities.Ad[]>([]); type Ad = Misskey.entities.Ad & {
place: 'square' | 'horizontal' | 'horizontal-big';
};
const ads = ref<Ad[]>([]);
// ISOTZUTCTZ // ISOTZUTCTZ
const localTime = new Date(); const localTime = new Date();
@ -136,7 +144,7 @@ misskeyApi('admin/ad/list', { publishing: publishing }).then(adsResponse => {
exdate.setMilliseconds(exdate.getMilliseconds() - localTimeDiff); exdate.setMilliseconds(exdate.getMilliseconds() - localTimeDiff);
stdate.setMilliseconds(stdate.getMilliseconds() - localTimeDiff); stdate.setMilliseconds(stdate.getMilliseconds() - localTimeDiff);
return { return {
...r, ...(r as Ad),
expiresAt: exdate.toISOString().slice(0, 16), expiresAt: exdate.toISOString().slice(0, 16),
startsAt: stdate.toISOString().slice(0, 16), startsAt: stdate.toISOString().slice(0, 16),
}; };
@ -239,7 +247,7 @@ function more() {
exdate.setMilliseconds(exdate.getMilliseconds() - localTimeDiff); exdate.setMilliseconds(exdate.getMilliseconds() - localTimeDiff);
stdate.setMilliseconds(stdate.getMilliseconds() - localTimeDiff); stdate.setMilliseconds(stdate.getMilliseconds() - localTimeDiff);
return { return {
...r, ...(r as Ad),
expiresAt: exdate.toISOString().slice(0, 16), expiresAt: exdate.toISOString().slice(0, 16),
startsAt: stdate.toISOString().slice(0, 16), startsAt: stdate.toISOString().slice(0, 16),
}; };
@ -256,7 +264,7 @@ function refresh() {
exdate.setMilliseconds(exdate.getMilliseconds() - localTimeDiff); exdate.setMilliseconds(exdate.getMilliseconds() - localTimeDiff);
stdate.setMilliseconds(stdate.getMilliseconds() - localTimeDiff); stdate.setMilliseconds(stdate.getMilliseconds() - localTimeDiff);
return { return {
...r, ...(r as Ad),
expiresAt: exdate.toISOString().slice(0, 16), expiresAt: exdate.toISOString().slice(0, 16),
startsAt: stdate.toISOString().slice(0, 16), startsAt: stdate.toISOString().slice(0, 16),
}; };

View File

@ -45,18 +45,26 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="announcement.imageUrl" type="url"> <MkInput v-model="announcement.imageUrl" type="url">
<template #label>{{ i18n.ts.imageUrl }}</template> <template #label>{{ i18n.ts.imageUrl }}</template>
</MkInput> </MkInput>
<MkRadios v-model="announcement.icon"> <MkRadios
v-model="announcement.icon"
:options="[
{ value: 'info', icon: 'ti ti-info-circle' },
{ value: 'warning', icon: 'ti ti-alert-triangle', iconStyle: 'color: var(--MI_THEME-warn);' },
{ value: 'error', icon: 'ti ti-circle-x', iconStyle: 'color: var(--MI_THEME-error);' },
{ value: 'success', icon: 'ti ti-check', iconStyle: 'color: var(--MI_THEME-success);' },
]"
>
<template #label>{{ i18n.ts.icon }}</template> <template #label>{{ i18n.ts.icon }}</template>
<option value="info"><i class="ti ti-info-circle"></i></option>
<option value="warning"><i class="ti ti-alert-triangle" style="color: var(--MI_THEME-warn);"></i></option>
<option value="error"><i class="ti ti-circle-x" style="color: var(--MI_THEME-error);"></i></option>
<option value="success"><i class="ti ti-check" style="color: var(--MI_THEME-success);"></i></option>
</MkRadios> </MkRadios>
<MkRadios v-model="announcement.display"> <MkRadios
v-model="announcement.display"
:options="[
{ value: 'normal', label: i18n.ts.normal },
{ value: 'banner', label: i18n.ts.banner },
{ value: 'dialog', label: i18n.ts.dialog },
]"
>
<template #label>{{ i18n.ts.display }}</template> <template #label>{{ i18n.ts.display }}</template>
<option value="normal">{{ i18n.ts.normal }}</option>
<option value="banner">{{ i18n.ts.banner }}</option>
<option value="dialog">{{ i18n.ts.dialog }}</option>
</MkRadios> </MkRadios>
<MkInfo v-if="announcement.display === 'dialog'" warn>{{ i18n.ts._announcement.dialogAnnouncementUxWarn }}</MkInfo> <MkInfo v-if="announcement.display === 'dialog'" warn>{{ i18n.ts._announcement.dialogAnnouncementUxWarn }}</MkInfo>
<MkSwitch v-model="announcement.forExistingUsers" :helpText="i18n.ts._announcement.forExistingUsersDescription"> <MkSwitch v-model="announcement.forExistingUsers" :helpText="i18n.ts._announcement.forExistingUsersDescription">

View File

@ -19,13 +19,17 @@ SPDX-License-Identifier: AGPL-3.0-only
</template> </template>
<div class="_gaps_m"> <div class="_gaps_m">
<MkRadios v-model="botProtectionForm.state.provider"> <MkRadios
<option value="none">{{ i18n.ts.none }} ({{ i18n.ts.notRecommended }})</option> v-model="botProtectionForm.state.provider"
<option value="hcaptcha">hCaptcha</option> :options="[
<option value="mcaptcha">mCaptcha</option> { value: 'none', label: `${i18n.ts.none} (${i18n.ts.notRecommended})` },
<option value="recaptcha">reCAPTCHA</option> { value: 'hcaptcha', label: 'hCaptcha' },
<option value="turnstile">Turnstile</option> { value: 'mcaptcha', label: 'mCaptcha' },
<option value="testcaptcha">testCaptcha</option> { value: 'recaptcha', label: 'reCAPTCHA' },
{ value: 'turnstile', label: 'Turnstile' },
{ value: 'testcaptcha', label: 'testCaptcha' },
]"
>
</MkRadios> </MkRadios>
<template v-if="botProtectionForm.state.provider === 'hcaptcha'"> <template v-if="botProtectionForm.state.provider === 'hcaptcha'">

View File

@ -9,10 +9,14 @@ SPDX-License-Identifier: AGPL-3.0-only
<SearchMarker path="/admin/branding" :label="i18n.ts.branding" :keywords="['branding']" icon="ti ti-paint"> <SearchMarker path="/admin/branding" :label="i18n.ts.branding" :keywords="['branding']" icon="ti ti-paint">
<div class="_gaps_m"> <div class="_gaps_m">
<SearchMarker :keywords="['entrance', 'welcome', 'landing', 'front', 'home', 'page', 'style']"> <SearchMarker :keywords="['entrance', 'welcome', 'landing', 'front', 'home', 'page', 'style']">
<MkRadios v-model="entrancePageStyle"> <MkRadios
:options="[
{ value: 'classic' },
{ value: 'simple' },
]"
v-model="entrancePageStyle"
>
<template #label><SearchLabel>{{ i18n.ts._serverSettings.entrancePageStyle }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts._serverSettings.entrancePageStyle }}</SearchLabel></template>
<option value="classic">Classic</option>
<option value="simple">Simple</option>
</MkRadios> </MkRadios>
</SearchMarker> </SearchMarker>

View File

@ -25,11 +25,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_gaps_m"> <div class="_gaps_m">
<div><SearchText>{{ i18n.ts._sensitiveMediaDetection.description }}</SearchText></div> <div><SearchText>{{ i18n.ts._sensitiveMediaDetection.description }}</SearchText></div>
<MkRadios v-model="sensitiveMediaDetectionForm.state.sensitiveMediaDetection"> <MkRadios
<option value="none">{{ i18n.ts.none }}</option> v-model="sensitiveMediaDetectionForm.state.sensitiveMediaDetection"
<option value="all">{{ i18n.ts.all }}</option> :options="[
<option value="local">{{ i18n.ts.localOnly }}</option> { value: 'none', label: i18n.ts.none },
<option value="remote">{{ i18n.ts.remoteOnly }}</option> { value: 'all', label: i18n.ts.all },
{ value: 'local', label: i18n.ts.localOnly },
{ value: 'remote', label: i18n.ts.remoteOnly },
]"
>
</MkRadios> </MkRadios>
<SearchMarker :keywords="['sensitivity']"> <SearchMarker :keywords="['sensitivity']">

View File

@ -258,11 +258,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_gaps"> <div class="_gaps">
<SearchMarker> <SearchMarker>
<MkRadios v-model="federationForm.state.federation"> <MkRadios
v-model="federationForm.state.federation"
:options="[
{ value: 'all', label: i18n.ts.all },
{ value: 'specified', label: i18n.ts.specifyHost },
{ value: 'none', label: i18n.ts.none },
]"
>
<template #label><SearchLabel>{{ i18n.ts.behavior }}</SearchLabel><span v-if="federationForm.modifiedStates.federation" class="_modified">{{ i18n.ts.modified }}</span></template> <template #label><SearchLabel>{{ i18n.ts.behavior }}</SearchLabel><span v-if="federationForm.modifiedStates.federation" class="_modified">{{ i18n.ts.modified }}</span></template>
<option value="all">{{ i18n.ts.all }}</option>
<option value="specified">{{ i18n.ts.specifyHost }}</option>
<option value="none">{{ i18n.ts.none }}</option>
</MkRadios> </MkRadios>
</SearchMarker> </SearchMarker>

View File

@ -11,9 +11,14 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter="search"> <MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter="search">
<template #prefix><i class="ti ti-search"></i></template> <template #prefix><i class="ti ti-search"></i></template>
</MkInput> </MkInput>
<MkRadios v-model="searchType" @update:modelValue="search()"> <MkRadios
<option value="nameAndDescription">{{ i18n.ts._channel.nameAndDescription }}</option> v-model="searchType"
<option value="nameOnly">{{ i18n.ts._channel.nameOnly }}</option> :options="[
{ value: 'nameAndDescription', label: i18n.ts._channel.nameAndDescription },
{ value: 'nameOnly', label: i18n.ts._channel.nameOnly },
]"
@update:modelValue="search()"
>
</MkRadios> </MkRadios>
<MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton> <MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton>
</div> </div>
@ -72,15 +77,17 @@ import { Paginator } from '@/utility/paginator.js';
const router = useRouter(); const router = useRouter();
type SearchType = 'nameAndDescription' | 'nameOnly';
const props = defineProps<{ const props = defineProps<{
query: string; query: string;
type?: string; type?: SearchType;
}>(); }>();
const key = ref(''); const key = ref('');
const tab = ref('featured'); const tab = ref('featured');
const searchQuery = ref(''); const searchQuery = ref('');
const searchType = ref('nameAndDescription'); const searchType = ref<SearchType>('nameAndDescription');
const channelPaginator = shallowRef(); const channelPaginator = shallowRef();
onMounted(() => { onMounted(() => {

View File

@ -35,7 +35,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkFolder :defaultOpen="true"> <MkFolder :defaultOpen="true">
<template #label>{{ i18n.ts._reversi.blackOrWhite }}</template> <template #label>{{ i18n.ts._reversi.blackOrWhite }}</template>
<MkRadios v-model="game.bw"> <!-- TODO: 移行 -->
<MkRadios2 v-model="game.bw">
<option value="random">{{ i18n.ts.random }}</option> <option value="random">{{ i18n.ts.random }}</option>
<option :value="'1'"> <option :value="'1'">
<I18n :src="i18n.ts._reversi.blackIs" tag="span"> <I18n :src="i18n.ts._reversi.blackIs" tag="span">
@ -51,22 +52,17 @@ SPDX-License-Identifier: AGPL-3.0-only
</template> </template>
</I18n> </I18n>
</option> </option>
</MkRadios> </MkRadios2>
</MkFolder> </MkFolder>
<MkFolder :defaultOpen="true"> <MkFolder :defaultOpen="true">
<template #label>{{ i18n.ts._reversi.timeLimitForEachTurn }}</template> <template #label>{{ i18n.ts._reversi.timeLimitForEachTurn }}</template>
<template #suffix>{{ game.timeLimitForEachTurn }}{{ i18n.ts._time.second }}</template> <template #suffix>{{ game.timeLimitForEachTurn }}{{ i18n.ts._time.second }}</template>
<MkRadios v-model="game.timeLimitForEachTurn"> <MkRadios
<option :value="5">5{{ i18n.ts._time.second }}</option> v-model="game.timeLimitForEachTurn"
<option :value="10">10{{ i18n.ts._time.second }}</option> :options="gameTurnOptionsDef"
<option :value="30">30{{ i18n.ts._time.second }}</option> >
<option :value="60">60{{ i18n.ts._time.second }}</option>
<option :value="90">90{{ i18n.ts._time.second }}</option>
<option :value="120">120{{ i18n.ts._time.second }}</option>
<option :value="180">180{{ i18n.ts._time.second }}</option>
<option :value="3600">3600{{ i18n.ts._time.second }}</option>
</MkRadios> </MkRadios>
</MkFolder> </MkFolder>
@ -117,7 +113,8 @@ import { i18n } from '@/i18n.js';
import { ensureSignin } from '@/i.js'; import { ensureSignin } from '@/i.js';
import { deepClone } from '@/utility/clone.js'; import { deepClone } from '@/utility/clone.js';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import MkRadios from '@/components/MkRadios.vue'; import MkRadios, { type RadioOption } from '@/components/MkRadios.vue';
import MkRadios2 from '@/components/MkRadios2.vue';
import MkSwitch from '@/components/MkSwitch.vue'; import MkSwitch from '@/components/MkSwitch.vue';
import MkFolder from '@/components/MkFolder.vue'; import MkFolder from '@/components/MkFolder.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
@ -139,6 +136,17 @@ const shareWhenStart = defineModel<boolean>('shareWhenStart', { default: false }
const game = ref<Misskey.entities.ReversiGameDetailed>(deepClone(props.game)); const game = ref<Misskey.entities.ReversiGameDetailed>(deepClone(props.game));
const gameTurnOptionsDef = [
{ value: 5, label: '5' + i18n.ts._time.second },
{ value: 10, label: '10' + i18n.ts._time.second },
{ value: 30, label: '30' + i18n.ts._time.second },
{ value: 60, label: '60' + i18n.ts._time.second },
{ value: 90, label: '90' + i18n.ts._time.second },
{ value: 120, label: '120' + i18n.ts._time.second },
{ value: 180, label: '180' + i18n.ts._time.second },
{ value: 3600, label: '3600' + i18n.ts._time.second },
] as RadioOption<number>[];
const mapName = computed(() => { const mapName = computed(() => {
if (game.value.map == null) return 'Random'; if (game.value.map == null) return 'Random';
const found = Object.values(Reversi.maps).find(x => x.data.join('') === game.value.map.join('')); const found = Object.values(Reversi.maps).find(x => x.data.join('') === game.value.map.join(''));

View File

@ -19,11 +19,10 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #header>{{ i18n.ts.options }}</template> <template #header>{{ i18n.ts.options }}</template>
<div class="_gaps_m"> <div class="_gaps_m">
<MkRadios v-model="searchScope"> <MkRadios
<option v-if="instance.federation !== 'none' && noteSearchableScope === 'global'" value="all">{{ i18n.ts._search.searchScopeAll }}</option> v-model="searchScope"
<option value="local">{{ instance.federation === 'none' ? i18n.ts._search.searchScopeAll : i18n.ts._search.searchScopeLocal }}</option> :options="searchScopeDef"
<option v-if="instance.federation !== 'none' && noteSearchableScope === 'global'" value="server">{{ i18n.ts._search.searchScopeServer }}</option> >
<option value="user">{{ i18n.ts._search.searchScopeUser }}</option>
</MkRadios> </MkRadios>
<div v-if="instance.federation !== 'none' && searchScope === 'server'" :class="$style.subOptionRoot"> <div v-if="instance.federation !== 'none' && searchScope === 'server'" :class="$style.subOptionRoot">
@ -128,6 +127,7 @@ import MkNotesTimeline from '@/components/MkNotesTimeline.vue';
import MkRadios from '@/components/MkRadios.vue'; import MkRadios from '@/components/MkRadios.vue';
import MkUserCardMini from '@/components/MkUserCardMini.vue'; import MkUserCardMini from '@/components/MkUserCardMini.vue';
import { Paginator } from '@/utility/paginator.js'; import { Paginator } from '@/utility/paginator.js';
import type { RadioOption } from '@/components/MkRadios.vue';
const props = withDefaults(defineProps<{ const props = withDefaults(defineProps<{
query?: string; query?: string;
@ -184,6 +184,24 @@ const searchScope = ref<'all' | 'local' | 'server' | 'user'>((() => {
return 'all'; return 'all';
})()); })());
const searchScopeDef = computed<RadioOption[]>(() => {
const options: RadioOption[] = [];
if (instance.federation !== 'none' && noteSearchableScope === 'global') {
options.push({ value: 'all', label: i18n.ts._search.searchScopeAll });
}
options.push({ value: 'local', label: instance.federation === 'none' ? i18n.ts._search.searchScopeAll : i18n.ts._search.searchScopeLocal });
if (instance.federation !== 'none' && noteSearchableScope === 'global') {
options.push({ value: 'server', label: i18n.ts._search.searchScopeServer });
}
options.push({ value: 'user', label: i18n.ts._search.searchScopeUser });
return options;
});
type SearchParams = { type SearchParams = {
readonly query: string; readonly query: string;
readonly host?: string; readonly host?: string;

View File

@ -9,10 +9,16 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter.prevent="search"> <MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter.prevent="search">
<template #prefix><i class="ti ti-search"></i></template> <template #prefix><i class="ti ti-search"></i></template>
</MkInput> </MkInput>
<MkRadios v-if="instance.federation !== 'none'" v-model="searchOrigin" @update:modelValue="search()"> <MkRadios
<option value="combined">{{ i18n.ts.all }}</option> v-if="instance.federation !== 'none'"
<option value="local">{{ i18n.ts.local }}</option> v-model="searchOrigin"
<option value="remote">{{ i18n.ts.remote }}</option> :options="[
{ value: 'combined', label: i18n.ts.all },
{ value: 'local', label: i18n.ts.local },
{ value: 'remote', label: i18n.ts.remote },
]"
@update:modelValue="search()"
>
</MkRadios> </MkRadios>
<MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton> <MkButton large primary gradate rounded @click="search">{{ i18n.ts.search }}</MkButton>
</div> </div>

View File

@ -40,31 +40,43 @@ SPDX-License-Identifier: AGPL-3.0-only
<SearchMarker :keywords="['column', 'align']"> <SearchMarker :keywords="['column', 'align']">
<MkPreferenceContainer k="deck.columnAlign"> <MkPreferenceContainer k="deck.columnAlign">
<MkRadios v-model="columnAlign"> <MkRadios
v-model="columnAlign"
:options="[
{ value: 'left', label: i18n.ts.left },
{ value: 'center', label: i18n.ts.center },
]"
>
<template #label><SearchLabel>{{ i18n.ts._deck.columnAlign }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts._deck.columnAlign }}</SearchLabel></template>
<option value="left">{{ i18n.ts.left }}</option>
<option value="center">{{ i18n.ts.center }}</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['menu', 'position']"> <SearchMarker :keywords="['menu', 'position']">
<MkPreferenceContainer k="deck.menuPosition"> <MkPreferenceContainer k="deck.menuPosition">
<MkRadios v-model="menuPosition"> <MkRadios
v-model="menuPosition"
:options="[
{ value: 'right', label: i18n.ts.right },
{ value: 'bottom', label: i18n.ts.bottom },
]"
>
<template #label><SearchLabel>{{ i18n.ts._deck.deckMenuPosition }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts._deck.deckMenuPosition }}</SearchLabel></template>
<option value="right">{{ i18n.ts.right }}</option>
<option value="bottom">{{ i18n.ts.bottom }}</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['navbar', 'position']"> <SearchMarker :keywords="['navbar', 'position']">
<MkPreferenceContainer k="deck.navbarPosition"> <MkPreferenceContainer k="deck.navbarPosition">
<MkRadios v-model="navbarPosition"> <MkRadios
v-model="navbarPosition"
:options="[
{ value: 'left', label: i18n.ts.left },
{ value: 'top', label: i18n.ts.top },
{ value: 'bottom', label: i18n.ts.bottom },
]"
>
<template #label><SearchLabel>{{ i18n.ts._deck.navbarPosition }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts._deck.navbarPosition }}</SearchLabel></template>
<option value="left">{{ i18n.ts.left }}</option>
<option value="top">{{ i18n.ts.top }}</option>
<option value="bottom">{{ i18n.ts.bottom }}</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
@ -99,6 +111,7 @@ import { prefer } from '@/preferences.js';
import MkPreferenceContainer from '@/components/MkPreferenceContainer.vue'; import MkPreferenceContainer from '@/components/MkPreferenceContainer.vue';
import { selectFile } from '@/utility/drive.js'; import { selectFile } from '@/utility/drive.js';
import { suggestReload } from '@/utility/reload-suggest.js'; import { suggestReload } from '@/utility/reload-suggest.js';
import { options } from 'sanitize-html';
const navWindow = prefer.model('deck.navWindow'); const navWindow = prefer.model('deck.navWindow');
const useSimpleUiForNonRootPages = prefer.model('deck.useSimpleUiForNonRootPages'); const useSimpleUiForNonRootPages = prefer.model('deck.useSimpleUiForNonRootPages');

View File

@ -59,38 +59,33 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="_gaps_m"> <div class="_gaps_m">
<SearchMarker :keywords="['emoji', 'picker', 'scale', 'size']"> <SearchMarker :keywords="['emoji', 'picker', 'scale', 'size']">
<MkPreferenceContainer k="emojiPickerScale"> <MkPreferenceContainer k="emojiPickerScale">
<MkRadios v-model="emojiPickerScale"> <MkRadios
v-model="emojiPickerScale"
:options="emojiPickerScaleDef"
>
<template #label><SearchLabel>{{ i18n.ts.size }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.size }}</SearchLabel></template>
<option :value="1">{{ i18n.ts.small }}</option>
<option :value="2">{{ i18n.ts.medium }}</option>
<option :value="3">{{ i18n.ts.large }}</option>
<option :value="4">{{ i18n.ts.large }}+</option>
<option :value="5">{{ i18n.ts.large }}++</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['emoji', 'picker', 'width', 'column', 'size']"> <SearchMarker :keywords="['emoji', 'picker', 'width', 'column', 'size']">
<MkPreferenceContainer k="emojiPickerWidth"> <MkPreferenceContainer k="emojiPickerWidth">
<MkRadios v-model="emojiPickerWidth"> <MkRadios
v-model="emojiPickerWidth"
:options="emojiPickerWidthDef"
>
<template #label><SearchLabel>{{ i18n.ts.numberOfColumn }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.numberOfColumn }}</SearchLabel></template>
<option :value="1">5</option>
<option :value="2">6</option>
<option :value="3">7</option>
<option :value="4">8</option>
<option :value="5">9</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['emoji', 'picker', 'height', 'size']"> <SearchMarker :keywords="['emoji', 'picker', 'height', 'size']">
<MkPreferenceContainer k="emojiPickerHeight"> <MkPreferenceContainer k="emojiPickerHeight">
<MkRadios v-model="emojiPickerHeight"> <MkRadios
v-model="emojiPickerHeight"
:options="emojiPickerHeightDef"
>
<template #label><SearchLabel>{{ i18n.ts.height }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.height }}</SearchLabel></template>
<option :value="1">{{ i18n.ts.small }}</option>
<option :value="2">{{ i18n.ts.medium }}</option>
<option :value="3">{{ i18n.ts.large }}</option>
<option :value="4">{{ i18n.ts.large }}+</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
@ -123,7 +118,7 @@ import { computed, ref, watch } from 'vue';
import XPalette from './emoji-palette.palette.vue'; import XPalette from './emoji-palette.palette.vue';
import type { MkSelectItem } from '@/components/MkSelect.vue'; import type { MkSelectItem } from '@/components/MkSelect.vue';
import { genId } from '@/utility/id.js'; import { genId } from '@/utility/id.js';
import MkRadios from '@/components/MkRadios.vue'; import MkRadios, { type RadioOption } from '@/components/MkRadios.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import FormSection from '@/components/form/section.vue'; import FormSection from '@/components/form/section.vue';
import MkSelect from '@/components/MkSelect.vue'; import MkSelect from '@/components/MkSelect.vue';
@ -153,8 +148,31 @@ const emojiPaletteForMainDef = computed<MkSelectItem[]>(() => [
})), })),
]); ]);
const emojiPickerScale = prefer.model('emojiPickerScale'); const emojiPickerScale = prefer.model('emojiPickerScale');
const emojiPickerScaleDef = [
{ label: i18n.ts.small, value: 1 },
{ label: i18n.ts.medium, value: 2 },
{ label: i18n.ts.large, value: 3 },
{ label: i18n.ts.large + '+', value: 4 },
{ label: i18n.ts.large + '++', value: 5 },
] as RadioOption<number>[];
const emojiPickerWidth = prefer.model('emojiPickerWidth'); const emojiPickerWidth = prefer.model('emojiPickerWidth');
const emojiPickerWidthDef = [
{ label: '5', value: 1 },
{ label: '6', value: 2 },
{ label: '7', value: 3 },
{ label: '8', value: 4 },
{ label: '9', value: 5 },
] as RadioOption<number>[];
const emojiPickerHeight = prefer.model('emojiPickerHeight'); const emojiPickerHeight = prefer.model('emojiPickerHeight');
const emojiPickerHeightDef = [
{ label: i18n.ts.small, value: 1 },
{ label: i18n.ts.medium, value: 2 },
{ label: i18n.ts.large, value: 3 },
{ label: i18n.ts.large + '+', value: 4 },
] as RadioOption<number>[];
const emojiPickerStyle = prefer.model('emojiPickerStyle'); const emojiPickerStyle = prefer.model('emojiPickerStyle');
const palettesSyncEnabled = ref(prefer.isSyncEnabled('emojiPalettes')); const palettesSyncEnabled = ref(prefer.isSyncEnabled('emojiPalettes'));

View File

@ -36,10 +36,14 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkButton primary class="save" @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton> <MkButton primary class="save" @click="save"><i class="ti ti-device-floppy"></i> {{ i18n.ts.save }}</MkButton>
</div> </div>
<MkRadios v-model="menuDisplay"> <MkRadios
v-model="menuDisplay"
:options="[
{ value: 'sideFull', label: i18n.ts._menuDisplay.sideFull },
{ value: 'sideIcon', label: i18n.ts._menuDisplay.sideIcon },
]"
>
<template #label>{{ i18n.ts.display }}</template> <template #label>{{ i18n.ts.display }}</template>
<option value="sideFull">{{ i18n.ts._menuDisplay.sideFull }}</option>
<option value="sideIcon">{{ i18n.ts._menuDisplay.sideIcon }}</option>
</MkRadios> </MkRadios>
<SearchMarker :keywords="['navbar', 'sidebar', 'toggle', 'button', 'sub']"> <SearchMarker :keywords="['navbar', 'sidebar', 'toggle', 'button', 'sub']">

View File

@ -31,12 +31,16 @@ SPDX-License-Identifier: AGPL-3.0-only
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['device', 'type', 'kind', 'smartphone', 'tablet', 'desktop']"> <SearchMarker :keywords="['device', 'type', 'kind', 'smartphone', 'tablet', 'desktop']">
<MkRadios v-model="overridedDeviceKind"> <MkRadios
v-model="overridedDeviceKind"
:options="[
{ value: null, label: i18n.ts.auto },
{ value: 'smartphone', label: i18n.ts.smartphone, icon: 'ti ti-device-mobile' },
{ value: 'tablet', label: i18n.ts.tablet, icon: 'ti ti-device-tablet' },
{ value: 'desktop', label: i18n.ts.desktop, icon: 'ti ti-device-desktop' },
]"
>
<template #label><SearchLabel>{{ i18n.ts.overridedDeviceKind }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.overridedDeviceKind }}</SearchLabel></template>
<option :value="null">{{ i18n.ts.auto }}</option>
<option value="smartphone"><i class="ti ti-device-mobile"/> {{ i18n.ts.smartphone }}</option>
<option value="tablet"><i class="ti ti-device-tablet"/> {{ i18n.ts.tablet }}</option>
<option value="desktop"><i class="ti ti-device-desktop"/> {{ i18n.ts.desktop }}</option>
</MkRadios> </MkRadios>
</SearchMarker> </SearchMarker>
@ -121,11 +125,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<SearchMarker :keywords="['emoji', 'style', 'native', 'system', 'fluent', 'twemoji']"> <SearchMarker :keywords="['emoji', 'style', 'native', 'system', 'fluent', 'twemoji']">
<MkPreferenceContainer k="emojiStyle"> <MkPreferenceContainer k="emojiStyle">
<div> <div>
<MkRadios v-model="emojiStyle"> <MkRadios
v-model="emojiStyle"
:options="[
{ value: 'native', label: i18n.ts.native },
{ value: 'fluentEmoji', label: 'Fluent Emoji' },
{ value: 'twemoji', label: 'Twemoji' },
]"
>
<template #label><SearchLabel>{{ i18n.ts.emojiStyle }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.emojiStyle }}</SearchLabel></template>
<option value="native">{{ i18n.ts.native }}</option>
<option value="fluentEmoji">Fluent Emoji</option>
<option value="twemoji">Twemoji</option>
</MkRadios> </MkRadios>
<div style="margin: 8px 0 0 0; font-size: 1.5em;"><Mfm :key="emojiStyle" text="🍮🍦🍭🍩🍰🍫🍬🥞🍪"/></div> <div style="margin: 8px 0 0 0; font-size: 1.5em;"><Mfm :key="emojiStyle" text="🍮🍦🍭🍩🍰🍫🍬🥞🍪"/></div>
</div> </div>
@ -240,11 +248,15 @@ SPDX-License-Identifier: AGPL-3.0-only
<SearchMarker :keywords="['reaction', 'size', 'scale', 'display']"> <SearchMarker :keywords="['reaction', 'size', 'scale', 'display']">
<MkPreferenceContainer k="reactionsDisplaySize"> <MkPreferenceContainer k="reactionsDisplaySize">
<MkRadios v-model="reactionsDisplaySize"> <MkRadios
v-model="reactionsDisplaySize"
:options="[
{ value: 'small', label: i18n.ts.small },
{ value: 'medium', label: i18n.ts.medium },
{ value: 'large', label: i18n.ts.large },
]"
>
<template #label><SearchLabel>{{ i18n.ts.reactionsDisplaySize }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.reactionsDisplaySize }}</SearchLabel></template>
<option value="small">{{ i18n.ts.small }}</option>
<option value="medium">{{ i18n.ts.medium }}</option>
<option value="large">{{ i18n.ts.large }}</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
@ -259,12 +271,16 @@ SPDX-License-Identifier: AGPL-3.0-only
<SearchMarker :keywords="['attachment', 'image', 'photo', 'picture', 'media', 'thumbnail', 'list', 'size', 'height']"> <SearchMarker :keywords="['attachment', 'image', 'photo', 'picture', 'media', 'thumbnail', 'list', 'size', 'height']">
<MkPreferenceContainer k="mediaListWithOneImageAppearance"> <MkPreferenceContainer k="mediaListWithOneImageAppearance">
<MkRadios v-model="mediaListWithOneImageAppearance"> <MkRadios
v-model="mediaListWithOneImageAppearance"
:options="[
{ value: 'expand', label: i18n.ts.default },
{ value: '16_9', label: i18n.tsx.limitTo({ x: '16:9' }) },
{ value: '1_1', label: i18n.tsx.limitTo({ x: '1:1' }) },
{ value: '2_3', label: i18n.tsx.limitTo({ x: '2:3' }) },
]"
>
<template #label><SearchLabel>{{ i18n.ts.mediaListWithOneImageAppearance }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.mediaListWithOneImageAppearance }}</SearchLabel></template>
<option value="expand">{{ i18n.ts.default }}</option>
<option value="16_9">{{ i18n.tsx.limitTo({ x: '16:9' }) }}</option>
<option value="1_1">{{ i18n.tsx.limitTo({ x: '1:1' }) }}</option>
<option value="2_3">{{ i18n.tsx.limitTo({ x: '2:3' }) }}</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
@ -386,22 +402,30 @@ SPDX-License-Identifier: AGPL-3.0-only
<SearchMarker :keywords="['position']"> <SearchMarker :keywords="['position']">
<MkPreferenceContainer k="notificationPosition"> <MkPreferenceContainer k="notificationPosition">
<MkRadios v-model="notificationPosition"> <MkRadios
v-model="notificationPosition"
:options="[
{ value: 'leftTop', label: i18n.ts.leftTop, icon: 'ti ti-align-box-left-top' },
{ value: 'rightTop', label: i18n.ts.rightTop, icon: 'ti ti-align-box-right-top' },
{ value: 'leftBottom', label: i18n.ts.leftBottom, icon: 'ti ti-align-box-left-bottom' },
{ value: 'rightBottom', label: i18n.ts.rightBottom, icon: 'ti ti-align-box-right-bottom' },
]"
>
<template #label><SearchLabel>{{ i18n.ts.position }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.position }}</SearchLabel></template>
<option value="leftTop"><i class="ti ti-align-box-left-top"></i> {{ i18n.ts.leftTop }}</option>
<option value="rightTop"><i class="ti ti-align-box-right-top"></i> {{ i18n.ts.rightTop }}</option>
<option value="leftBottom"><i class="ti ti-align-box-left-bottom"></i> {{ i18n.ts.leftBottom }}</option>
<option value="rightBottom"><i class="ti ti-align-box-right-bottom"></i> {{ i18n.ts.rightBottom }}</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['stack', 'axis', 'direction']"> <SearchMarker :keywords="['stack', 'axis', 'direction']">
<MkPreferenceContainer k="notificationStackAxis"> <MkPreferenceContainer k="notificationStackAxis">
<MkRadios v-model="notificationStackAxis"> <MkRadios
v-model="notificationStackAxis"
:options="[
{ value: 'vertical', label: i18n.ts.vertical, icon: 'ti ti-carousel-vertical' },
{ value: 'horizontal', label: i18n.ts.horizontal, icon: 'ti ti-carousel-horizontal' },
]"
>
<template #label><SearchLabel>{{ i18n.ts.stackAxis }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.stackAxis }}</SearchLabel></template>
<option value="vertical"><i class="ti ti-carousel-vertical"></i> {{ i18n.ts.vertical }}</option>
<option value="horizontal"><i class="ti ti-carousel-horizontal"></i> {{ i18n.ts.horizontal }}</option>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
</SearchMarker> </SearchMarker>
@ -569,12 +593,16 @@ SPDX-License-Identifier: AGPL-3.0-only
</SearchMarker> </SearchMarker>
<SearchMarker :keywords="['font', 'size']"> <SearchMarker :keywords="['font', 'size']">
<MkRadios v-model="fontSize"> <MkRadios
v-model="fontSize"
:options="[
{ value: null, label: 'Aa', labelStyle: 'font-size: 14px;' },
{ value: '1', label: 'Aa', labelStyle: 'font-size: 15px;' },
{ value: '2', label: 'Aa', labelStyle: 'font-size: 16px;' },
{ value: '3', label: 'Aa', labelStyle: 'font-size: 17px;' },
]"
>
<template #label><SearchLabel>{{ i18n.ts.fontSize }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.fontSize }}</SearchLabel></template>
<option :value="null"><span style="font-size: 14px;">Aa</span></option>
<option value="1"><span style="font-size: 15px;">Aa</span></option>
<option value="2"><span style="font-size: 16px;">Aa</span></option>
<option value="3"><span style="font-size: 17px;">Aa</span></option>
</MkRadios> </MkRadios>
</SearchMarker> </SearchMarker>
@ -771,10 +799,14 @@ SPDX-License-Identifier: AGPL-3.0-only
<SearchMarker> <SearchMarker>
<MkPreferenceContainer k="hemisphere"> <MkPreferenceContainer k="hemisphere">
<MkRadios v-model="hemisphere"> <MkRadios
v-model="hemisphere"
:options="[
{ value: 'N', label: i18n.ts._hemisphere.N },
{ value: 'S', label: i18n.ts._hemisphere.S },
]"
>
<template #label><SearchLabel>{{ i18n.ts.hemisphere }}</SearchLabel></template> <template #label><SearchLabel>{{ i18n.ts.hemisphere }}</SearchLabel></template>
<option value="N">{{ i18n.ts._hemisphere.N }}</option>
<option value="S">{{ i18n.ts._hemisphere.S }}</option>
<template #caption>{{ i18n.ts._hemisphere.caption }}</template> <template #caption>{{ i18n.ts._hemisphere.caption }}</template>
</MkRadios> </MkRadios>
</MkPreferenceContainer> </MkPreferenceContainer>
@ -903,7 +935,7 @@ const contextMenu = prefer.model('contextMenu');
const menuStyle = prefer.model('menuStyle'); const menuStyle = prefer.model('menuStyle');
const makeEveryTextElementsSelectable = prefer.model('makeEveryTextElementsSelectable'); const makeEveryTextElementsSelectable = prefer.model('makeEveryTextElementsSelectable');
const fontSize = ref(miLocalStorage.getItem('fontSize')); const fontSize = ref(miLocalStorage.getItem('fontSize') as '1' | '2' | '3' | null);
const useSystemFont = ref(miLocalStorage.getItem('useSystemFont') != null); const useSystemFont = ref(miLocalStorage.getItem('useSystemFont') != null);
watch(lang, () => { watch(lang, () => {

View File

@ -17,13 +17,17 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #label>Black</template> <template #label>Black</template>
</MkSwitch> </MkSwitch>
<MkRadios v-model="statusbar.size"> <MkRadios
v-model="statusbar.size"
:options="[
{ value: 'verySmall', label: i18n.ts.small + '+' },
{ value: 'small', label: i18n.ts.small },
{ value: 'medium', label: i18n.ts.medium },
{ value: 'large', label: i18n.ts.large },
{ value: 'veryLarge', label: i18n.ts.large + '+' },
]"
>
<template #label>{{ i18n.ts.size }}</template> <template #label>{{ i18n.ts.size }}</template>
<option value="verySmall">{{ i18n.ts.small }}+</option>
<option value="small">{{ i18n.ts.small }}</option>
<option value="medium">{{ i18n.ts.medium }}</option>
<option value="large">{{ i18n.ts.large }}</option>
<option value="veryLarge">{{ i18n.ts.large }}+</option>
</MkRadios> </MkRadios>
<template v-if="statusbar.type === 'rss'"> <template v-if="statusbar.type === 'rss'">

View File

@ -235,7 +235,7 @@ export const PREF_DEF = definePreferences({
default: window.matchMedia('(prefers-reduced-motion)').matches, default: window.matchMedia('(prefers-reduced-motion)').matches,
}, },
emojiStyle: { emojiStyle: {
default: 'twemoji', // twemoji / fluentEmoji / native default: 'twemoji' as 'native' | 'fluentEmoji' | 'twemoji',
}, },
menuStyle: { menuStyle: {
default: 'auto' as 'auto' | 'popup' | 'drawer', default: 'auto' as 'auto' | 'popup' | 'drawer',
@ -478,7 +478,7 @@ export const PREF_DEF = definePreferences({
default: true, default: true,
}, },
'deck.columnAlign': { 'deck.columnAlign': {
default: 'center' as 'left' | 'right' | 'center', default: 'center' as 'left' | 'center',
}, },
'deck.columnGap': { 'deck.columnGap': {
default: 6, default: 6,

View File

@ -82,7 +82,7 @@ export const store = markRaw(new Pizzax('base', {
}, },
menuDisplay: { menuDisplay: {
where: 'device', where: 'device',
default: 'sideFull' as 'sideFull' | 'sideIcon' | 'top', default: 'sideFull' as 'sideFull' | 'sideIcon'/* | 'top' */,
}, },
postFormWithHashtags: { postFormWithHashtags: {
where: 'device', where: 'device',

View File

@ -0,0 +1 @@
export type OptionValue = string | number | null;

View File

@ -4,7 +4,7 @@
*/ */
import * as Misskey from 'misskey-js'; import * as Misskey from 'misskey-js';
import type { OptionValue } from '@/components/MkSelect.vue'; import type { OptionValue } from '@/types/option-value.js';
export type EnumItem = string | { export type EnumItem = string | {
label: string; label: string;
@ -43,18 +43,18 @@ export interface BooleanFormItem extends FormItemBase {
export interface EnumFormItem extends FormItemBase { export interface EnumFormItem extends FormItemBase {
type: 'enum'; type: 'enum';
default?: string | null; default?: OptionValue | null;
required?: boolean; required?: boolean;
enum: EnumItem[]; enum: EnumItem[];
} }
export interface RadioFormItem extends FormItemBase { export interface RadioFormItem extends FormItemBase {
type: 'radio'; type: 'radio';
default?: unknown | null; default?: OptionValue | null;
required?: boolean; required?: boolean;
options: { options: {
label: string; label: string;
value: unknown; value: OptionValue;
}[]; }[];
} }