mirror of
https://github.com/misskey-dev/misskey.git
synced 2026-05-05 00:45:50 +02:00
refactor(frontend): フロントエンドの型エラー解消(途中まで) (#16539)
* fix(frontend): FormLinkをボタンとして使用した際にエラーが出る問題を修正 * refactor(frontend): フロントエンドの型エラー解消 * remove unused ts-expect-error * migrate * remove unrelated changes * fix lint * more type fixes
This commit is contained in:
@@ -29,6 +29,6 @@ const users = ref<Misskey.entities.UserLite[]>([]);
|
||||
onMounted(async () => {
|
||||
users.value = await misskeyApi('users/show', {
|
||||
userIds: props.userIds,
|
||||
}) as unknown as Misskey.entities.UserLite[];
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -823,17 +823,15 @@ async function saveServerDraft(clearLocal = false) {
|
||||
return await os.apiWithDialog(serverDraftId.value == null ? 'notes/drafts/create' : 'notes/drafts/update', {
|
||||
...(serverDraftId.value == null ? {} : { draftId: serverDraftId.value }),
|
||||
text: text.value,
|
||||
useCw: useCw.value,
|
||||
cw: cw.value,
|
||||
cw: useCw.value ? cw.value || null : null,
|
||||
visibility: visibility.value,
|
||||
localOnly: localOnly.value,
|
||||
hashtag: hashtags.value,
|
||||
...(files.value.length > 0 ? { fileIds: files.value.map(f => f.id) } : {}),
|
||||
poll: poll.value,
|
||||
...(visibleUsers.value.length > 0 ? { visibleUserIds: visibleUsers.value.map(x => x.id) } : {}),
|
||||
renoteId: renoteTargetNote.value ? renoteTargetNote.value.id : undefined,
|
||||
renoteId: renoteTargetNote.value ? renoteTargetNote.value.id : quoteId.value ? quoteId.value : undefined,
|
||||
replyId: replyTargetNote.value ? replyTargetNote.value.id : undefined,
|
||||
quoteId: quoteId.value,
|
||||
channelId: targetChannel.value ? targetChannel.value.id : undefined,
|
||||
reactionAcceptance: reactionAcceptance.value,
|
||||
}).then(() => {
|
||||
|
||||
@@ -90,7 +90,7 @@ function subscribe() {
|
||||
publickey: encode(subscription.getKey('p256dh')),
|
||||
});
|
||||
}, async err => { // When subscribe failed
|
||||
// 通知が許可されていなかったとき
|
||||
// 通知が許可されていなかったとき
|
||||
if (err?.name === 'NotAllowedError') {
|
||||
console.info('User denied the notification permission request.');
|
||||
return;
|
||||
@@ -114,14 +114,13 @@ async function unsubscribe() {
|
||||
|
||||
if ($i && accounts.length >= 2) {
|
||||
apiWithDialog('sw/unregister', {
|
||||
i: $i.token,
|
||||
endpoint,
|
||||
});
|
||||
}, $i.token);
|
||||
} else {
|
||||
pushSubscription.value.unsubscribe();
|
||||
apiWithDialog('sw/unregister', {
|
||||
endpoint,
|
||||
});
|
||||
}, null);
|
||||
pushSubscription.value = null;
|
||||
}
|
||||
}
|
||||
@@ -134,7 +133,7 @@ function encode(buffer: ArrayBuffer | null) {
|
||||
* Convert the URL safe base64 string to a Uint8Array
|
||||
* @param base64String base64 string
|
||||
*/
|
||||
function urlBase64ToUint8Array(base64String: string): Uint8Array {
|
||||
function urlBase64ToUint8Array(base64String: string): BufferSource {
|
||||
const padding = '='.repeat((4 - base64String.length % 4) % 4);
|
||||
const base64 = (base64String + padding)
|
||||
.replace(/-/g, '+')
|
||||
|
||||
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<template>
|
||||
<MkA :to="forModeration ? `/admin/roles/${role.id}` : `/roles/${role.id}`" :class="$style.root" tabindex="-1" :style="{ '--color': role.color }">
|
||||
<template v-if="forModeration">
|
||||
<i v-if="role.isPublic" class="ti ti-world" :class="$style.icon" style="color: var(--MI_THEME-success)"></i>
|
||||
<i v-if="'isPublic' in role && role.isPublic" class="ti ti-world" :class="$style.icon" style="color: var(--MI_THEME-success)"></i>
|
||||
<i v-else class="ti ti-lock" :class="$style.icon" style="color: var(--MI_THEME-warn)"></i>
|
||||
</template>
|
||||
|
||||
@@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
</template>
|
||||
</span>
|
||||
<span :class="$style.bodyName">{{ role.name }}</span>
|
||||
<template v-if="detailed">
|
||||
<template v-if="detailed && 'target' in role && 'usersCount' in role">
|
||||
<span v-if="role.target === 'manual'" :class="$style.bodyUsers">{{ role.usersCount }} users</span>
|
||||
<span v-else-if="role.target === 'conditional'" :class="$style.bodyUsers">? users</span>
|
||||
</template>
|
||||
@@ -39,7 +39,7 @@ import * as Misskey from 'misskey-js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
role: Misskey.entities.Role;
|
||||
role: Misskey.entities.Role | Misskey.entities.IResponse['roles'][number];
|
||||
forModeration: boolean;
|
||||
detailed?: boolean;
|
||||
}>(), {
|
||||
|
||||
@@ -72,7 +72,7 @@ import { getStaticImageUrl } from '@/utility/media-proxy.js';
|
||||
|
||||
const props = defineProps<{
|
||||
showing: boolean;
|
||||
q: string;
|
||||
q: string | Misskey.entities.UserDetailed;
|
||||
source: HTMLElement;
|
||||
}>();
|
||||
|
||||
@@ -99,10 +99,11 @@ async function fetchUser() {
|
||||
user.value = props.q;
|
||||
error.value = false;
|
||||
} else {
|
||||
const query: Omit<Misskey.entities.UsersShowRequest, 'userIds'> = props.q.startsWith('@') ?
|
||||
const query: Misskey.entities.UsersShowRequest = props.q.startsWith('@') ?
|
||||
Misskey.acct.parse(props.q.substring(1)) :
|
||||
{ userId: props.q };
|
||||
|
||||
// @ts-expect-error payloadの引数側の型が正常に解決されない
|
||||
misskeyApi('users/show', query).then(res => {
|
||||
if (!props.showing) return;
|
||||
user.value = res;
|
||||
|
||||
@@ -4,31 +4,39 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div :class="[$style.root, { [$style.inline]: inline }]">
|
||||
<a v-if="external" :class="$style.main" class="_button" :href="to" target="_blank">
|
||||
<component
|
||||
:is="to ? 'div' : 'button'"
|
||||
:class="[
|
||||
$style.root,
|
||||
{
|
||||
[$style.inline]: inline,
|
||||
'_button': !to,
|
||||
},
|
||||
]"
|
||||
>
|
||||
<component
|
||||
:is="to ? (external ? 'a' : 'MkA') : 'div'"
|
||||
:class="[$style.main, { [$style.active]: active }]"
|
||||
class="_button"
|
||||
v-bind="to ? (external ? { href: to, target: '_blank' } : { to, behavior }) : {}"
|
||||
>
|
||||
<span :class="$style.icon"><slot name="icon"></slot></span>
|
||||
<span :class="$style.text"><slot></slot></span>
|
||||
<div :class="$style.headerText">
|
||||
<div>
|
||||
<MkCondensedLine :minScale="2 / 3"><slot></slot></MkCondensedLine>
|
||||
</div>
|
||||
</div>
|
||||
<span :class="$style.suffix">
|
||||
<span :class="$style.suffixText"><slot name="suffix"></slot></span>
|
||||
<i class="ti ti-external-link"></i>
|
||||
<i :class="to && external ? 'ti ti-external-link' : 'ti ti-chevron-right'"></i>
|
||||
</span>
|
||||
</a>
|
||||
<MkA v-else :class="[$style.main, { [$style.active]: active }]" class="_button" :to="to" :behavior="behavior">
|
||||
<span :class="$style.icon"><slot name="icon"></slot></span>
|
||||
<span :class="$style.text"><slot></slot></span>
|
||||
<span :class="$style.suffix">
|
||||
<span :class="$style.suffixText"><slot name="suffix"></slot></span>
|
||||
<i class="ti ti-chevron-right"></i>
|
||||
</span>
|
||||
</MkA>
|
||||
</div>
|
||||
</component>
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
to: string;
|
||||
defineProps<{
|
||||
to?: string;
|
||||
active?: boolean;
|
||||
external?: boolean;
|
||||
behavior?: null | 'window' | 'browser';
|
||||
@@ -75,17 +83,18 @@ const props = defineProps<{
|
||||
&:empty {
|
||||
display: none;
|
||||
|
||||
& + .text {
|
||||
& + .headerText {
|
||||
padding-left: 4px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.text {
|
||||
flex-shrink: 1;
|
||||
white-space: normal;
|
||||
.headerText {
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
text-align: start;
|
||||
overflow: hidden;
|
||||
padding-right: 12px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.suffix {
|
||||
|
||||
@@ -11,7 +11,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||
<MkPageHeader v-else v-model:tab="tab" v-bind="pageHeaderProps"/>
|
||||
</template>
|
||||
<div :class="$style.body">
|
||||
<MkSwiper v-if="prefer.s.enableHorizontalSwipe && swipable && (props.tabs?.length ?? 1) > 1" v-model:tab="tab" :class="$style.swiper" :tabs="props.tabs">
|
||||
<MkSwiper v-if="prefer.s.enableHorizontalSwipe && swipable && (props.tabs?.length ?? 1) > 1" v-model:tab="tab" :class="$style.swiper" :tabs="props.tabs ?? []">
|
||||
<slot></slot>
|
||||
</MkSwiper>
|
||||
<slot v-else></slot>
|
||||
@@ -45,7 +45,7 @@ const props = withDefaults(defineProps<PageHeaderProps & {
|
||||
});
|
||||
|
||||
const pageHeaderProps = computed(() => {
|
||||
const { reversed, ...rest } = props;
|
||||
const { reversed, tab, ...rest } = props;
|
||||
return rest;
|
||||
});
|
||||
|
||||
@@ -75,10 +75,6 @@ defineExpose({
|
||||
</script>
|
||||
|
||||
<style lang="scss" module>
|
||||
.root {
|
||||
|
||||
}
|
||||
|
||||
.body, .swiper {
|
||||
min-height: calc(100cqh - (var(--MI-stickyTop, 0px) + var(--MI-stickyBottom, 0px)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user