wip use defineAsyncComponent

This commit is contained in:
tamaina 2022-04-27 00:15:10 +09:00
parent 11f735b088
commit 555d42f7a7
3 changed files with 6 additions and 13 deletions

View File

@ -1,5 +1,5 @@
import { del, get, set } from '@/scripts/idb-proxy'; import { del, get, set } from '@/scripts/idb-proxy';
import { reactive } from 'vue'; import { defineAsyncComponent, reactive } from 'vue';
import * as misskey from 'misskey-js'; import * as misskey from 'misskey-js';
import { apiUrl } from '@/config'; import { apiUrl } from '@/config';
import { waiting, api, popup, popupMenu, success, alert } from '@/os'; import { waiting, api, popup, popupMenu, success, alert } from '@/os';
@ -141,7 +141,7 @@ export async function openAccountMenu(opts: {
onChoose?: (account: misskey.entities.UserDetailed) => void; onChoose?: (account: misskey.entities.UserDetailed) => void;
}, ev: MouseEvent) { }, ev: MouseEvent) {
function showSigninDialog() { function showSigninDialog() {
popup(import('@/components/signin-dialog.vue'), {}, { popup(defineAsyncComponent(() => import('@/components/signin-dialog.vue')), {}, {
done: res => { done: res => {
addAccount(res.id, res.i); addAccount(res.id, res.i);
success(); success();
@ -150,7 +150,7 @@ export async function openAccountMenu(opts: {
} }
function createAccount() { function createAccount() {
popup(import('@/components/signup-dialog.vue'), {}, { popup(defineAsyncComponent(() => import('@/components/signup-dialog.vue')), {}, {
done: res => { done: res => {
addAccount(res.id, res.i); addAccount(res.id, res.i);
switchAccountWithToken(res.i); switchAccountWithToken(res.i);

View File

@ -230,7 +230,7 @@ if (lastVersion !== version) {
if (lastVersion != null && compareVersions(version, lastVersion) === 1) { if (lastVersion != null && compareVersions(version, lastVersion) === 1) {
// ログインしてる場合だけ // ログインしてる場合だけ
if ($i) { if ($i) {
popup(import('@/components/updated.vue'), {}, {}, 'closed'); popup(defineAsyncComponent(() => import('@/components/updated.vue')), {}, {}, 'closed');
} }
} }
} catch (e) { } catch (e) {

View File

@ -111,10 +111,6 @@ export function promiseDialog<T extends Promise<any>>(
return promise; return promise;
} }
function isModule(x: any): x is typeof import('*.vue') {
return x.default != null;
}
let popupIdCount = 0; let popupIdCount = 0;
export const popups = ref([]) as Ref<{ export const popups = ref([]) as Ref<{
id: any; id: any;
@ -132,10 +128,7 @@ export function claimZIndex(priority: 'low' | 'middle' | 'high' = 'low'): number
return zIndexes[priority]; return zIndexes[priority];
} }
export async function popup(component: Component | typeof import('*.vue') | Promise<Component | typeof import('*.vue')>, props: Record<string, any>, events = {}, disposeEvent?: string) { export async function popup(component: Component, props: Record<string, any>, events = {}, disposeEvent?: string) {
if (component.then) component = await component;
if (isModule(component)) component = component.default;
markRaw(component); markRaw(component);
const id = ++popupIdCount; const id = ++popupIdCount;
@ -164,7 +157,7 @@ export async function popup(component: Component | typeof import('*.vue') | Prom
export function pageWindow(path: string) { export function pageWindow(path: string) {
const { component, props } = resolve(path); const { component, props } = resolve(path);
popup(import('@/components/page-window.vue'), { popup(defineAsyncComponent(() => import('@/components/page-window.vue')), {
initialPath: path, initialPath: path,
initialComponent: markRaw(component), initialComponent: markRaw(component),
initialProps: props, initialProps: props,