diff --git a/src/client/os.ts b/src/client/os.ts index 015456ac07..3de504d2ea 100644 --- a/src/client/os.ts +++ b/src/client/os.ts @@ -45,7 +45,13 @@ export function api(endpoint: string, data: Record = {}, token?: st return promise; } -export function popup(component: Component, props: Record, events = {}, option?) { +function isModule(x: any): x is typeof import('*.vue') { + return x.default != null; +} + +export function popup(component: Component | typeof import('*.vue'), props: Record, events = {}, option?) { + if (isModule(component)) component = component.default; + if (_DEV_) { console.log('os:popup', component, props, events); } @@ -75,7 +81,9 @@ export function popup(component: Component, props: Record, events = }); } -export function modal(component: Component, props: Record, events = {}, option?: { source?: any; position?: any; cancelableByBgClick?: boolean; }) { +export function modal(component: Component | typeof import('*.vue'), props: Record, events = {}, option?: { source?: any; position?: any; cancelableByBgClick?: boolean; }) { + if (isModule(component)) component = component.default; + if (_DEV_) { console.log('os:modal', component, props, events, option); } diff --git a/src/client/pages/my-settings/index.vue b/src/client/pages/my-settings/index.vue index fbc22f26a2..7688950e8f 100644 --- a/src/client/pages/my-settings/index.vue +++ b/src/client/pages/my-settings/index.vue @@ -116,7 +116,7 @@ export default defineComponent({ async configure() { const includingTypes = notificationTypes.filter(x => !this.$store.state.i.mutingNotificationTypes.includes(x)); - os.modal(await import('@/components/notification-setting-window.vue').then(x => x.default), { + os.modal(await import('@/components/notification-setting-window.vue'), { includingTypes, showGlobalToggle: false, }).then(async (res) => { diff --git a/src/client/scripts/autocomplete.ts b/src/client/scripts/autocomplete.ts index 3a92ccf6fd..dc29c3f01e 100644 --- a/src/client/scripts/autocomplete.ts +++ b/src/client/scripts/autocomplete.ts @@ -146,7 +146,7 @@ export class Autocomplete { this.opening = false; } else { - const MkAutocomplete = await import('@/components/autocomplete.vue').then(x => x.default); + const MkAutocomplete = await import('@/components/autocomplete.vue'); const _x = ref(x); const _y = ref(y); diff --git a/src/client/widgets/notifications.vue b/src/client/widgets/notifications.vue index 6039ddcdc1..ab96e9707e 100644 --- a/src/client/widgets/notifications.vue +++ b/src/client/widgets/notifications.vue @@ -38,6 +38,7 @@ const widget = define({ export default defineComponent({ extends: widget, + components: { MkContainer, XNotifications, @@ -51,7 +52,7 @@ export default defineComponent({ methods: { async configure() { - os.modal(await import('@/components/notification-setting-window.vue').then(x => x.default), { + os.modal(await import('@/components/notification-setting-window.vue'), { includingTypes: this.props.includingTypes, }).then(async ({ includingTypes }) => { this.props.includingTypes = includingTypes;