wip use defineAsyncComponent
This commit is contained in:
parent
11f735b088
commit
555d42f7a7
|
@ -1,5 +1,5 @@
|
|||
import { del, get, set } from '@/scripts/idb-proxy';
|
||||
import { reactive } from 'vue';
|
||||
import { defineAsyncComponent, reactive } from 'vue';
|
||||
import * as misskey from 'misskey-js';
|
||||
import { apiUrl } from '@/config';
|
||||
import { waiting, api, popup, popupMenu, success, alert } from '@/os';
|
||||
|
@ -141,7 +141,7 @@ export async function openAccountMenu(opts: {
|
|||
onChoose?: (account: misskey.entities.UserDetailed) => void;
|
||||
}, ev: MouseEvent) {
|
||||
function showSigninDialog() {
|
||||
popup(import('@/components/signin-dialog.vue'), {}, {
|
||||
popup(defineAsyncComponent(() => import('@/components/signin-dialog.vue')), {}, {
|
||||
done: res => {
|
||||
addAccount(res.id, res.i);
|
||||
success();
|
||||
|
@ -150,7 +150,7 @@ export async function openAccountMenu(opts: {
|
|||
}
|
||||
|
||||
function createAccount() {
|
||||
popup(import('@/components/signup-dialog.vue'), {}, {
|
||||
popup(defineAsyncComponent(() => import('@/components/signup-dialog.vue')), {}, {
|
||||
done: res => {
|
||||
addAccount(res.id, res.i);
|
||||
switchAccountWithToken(res.i);
|
||||
|
|
|
@ -230,7 +230,7 @@ if (lastVersion !== version) {
|
|||
if (lastVersion != null && compareVersions(version, lastVersion) === 1) {
|
||||
// ログインしてる場合だけ
|
||||
if ($i) {
|
||||
popup(import('@/components/updated.vue'), {}, {}, 'closed');
|
||||
popup(defineAsyncComponent(() => import('@/components/updated.vue')), {}, {}, 'closed');
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
@ -111,10 +111,6 @@ export function promiseDialog<T extends Promise<any>>(
|
|||
return promise;
|
||||
}
|
||||
|
||||
function isModule(x: any): x is typeof import('*.vue') {
|
||||
return x.default != null;
|
||||
}
|
||||
|
||||
let popupIdCount = 0;
|
||||
export const popups = ref([]) as Ref<{
|
||||
id: any;
|
||||
|
@ -132,10 +128,7 @@ export function claimZIndex(priority: 'low' | 'middle' | 'high' = 'low'): number
|
|||
return zIndexes[priority];
|
||||
}
|
||||
|
||||
export async function popup(component: Component | typeof import('*.vue') | Promise<Component | typeof import('*.vue')>, props: Record<string, any>, events = {}, disposeEvent?: string) {
|
||||
if (component.then) component = await component;
|
||||
|
||||
if (isModule(component)) component = component.default;
|
||||
export async function popup(component: Component, props: Record<string, any>, events = {}, disposeEvent?: string) {
|
||||
markRaw(component);
|
||||
|
||||
const id = ++popupIdCount;
|
||||
|
@ -164,7 +157,7 @@ export async function popup(component: Component | typeof import('*.vue') | Prom
|
|||
|
||||
export function pageWindow(path: string) {
|
||||
const { component, props } = resolve(path);
|
||||
popup(import('@/components/page-window.vue'), {
|
||||
popup(defineAsyncComponent(() => import('@/components/page-window.vue')), {
|
||||
initialPath: path,
|
||||
initialComponent: markRaw(component),
|
||||
initialProps: props,
|
||||
|
|
Loading…
Reference in New Issue