This commit is contained in:
syuilo 2020-11-03 15:22:55 +09:00
parent 5ef4a52bbd
commit c3ae6f3a4a
25 changed files with 73 additions and 62 deletions

View File

@ -248,8 +248,8 @@ export default defineComponent({
os.contextMenu([{ os.contextMenu([{
text: this.$t('openInWindow'), text: this.$t('openInWindow'),
icon: faWindowRestore, icon: faWindowRestore,
action: async () => { action: () => {
os.popup(await import('./drive-window.vue'), { os.popup(import('./drive-window.vue'), {
initialFolder: this.folder initialFolder: this.folder
}, { }, {
}, 'closed'); }, 'closed');

View File

@ -46,7 +46,7 @@ export default defineComponent({
if (!document.body.contains(this.$el)) return; if (!document.body.contains(this.$el)) return;
if (this.close) return; if (this.close) return;
const { dispose } = os.popup(await import('@/components/url-preview-popup.vue'), { const { dispose } = await os.popup(import('@/components/url-preview-popup.vue'), {
url: this.url, url: this.url,
source: this.$el source: this.$el
}); });

View File

@ -498,7 +498,7 @@ export default defineComponent({
react(viaKeyboard = false) { react(viaKeyboard = false) {
pleaseLogin(); pleaseLogin();
this.blur(); this.blur();
os.popup(defineAsyncComponent(() => import('@/components/reaction-picker.vue')), { os.popup(import('@/components/reaction-picker.vue'), {
showFocus: viaKeyboard, showFocus: viaKeyboard,
src: this.$refs.reactButton, src: this.$refs.reactButton,
}, { }, {
@ -644,7 +644,7 @@ export default defineComponent({
text: this.$t('reportAbuse'), text: this.$t('reportAbuse'),
action: () => { action: () => {
const u = `${url}/notes/${this.appearNote.id}`; const u = `${url}/notes/${this.appearNote.id}`;
os.popup(defineAsyncComponent(() => import('@/components/abuse-report-window.vue')), { os.popup(import('@/components/abuse-report-window.vue'), {
user: this.appearNote.user, user: this.appearNote.user,
initialComment: `Note: ${u}\n-----\n` initialComment: `Note: ${u}\n-----\n`
}, {}, 'closed'); }, {}, 'closed');

View File

@ -378,13 +378,13 @@ export default defineComponent({
this.saveDraft(); this.saveDraft();
}, },
async setVisibility() { setVisibility() {
if (this.channel) { if (this.channel) {
// TODO: information dialog // TODO: information dialog
return; return;
} }
os.popup(await import('./visibility-picker.vue'), { os.popup(import('./visibility-picker.vue'), {
currentVisibility: this.visibility, currentVisibility: this.visibility,
currentLocalOnly: this.localOnly, currentLocalOnly: this.localOnly,
src: this.$refs.visibilityButton src: this.$refs.visibilityButton

View File

@ -257,8 +257,8 @@ export default defineComponent({
}], ev.currentTarget || ev.target); }], ev.currentTarget || ev.target);
}, },
async addAcount() { addAcount() {
os.popup(await import('./signin-dialog.vue'), {}, { os.popup(import('./signin-dialog.vue'), {}, {
done: res => { done: res => {
this.$store.dispatch('addAcount', res); this.$store.dispatch('addAcount', res);
os.success(); os.success();
@ -266,8 +266,8 @@ export default defineComponent({
}, 'closed'); }, 'closed');
}, },
async createAccount() { createAccount() {
os.popup(await import('./signup-dialog.vue'), {}, { os.popup(import('./signup-dialog.vue'), {}, {
done: res => { done: res => {
this.$store.dispatch('addAcount', res); this.$store.dispatch('addAcount', res);
this.switchAccountWithToken(res.i); this.switchAccountWithToken(res.i);
@ -275,7 +275,7 @@ export default defineComponent({
}, 'closed'); }, 'closed');
}, },
async switchAccount(account: any) { switchAccount(account: any) {
const token = this.$store.state.device.accounts.find((x: any) => x.id === account.id).token; const token = this.$store.state.device.accounts.find((x: any) => x.id === account.id).token;
this.switchAccountWithToken(token); this.switchAccountWithToken(token);
}, },

View File

@ -119,8 +119,8 @@ export default defineComponent({
os.popups.value = os.popups.value.filter(x => x !== p); os.popups.value = os.popups.value.filter(x => x !== p);
}; };
const showReq = async req => { const showReq = req => {
os.popup(await import('./taskmanager.api-window.vue'), { os.popup(import('./taskmanager.api-window.vue'), {
req: req req: req
}, { }, {
}, 'closed'); }, 'closed');

View File

@ -71,7 +71,7 @@ export default defineComponent({
if (!document.body.contains(this.$el)) return; if (!document.body.contains(this.$el)) return;
if (this.close) return; if (this.close) return;
const { dispose } = os.popup(await import('@/components/url-preview-popup.vue'), { const { dispose } = await os.popup(import('@/components/url-preview-popup.vue'), {
url: this.url, url: this.url,
source: this.$el source: this.$el
}); });

View File

@ -23,13 +23,13 @@ export default {
} }
}; };
const show = async e => { const show = e => {
if (!document.body.contains(el)) return; if (!document.body.contains(el)) return;
if (self._close) return; if (self._close) return;
if (self.text == null) return; if (self.text == null) return;
const showing = ref(true); const showing = ref(true);
popup(await import('@/components/ui/tooltip.vue'), { popup(import('@/components/ui/tooltip.vue'), {
showing, showing,
text: self.text, text: self.text,
source: el source: el

View File

@ -18,13 +18,13 @@ export class UserPreview {
} }
@autobind @autobind
private async show() { private show() {
if (!document.body.contains(this.el)) return; if (!document.body.contains(this.el)) return;
if (this.promise) return; if (this.promise) return;
const showing = ref(true); const showing = ref(true);
popup(await import('@/components/user-preview.vue'), { popup(import('@/components/user-preview.vue'), {
showing, showing,
q: this.user, q: this.user,
source: this.el source: this.el

View File

@ -147,7 +147,9 @@ export const popups = ref([]) as Ref<{
props: Record<string, any>; props: Record<string, any>;
}[]>; }[]>;
export function popup(component: Component | typeof import('*.vue'), props: Record<string, any>, events = {}, disposeEvent?: string) { 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; if (isModule(component)) component = component.default;
markRaw(component); markRaw(component);
@ -179,7 +181,7 @@ export function popup(component: Component | typeof import('*.vue'), props: Reco
export function pageWindow(path: string) { export function pageWindow(path: string) {
const { component, props } = resolve(path); const { component, props } = resolve(path);
popup(defineAsyncComponent(() => import('@/components/page-window.vue')), { popup(import('@/components/page-window.vue'), {
initialPath: path, initialPath: path,
initialComponent: markRaw(component), initialComponent: markRaw(component),
initialProps: props, initialProps: props,
@ -188,7 +190,7 @@ export function pageWindow(path: string) {
export function dialog(props: Record<string, any>) { export function dialog(props: Record<string, any>) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(defineAsyncComponent(() => import('@/components/dialog.vue')), props, { popup(import('@/components/dialog.vue'), props, {
done: result => { done: result => {
resolve(result ? result : { canceled: true }); resolve(result ? result : { canceled: true });
}, },
@ -202,7 +204,7 @@ export function success() {
setTimeout(() => { setTimeout(() => {
showing.value = false; showing.value = false;
}, 1000); }, 1000);
popup(defineAsyncComponent(() => import('@/components/waiting-dialog.vue')), { popup(import('@/components/waiting-dialog.vue'), {
success: true, success: true,
showing: showing showing: showing
}, { }, {
@ -214,7 +216,7 @@ export function success() {
export function waiting() { export function waiting() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const showing = ref(true); const showing = ref(true);
popup(defineAsyncComponent(() => import('@/components/waiting-dialog.vue')), { popup(import('@/components/waiting-dialog.vue'), {
success: false, success: false,
showing: showing showing: showing
}, { }, {
@ -225,7 +227,7 @@ export function waiting() {
export function form(title, form) { export function form(title, form) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(defineAsyncComponent(() => import('@/components/form-dialog.vue')), { title, form }, { popup(import('@/components/form-dialog.vue'), { title, form }, {
done: result => { done: result => {
resolve(result); resolve(result);
}, },
@ -235,7 +237,7 @@ export function form(title, form) {
export async function selectUser() { export async function selectUser() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(defineAsyncComponent(() => import('@/components/user-select-dialog.vue')), {}, { popup(import('@/components/user-select-dialog.vue'), {}, {
ok: user => { ok: user => {
resolve(user); resolve(user);
}, },
@ -245,7 +247,7 @@ export async function selectUser() {
export async function selectDriveFile(multiple: boolean) { export async function selectDriveFile(multiple: boolean) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(defineAsyncComponent(() => import('@/components/drive-select-dialog.vue')), { popup(import('@/components/drive-select-dialog.vue'), {
type: 'file', type: 'file',
multiple multiple
}, { }, {
@ -260,7 +262,7 @@ export async function selectDriveFile(multiple: boolean) {
export async function selectDriveFolder(multiple: boolean) { export async function selectDriveFolder(multiple: boolean) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(defineAsyncComponent(() => import('@/components/drive-select-dialog.vue')), { popup(import('@/components/drive-select-dialog.vue'), {
type: 'folder', type: 'folder',
multiple multiple
}, { }, {
@ -275,7 +277,7 @@ export async function selectDriveFolder(multiple: boolean) {
export async function pickEmoji(src?: HTMLElement) { export async function pickEmoji(src?: HTMLElement) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
popup(defineAsyncComponent(() => import('@/components/emoji-picker.vue')), { popup(import('@/components/emoji-picker.vue'), {
src src
}, { }, {
done: emoji => { done: emoji => {
@ -287,7 +289,8 @@ export async function pickEmoji(src?: HTMLElement) {
export function modalMenu(items: any[], src?: HTMLElement, options?: { align?: string; viaKeyboard?: boolean }) { export function modalMenu(items: any[], src?: HTMLElement, options?: { align?: string; viaKeyboard?: boolean }) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const { dispose } = popup(defineAsyncComponent(() => import('@/components/ui/modal-menu.vue')), { let dispose;
popup(import('@/components/ui/modal-menu.vue'), {
items, items,
src, src,
align: options?.align, align: options?.align,
@ -297,6 +300,8 @@ export function modalMenu(items: any[], src?: HTMLElement, options?: { align?: s
resolve(); resolve();
dispose(); dispose();
}, },
}).then(_dispose => {
dispose = _dispose;
}); });
}); });
} }
@ -304,7 +309,8 @@ export function modalMenu(items: any[], src?: HTMLElement, options?: { align?: s
export function contextMenu(items: any[], ev: MouseEvent) { export function contextMenu(items: any[], ev: MouseEvent) {
ev.preventDefault(); ev.preventDefault();
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const { dispose } = popup(defineAsyncComponent(() => import('@/components/ui/context-menu.vue')), { let dispose;
popup(import('@/components/ui/context-menu.vue'), {
items, items,
ev, ev,
}, { }, {
@ -312,6 +318,8 @@ export function contextMenu(items: any[], ev: MouseEvent) {
resolve(); resolve();
dispose(); dispose();
}, },
}).then(_dispose => {
dispose = _dispose;
}); });
}); });
} }
@ -323,11 +331,14 @@ export function post(props: Record<string, any>) {
// Vueが渡されたコンポーネントに内部的に__propsというプロパティを生やす影響で、 // Vueが渡されたコンポーネントに内部的に__propsというプロパティを生やす影響で、
// 複数のpost formを開いたときに場合によってはエラーになる // 複数のpost formを開いたときに場合によってはエラーになる
// もちろん複数のpost formを開けること自体Misskeyサイドのバグなのだが // もちろん複数のpost formを開けること自体Misskeyサイドのバグなのだが
const { dispose } = popup(MkPostFormDialog, props, { let dispose;
popup(MkPostFormDialog, props, {
closed: () => { closed: () => {
resolve(); resolve();
dispose(); dispose();
}, },
}).then(_dispose => {
dispose = _dispose;
}); });
}); });
} }

View File

@ -113,8 +113,8 @@ export default defineComponent({
os.promiseDialog(promise); os.promiseDialog(promise);
}, },
async edit(emoji) { edit(emoji) {
os.popup(await import('./emoji-edit-dialog.vue'), { os.popup(import('./emoji-edit-dialog.vue'), {
emoji: emoji emoji: emoji
}, { }, {
done: result => { done: result => {

View File

@ -84,8 +84,8 @@ export default defineComponent({
Progress.done(); Progress.done();
}, },
async showUser() { showUser() {
os.popup(await import('./user-dialog.vue'), { os.popup(import('./user-dialog.vue'), {
userId: this.file.userId userId: this.file.userId
}, {}, 'closed'); }, {}, 'closed');
}, },

View File

@ -131,8 +131,8 @@ export default defineComponent({
}); });
}, },
async show(file, ev) { show(file, ev) {
os.popup(await import('./file-dialog.vue'), { os.popup(import('./file-dialog.vue'), {
fileId: file.id fileId: file.id
}, {}, 'closed'); }, {}, 'closed');
}, },

View File

@ -206,8 +206,8 @@ export default defineComponent({
}); });
}, },
async show(user) { show(user) {
os.popup(await import('./user-dialog.vue'), { os.popup(import('./user-dialog.vue'), {
userId: user.id userId: user.id
}, {}, 'closed'); }, {}, 'closed');
}, },

View File

@ -42,8 +42,8 @@ export default defineComponent({
}, },
methods: { methods: {
async generateToken() { generateToken() {
os.popup(await import('@/components/token-generate-window.vue'), {}, { os.popup(import('@/components/token-generate-window.vue'), {}, {
done: async result => { done: async result => {
const { name, permissions } = result; const { name, permissions } = result;
const { token } = await os.api('miauth/gen-token', { const { token } = await os.api('miauth/gen-token', {

View File

@ -72,9 +72,9 @@ export default defineComponent({
os.api('notifications/mark-all-as-read'); os.api('notifications/mark-all-as-read');
}, },
async configure() { configure() {
const includingTypes = notificationTypes.filter(x => !this.$store.state.i.mutingNotificationTypes.includes(x)); const includingTypes = notificationTypes.filter(x => !this.$store.state.i.mutingNotificationTypes.includes(x));
os.popup(await import('@/components/notification-setting-window.vue'), { os.popup(import('@/components/notification-setting-window.vue'), {
includingTypes, includingTypes,
showGlobalToggle: false, showGlobalToggle: false,
}, { }, {

View File

@ -69,7 +69,7 @@ export default defineComponent({
}, },
taskmanager() { taskmanager() {
os.popup(defineAsyncComponent(() => import('@/components/taskmanager.vue')), { os.popup(import('@/components/taskmanager.vue'), {
}, {}, 'closed'); }, {}, 'closed');
} }
} }

View File

@ -117,8 +117,8 @@ export default defineComponent({
return; return;
} }
const token = permissions == null || permissions.length === 0 ? null : await new Promise(async (res, rej) => { const token = permissions == null || permissions.length === 0 ? null : await new Promise((res, rej) => {
os.popup(await import('@/components/token-generate-window.vue'), { os.popup(import('@/components/token-generate-window.vue'), {
title: this.$t('tokenRequested'), title: this.$t('tokenRequested'),
information: this.$t('pluginTokenRequestedDescription'), information: this.$t('pluginTokenRequestedDescription'),
initialName: name, initialName: name,

View File

@ -73,8 +73,8 @@ export default defineComponent({
this.changed = false; this.changed = false;
}, },
async preview(ev) { preview(ev) {
os.popup(await import('@/components/reaction-picker.vue'), { os.popup(import('@/components/reaction-picker.vue'), {
reactions: this.splited, reactions: this.splited,
showFocus: false, showFocus: false,
src: ev.currentTarget || ev.target, src: ev.currentTarget || ev.target,
@ -85,7 +85,7 @@ export default defineComponent({
this.reactions = defaultSettings.reactions.join(''); this.reactions = defaultSettings.reactions.join('');
}, },
async chooseEmoji(ev) { chooseEmoji(ev) {
os.pickEmoji(ev.currentTarget || ev.target).then(emoji => { os.pickEmoji(ev.currentTarget || ev.target).then(emoji => {
this.reactions += emoji; this.reactions += emoji;
}); });

View File

@ -101,8 +101,8 @@ export function getUserMenu(user) {
}); });
} }
async function reportAbuse() { function reportAbuse() {
os.popup(await import('@/components/abuse-report-window.vue'), { os.popup(import('@/components/abuse-report-window.vue'), {
user: user, user: user,
}, {}, 'closed'); }, {}, 'closed');
} }

View File

@ -143,7 +143,7 @@ export default defineComponent({
os.post(); os.post();
}, },
async onNotification(notification) { onNotification(notification) {
if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) {
return; return;
} }
@ -153,7 +153,7 @@ export default defineComponent({
id: notification.id id: notification.id
}); });
os.popup(await import('@/components/toast.vue'), { os.popup(import('@/components/toast.vue'), {
notification notification
}, {}, 'closed'); }, {}, 'closed');
} }

View File

@ -42,8 +42,8 @@ export default defineComponent({
this.menu = [{ this.menu = [{
icon: faCog, icon: faCog,
text: this.$t('notificationSetting'), text: this.$t('notificationSetting'),
action: async () => { action: () => {
os.popup(await import('@/components/notification-setting-window.vue'), { os.popup(import('@/components/notification-setting-window.vue'), {
includingTypes: this.column.includingTypes, includingTypes: this.column.includingTypes,
}, { }, {
done: async (res) => { done: async (res) => {

View File

@ -235,7 +235,7 @@ export default defineComponent({
}], e); }], e);
}, },
async onNotification(notification) { onNotification(notification) {
if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) {
return; return;
} }
@ -244,7 +244,7 @@ export default defineComponent({
id: notification.id id: notification.id
}); });
os.popup(await import('@/components/toast.vue'), { os.popup(import('@/components/toast.vue'), {
notification notification
}, {}, 'closed'); }, {}, 'closed');
} }

View File

@ -95,7 +95,7 @@ export default defineComponent({
if (window._scroll) window._scroll(); if (window._scroll) window._scroll();
}, },
async onNotification(notification) { onNotification(notification) {
if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) { if (this.$store.state.i.mutingNotificationTypes.includes(notification.type)) {
return; return;
} }
@ -104,7 +104,7 @@ export default defineComponent({
id: notification.id id: notification.id
}); });
os.popup(await import('@/components/toast.vue'), { os.popup(import('@/components/toast.vue'), {
notification notification
}, {}, 'closed'); }, {}, 'closed');
} }

View File

@ -51,8 +51,8 @@ export default defineComponent({
}, },
methods: { methods: {
async configure() { configure() {
os.popup(await import('@/components/notification-setting-window.vue'), { os.popup(import('@/components/notification-setting-window.vue'), {
includingTypes: this.props.includingTypes, includingTypes: this.props.includingTypes,
}, { }, {
done: async (res) => { done: async (res) => {