This commit is contained in:
syuilo 2018-05-27 18:12:39 +09:00
parent e477de6dd0
commit fa1a85f682
6 changed files with 45 additions and 52 deletions

View File

@ -1,16 +1,15 @@
import OS from '../../mios';
import Ctx from '../views/components/context-menu.vue'; import Ctx from '../views/components/context-menu.vue';
export default function(e, menu, opts?) { export default (os: OS) => (e, menu, opts?) => {
const o = opts || {}; const o = opts || {};
const vm = new Ctx({ const vm = os.new(Ctx, {
propsData: { menu,
menu, x: e.pageX - window.pageXOffset,
x: e.pageX - window.pageXOffset, y: e.pageY - window.pageYOffset,
y: e.pageY - window.pageYOffset, });
}
}).$mount();
vm.$once('closed', () => { vm.$once('closed', () => {
if (o.closed) o.closed(); if (o.closed) o.closed();
}); });
document.body.appendChild(vm.$el); document.body.appendChild(vm.$el);
} };

View File

@ -1,16 +1,15 @@
import OS from '../../mios';
import Dialog from '../views/components/dialog.vue'; import Dialog from '../views/components/dialog.vue';
export default function(opts) { export default (os: OS) => opts => {
return new Promise<string>((res, rej) => { return new Promise<string>((res, rej) => {
const o = opts || {}; const o = opts || {};
const d = new Dialog({ const d = os.new(Dialog, {
propsData: { title: o.title,
title: o.title, text: o.text,
text: o.text, modal: o.modal,
modal: o.modal, buttons: o.actions
buttons: o.actions });
}
}).$mount();
d.$once('clicked', id => { d.$once('clicked', id => {
res(id); res(id);
}); });

View File

@ -1,20 +1,19 @@
import OS from '../../mios';
import InputDialog from '../views/components/input-dialog.vue'; import InputDialog from '../views/components/input-dialog.vue';
export default function(opts) { export default (os: OS) => opts => {
return new Promise<string>((res, rej) => { return new Promise<string>((res, rej) => {
const o = opts || {}; const o = opts || {};
const d = new InputDialog({ const d = os.new(InputDialog, {
propsData: { title: o.title,
title: o.title, placeholder: o.placeholder,
placeholder: o.placeholder, default: o.default,
default: o.default, type: o.type || 'text',
type: o.type || 'text', allowEmpty: o.allowEmpty
allowEmpty: o.allowEmpty });
}
}).$mount();
d.$once('done', text => { d.$once('done', text => {
res(text); res(text);
}); });
document.body.appendChild(d.$el); document.body.appendChild(d.$el);
}); });
} };

View File

@ -1,10 +1,9 @@
import OS from '../../mios';
import Notification from '../views/components/ui-notification.vue'; import Notification from '../views/components/ui-notification.vue';
export default function(message) { export default (os: OS) => message => {
const vm = new Notification({ const vm = os.new(Notification, {
propsData: { message
message });
}
}).$mount();
document.body.appendChild(vm.$el); document.body.appendChild(vm.$el);
} };

View File

@ -1,21 +1,18 @@
import OS from '../../mios';
import PostFormWindow from '../views/components/post-form-window.vue'; import PostFormWindow from '../views/components/post-form-window.vue';
import RenoteFormWindow from '../views/components/renote-form-window.vue'; import RenoteFormWindow from '../views/components/renote-form-window.vue';
export default function(opts) { export default (os: OS) => opts => {
const o = opts || {}; const o = opts || {};
if (o.renote) { if (o.renote) {
const vm = new RenoteFormWindow({ const vm = os.new(RenoteFormWindow, {
propsData: { renote: o.renote
renote: o.renote });
}
}).$mount();
document.body.appendChild(vm.$el); document.body.appendChild(vm.$el);
} else { } else {
const vm = new PostFormWindow({ const vm = os.new(PostFormWindow, {
propsData: { reply: o.reply
reply: o.reply });
}
}).$mount();
document.body.appendChild(vm.$el); document.body.appendChild(vm.$el);
} }
} };

View File

@ -69,10 +69,10 @@ init(async (launch) => {
const [, os] = launch(router, os => ({ const [, os] = launch(router, os => ({
chooseDriveFolder: chooseDriveFolder(os), chooseDriveFolder: chooseDriveFolder(os),
chooseDriveFile: chooseDriveFile(os), chooseDriveFile: chooseDriveFile(os),
dialog, dialog: dialog(os),
input, input: input(os),
post, post: post(os),
notify, notify: notify(os),
updateAvatar: updateAvatar(os), updateAvatar: updateAvatar(os),
updateBanner: updateBanner(os) updateBanner: updateBanner(os)
})); }));