popupの制御を出す側で行うように

This commit is contained in:
kakkokari-gtyih
2024-07-15 11:53:32 +09:00
parent 8d144c8fdc
commit 87a7d1a8ea
10 changed files with 52 additions and 52 deletions

View File

@@ -3,10 +3,11 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { defineAsyncComponent } from 'vue';
import { defineAsyncComponent, inject } from 'vue';
import { $i } from '@/account.js';
import { i18n } from '@/i18n.js';
import { popup } from '@/os.js';
import { embedPage } from '@/config.js';
export type OpenOnRemoteOptions = {
/**
@@ -47,18 +48,22 @@ export type OpenOnRemoteOptions = {
export function pleaseLogin(path?: string, openOnRemote?: OpenOnRemoteOptions) {
if ($i) return;
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {
autoSet: true,
message: openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired,
openOnRemote,
}, {
cancelled: () => {
if (path) {
window.location.href = path;
}
},
closed: () => dispose(),
});
if (embedPage) {
window.open(path ?? '/', '_blank', 'noopener');
} else {
const { dispose } = popup(defineAsyncComponent(() => import('@/components/MkSigninDialog.vue')), {
autoSet: true,
message: openOnRemote ? i18n.ts.signinOrContinueOnRemote : i18n.ts.signinRequired,
openOnRemote,
}, {
cancelled: () => {
if (path) {
window.location.href = path;
}
},
closed: () => dispose(),
});
}
throw new Error('signin required');
}