Refactor
This commit is contained in:
@@ -1,18 +1,17 @@
|
||||
import OS from '../../mios';
|
||||
import { url } from '../../config';
|
||||
import MkChooseFileFromDriveWindow from '../views/components/choose-file-from-drive-window.vue';
|
||||
|
||||
export default function(opts) {
|
||||
export default (os: OS) => opts => {
|
||||
return new Promise((res, rej) => {
|
||||
const o = opts || {};
|
||||
|
||||
if (document.body.clientWidth > 800) {
|
||||
const w = new MkChooseFileFromDriveWindow({
|
||||
propsData: {
|
||||
title: o.title,
|
||||
multiple: o.multiple,
|
||||
initFolder: o.currentFolder
|
||||
}
|
||||
}).$mount();
|
||||
const w = os.new(MkChooseFileFromDriveWindow, {
|
||||
title: o.title,
|
||||
multiple: o.multiple,
|
||||
initFolder: o.currentFolder
|
||||
});
|
||||
w.$once('selected', file => {
|
||||
res(file);
|
||||
});
|
||||
@@ -27,4 +26,4 @@ export default function(opts) {
|
||||
'height=500, width=800');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import OS from '../../mios';
|
||||
import MkChooseFolderFromDriveWindow from '../views/components/choose-folder-from-drive-window.vue';
|
||||
|
||||
export default function(opts) {
|
||||
export default (os: OS) => opts => {
|
||||
return new Promise((res, rej) => {
|
||||
const o = opts || {};
|
||||
const w = new MkChooseFolderFromDriveWindow({
|
||||
propsData: {
|
||||
title: o.title,
|
||||
initFolder: o.currentFolder
|
||||
}
|
||||
}).$mount();
|
||||
const w = os.new(MkChooseFolderFromDriveWindow, {
|
||||
title: o.title,
|
||||
initFolder: o.currentFolder
|
||||
});
|
||||
w.$once('selected', folder => {
|
||||
res(folder);
|
||||
});
|
||||
document.body.appendChild(w.$el);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -6,17 +6,15 @@ import ProgressDialog from '../views/components/progress-dialog.vue';
|
||||
export default (os: OS) => (cb, file = null) => {
|
||||
const fileSelected = file => {
|
||||
|
||||
const w = new CropWindow({
|
||||
propsData: {
|
||||
image: file,
|
||||
title: 'アバターとして表示する部分を選択',
|
||||
aspectRatio: 1 / 1
|
||||
}
|
||||
}).$mount();
|
||||
const w = os.new(CropWindow, {
|
||||
image: file,
|
||||
title: 'アバターとして表示する部分を選択',
|
||||
aspectRatio: 1 / 1
|
||||
});
|
||||
|
||||
w.$once('cropped', blob => {
|
||||
const data = new FormData();
|
||||
data.append('i', os.i.token);
|
||||
data.append('i', os.store.state.i.token);
|
||||
data.append('file', blob, file.name + '.cropped.png');
|
||||
|
||||
os.api('drive/folders/find', {
|
||||
@@ -42,11 +40,9 @@ export default (os: OS) => (cb, file = null) => {
|
||||
};
|
||||
|
||||
const upload = (data, folder) => {
|
||||
const dialog = new ProgressDialog({
|
||||
propsData: {
|
||||
title: '新しいアバターをアップロードしています'
|
||||
}
|
||||
}).$mount();
|
||||
const dialog = os.new(ProgressDialog, {
|
||||
title: '新しいアバターをアップロードしています'
|
||||
});
|
||||
document.body.appendChild(dialog.$el);
|
||||
|
||||
if (folder) data.append('folderId', folder.id);
|
||||
@@ -70,8 +66,14 @@ export default (os: OS) => (cb, file = null) => {
|
||||
os.api('i/update', {
|
||||
avatarId: file.id
|
||||
}).then(i => {
|
||||
os.i.avatarId = i.avatarId;
|
||||
os.i.avatarUrl = i.avatarUrl;
|
||||
os.store.commit('updateIKeyValue', {
|
||||
key: 'avatarId',
|
||||
value: i.avatarId
|
||||
});
|
||||
os.store.commit('updateIKeyValue', {
|
||||
key: 'avatarUrl',
|
||||
value: i.avatarUrl
|
||||
});
|
||||
|
||||
os.apis.dialog({
|
||||
title: '%fa:info-circle%アバターを更新しました',
|
||||
|
||||
@@ -6,17 +6,15 @@ import ProgressDialog from '../views/components/progress-dialog.vue';
|
||||
export default (os: OS) => {
|
||||
|
||||
const cropImage = file => new Promise((resolve, reject) => {
|
||||
const w = new CropWindow({
|
||||
propsData: {
|
||||
image: file,
|
||||
title: 'バナーとして表示する部分を選択',
|
||||
aspectRatio: 16 / 9
|
||||
}
|
||||
}).$mount();
|
||||
const w = os.new(CropWindow, {
|
||||
image: file,
|
||||
title: 'バナーとして表示する部分を選択',
|
||||
aspectRatio: 16 / 9
|
||||
});
|
||||
|
||||
w.$once('cropped', blob => {
|
||||
const data = new FormData();
|
||||
data.append('i', os.i.token);
|
||||
data.append('i', os.store.state.i.token);
|
||||
data.append('file', blob, file.name + '.cropped.png');
|
||||
|
||||
os.api('drive/folders/find', {
|
||||
@@ -44,11 +42,9 @@ export default (os: OS) => {
|
||||
});
|
||||
|
||||
const upload = (data, folder) => new Promise((resolve, reject) => {
|
||||
const dialog = new ProgressDialog({
|
||||
propsData: {
|
||||
title: '新しいバナーをアップロードしています'
|
||||
}
|
||||
}).$mount();
|
||||
const dialog = os.new(ProgressDialog, {
|
||||
title: '新しいバナーをアップロードしています'
|
||||
});
|
||||
document.body.appendChild(dialog.$el);
|
||||
|
||||
if (folder) data.append('folderId', folder.id);
|
||||
@@ -73,8 +69,14 @@ export default (os: OS) => {
|
||||
return os.api('i/update', {
|
||||
bannerId: file.id
|
||||
}).then(i => {
|
||||
os.i.bannerId = i.bannerId;
|
||||
os.i.bannerUrl = i.bannerUrl;
|
||||
os.store.commit('updateIKeyValue', {
|
||||
key: 'bannerId',
|
||||
value: i.bannerId
|
||||
});
|
||||
os.store.commit('updateIKeyValue', {
|
||||
key: 'bannerUrl',
|
||||
value: i.bannerUrl
|
||||
});
|
||||
|
||||
os.apis.dialog({
|
||||
title: '%fa:info-circle%バナーを更新しました',
|
||||
|
||||
Reference in New Issue
Block a user