wip
This commit is contained in:
parent
8e9c9e9906
commit
70c71859f3
|
@ -297,7 +297,7 @@ function showMenu(ev: MouseEvent, item: typeof items.value[0]) {
|
||||||
icon: 'ti ti-sparkles',
|
icon: 'ti ti-sparkles',
|
||||||
text: i18n.ts._imageEffector.title,
|
text: i18n.ts._imageEffector.title,
|
||||||
action: async () => {
|
action: async () => {
|
||||||
const { dispose } = os.popup(defineAsyncComponent(() => import('@/components/MkImageEffectorDialog.vue')), {
|
const { dispose } = await os.popupAsyncWithDialog(import('@/components/MkImageEffectorDialog.vue').then(x => x.default), {
|
||||||
image: item.file,
|
image: item.file,
|
||||||
}, {
|
}, {
|
||||||
ok: (file) => {
|
ok: (file) => {
|
||||||
|
|
|
@ -206,6 +206,52 @@ export function popup<T extends Component>(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function popupAsyncWithDialog<T extends Component>(
|
||||||
|
componentFetching: Promise<T>,
|
||||||
|
props: ComponentProps<T>,
|
||||||
|
events: Partial<ComponentEmit<T>> = {},
|
||||||
|
): Promise<{ dispose: () => void }> {
|
||||||
|
const closeWaiting = waiting();
|
||||||
|
|
||||||
|
let component: T;
|
||||||
|
|
||||||
|
try {
|
||||||
|
component = await componentFetching;
|
||||||
|
} catch (err) {
|
||||||
|
closeWaiting();
|
||||||
|
alert({
|
||||||
|
type: 'error',
|
||||||
|
title: i18n.ts.somethingHappened,
|
||||||
|
text: 'CODE: ASYNC_COMP_LOAD_FAIL',
|
||||||
|
});
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
|
||||||
|
closeWaiting();
|
||||||
|
|
||||||
|
markRaw(component);
|
||||||
|
|
||||||
|
const id = ++popupIdCount;
|
||||||
|
const dispose = () => {
|
||||||
|
// このsetTimeoutが無いと挙動がおかしくなる(autocompleteが閉じなくなる)。Vueのバグ?
|
||||||
|
window.setTimeout(() => {
|
||||||
|
popups.value = popups.value.filter(p => p.id !== id);
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
const state = {
|
||||||
|
component,
|
||||||
|
props,
|
||||||
|
events,
|
||||||
|
id,
|
||||||
|
};
|
||||||
|
|
||||||
|
popups.value.push(state);
|
||||||
|
|
||||||
|
return {
|
||||||
|
dispose,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function pageWindow(path: string) {
|
export function pageWindow(path: string) {
|
||||||
const { dispose } = popup(MkPageWindow, {
|
const { dispose } = popup(MkPageWindow, {
|
||||||
initialPath: path,
|
initialPath: path,
|
||||||
|
|
Loading…
Reference in New Issue