enhance(frontend): 非同期的なコンポーネントの読み込み時のハンドリングを強化

This commit is contained in:
syuilo
2025-06-01 10:44:45 +09:00
parent 63db879bcc
commit f4167ae7f1
33 changed files with 120 additions and 72 deletions

View File

@@ -477,16 +477,16 @@ function toggleRoleItem(role) {
}
}
function createAnnouncement() {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkUserAnnouncementEditDialog.vue')), {
async function createAnnouncement() {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkUserAnnouncementEditDialog.vue').then(x => x.default), {
user: user.value,
}, {
closed: () => dispose(),
});
}
function editAnnouncement(announcement) {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkUserAnnouncementEditDialog.vue')), {
async function editAnnouncement(announcement) {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkUserAnnouncementEditDialog.vue').then(x => x.default), {
user: user.value,
announcement,
}, {

View File

@@ -525,10 +525,10 @@ const headerPageMetadata = computed(() => ({
const headerActions = computed(() => [{
icon: 'ti ti-search',
text: i18n.ts.search,
handler: () => {
handler: async () => {
if (searchWindowOpening) return;
searchWindowOpening = true;
const { dispose } = os.popup(defineAsyncComponent(() => import('./custom-emojis-manager.local.list.search.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('./custom-emojis-manager.local.list.search.vue').then(x => x.default), {
query: searchQuery.value,
}, {
queryUpdated: (query: EmojiSearchQuery) => {
@@ -584,8 +584,8 @@ const headerActions = computed(() => [{
}, {
icon: 'ti ti-notes',
text: i18n.ts._customEmojisManager._gridCommon.registrationLogs,
handler: () => {
const { dispose } = os.popup(defineAsyncComponent(() => import('./custom-emojis-manager.local.list.logs.vue')), {
handler: async () => {
const { dispose } = await os.popupAsyncWithDialog(import('./custom-emojis-manager.local.list.logs.vue').then(x => x.default), {
logs: requestLogs.value,
}, {
closed: () => {

View File

@@ -46,7 +46,7 @@ function load() {
load();
async function add(ev: MouseEvent) {
const { dispose } = os.popup(defineAsyncComponent(() => import('./avatar-decoration-edit-dialog.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('./avatar-decoration-edit-dialog.vue').then(x => x.default), {
}, {
done: result => {
if (result.created) {
@@ -57,8 +57,8 @@ async function add(ev: MouseEvent) {
});
}
function edit(avatarDecoration) {
const { dispose } = os.popup(defineAsyncComponent(() => import('./avatar-decoration-edit-dialog.vue')), {
async function edit(avatarDecoration) {
const { dispose } = await os.popupAsyncWithDialog(import('./avatar-decoration-edit-dialog.vue').then(x => x.default), {
avatarDecoration: avatarDecoration,
}, {
done: result => {

View File

@@ -181,9 +181,9 @@ function showMenu(ev: MouseEvent, contextmenu = false) {
menu.push({
text: i18n.ts.reportAbuse,
icon: 'ti ti-exclamation-circle',
action: () => {
action: async () => {
const localUrl = `${url}/chat/messages/${props.message.id}`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: props.message.fromUser!,
initialComment: `${localUrl}\n-----\n`,
}, {

View File

@@ -128,7 +128,7 @@ const toggleSelect = (emoji) => {
};
const add = async (ev: MouseEvent) => {
const { dispose } = os.popup(defineAsyncComponent(() => import('./emoji-edit-dialog.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('./emoji-edit-dialog.vue').then(x => x.default), {
}, {
done: result => {
if (result.created) {
@@ -139,8 +139,8 @@ const add = async (ev: MouseEvent) => {
});
};
const edit = (emoji) => {
const { dispose } = os.popup(defineAsyncComponent(() => import('./emoji-edit-dialog.vue')), {
const edit = async (emoji) => {
const { dispose } = await os.popupAsyncWithDialog(import('./emoji-edit-dialog.vue').then(x => x.default), {
emoji: emoji,
}, {
done: result => {

View File

@@ -174,10 +174,10 @@ function rename() {
});
}
function describe() {
async function describe() {
if (!file.value) return;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkFileCaptionEditWindow.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkFileCaptionEditWindow.vue').then(x => x.default), {
default: file.value.comment ?? '',
file: file.value,
}, {

View File

@@ -67,7 +67,7 @@ function menu(ev) {
}
const edit = async (emoji) => {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/pages/emoji-edit-dialog.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('@/pages/emoji-edit-dialog.vue').then(x => x.default), {
emoji: emoji,
}, {
closed: () => dispose(),

View File

@@ -238,12 +238,12 @@ async function run() {
}
}
function reportAbuse() {
async function reportAbuse() {
if (!flash.value) return;
const pageUrl = `${url}/play/${flash.value.id}`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: flash.value.user,
initialComment: `Play: ${pageUrl}\n-----\n`,
}, {

View File

@@ -153,12 +153,12 @@ function edit() {
router.push(`/gallery/${post.value.id}/edit`);
}
function reportAbuse() {
async function reportAbuse() {
if (!post.value) return;
const pageUrl = `${url}/gallery/${post.value.id}`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: post.value.user,
initialComment: `Post: ${pageUrl}\n-----\n`,
}, {

View File

@@ -245,12 +245,12 @@ function pin(pin) {
});
}
function reportAbuse() {
async function reportAbuse() {
if (!page.value) return;
const pageUrl = `${url}/@${props.username}/pages/${props.pageName}`;
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkAbuseReportWindow.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkAbuseReportWindow.vue').then(x => x.default), {
user: page.value.user,
initialComment: `Page: ${pageUrl}\n-----\n`,
}, {

View File

@@ -41,9 +41,9 @@ async function save() {
mainRouter.push('/');
}
onMounted(() => {
onMounted(async () => {
if (props.token == null) {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkForgotPassword.vue')), {}, {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkForgotPassword.vue').then(x => x.default), {}, {
closed: () => dispose(),
});
mainRouter.push('/');

View File

@@ -117,7 +117,7 @@ async function registerTOTP(): Promise<void> {
token: auth.result.token,
});
const { dispose } = os.popup(defineAsyncComponent(() => import('./2fa.qrdialog.vue')), {
const { dispose } = await os.popupAsyncWithDialog(import('./2fa.qrdialog.vue').then(x => x.default), {
twoFactorData,
}, {
closed: () => dispose(),

View File

@@ -68,8 +68,8 @@ misskeyApi('get-avatar-decorations').then(_avatarDecorations => {
loading.value = false;
});
function openDecoration(avatarDecoration, index?: number) {
const { dispose } = os.popup(defineAsyncComponent(() => import('./avatar-decoration.dialog.vue')), {
async function openDecoration(avatarDecoration, index?: number) {
const { dispose } = await os.popupAsyncWithDialog(import('./avatar-decoration.dialog.vue').then(x => x.default), {
decoration: avatarDecoration,
usingIndex: index,
}, {

View File

@@ -81,8 +81,8 @@ const pagination = {
noPaging: true,
};
function generateToken() {
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkTokenGenerateWindow.vue')), {}, {
async function generateToken() {
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkTokenGenerateWindow.vue').then(x => x.default), {}, {
done: async result => {
const { name, permissions } = result;
const { token } = await misskeyApi('miauth/gen-token', {