This commit is contained in:
syuilo 2020-09-20 13:53:54 +09:00
parent b89bf97c9a
commit 404583a285
4 changed files with 14 additions and 5 deletions

View File

@ -45,7 +45,13 @@ export function api(endpoint: string, data: Record<string, any> = {}, token?: st
return promise;
}
export function popup(component: Component, props: Record<string, any>, 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<string, any>, 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<string, any>, events =
});
}
export function modal(component: Component, props: Record<string, any>, events = {}, option?: { source?: any; position?: any; cancelableByBgClick?: boolean; }) {
export function modal(component: Component | typeof import('*.vue'), props: Record<string, any>, events = {}, option?: { source?: any; position?: any; cancelableByBgClick?: boolean; }) {
if (isModule(component)) component = component.default;
if (_DEV_) {
console.log('os:modal', component, props, events, option);
}

View File

@ -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) => {

View File

@ -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);

View File

@ -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;