Refactor client (#3178)
* wip * wip * wip * wip * wip * wip * wip * wip * wip * wip
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import Chooser from '../views/components/drive-file-chooser.vue';
|
||||
|
||||
export default function(opts) {
|
||||
return new Promise((res, rej) => {
|
||||
const o = opts || {};
|
||||
const w = new Chooser({
|
||||
propsData: {
|
||||
title: o.title,
|
||||
multiple: o.multiple,
|
||||
initFolder: o.currentFolder
|
||||
}
|
||||
}).$mount();
|
||||
w.$once('selected', file => {
|
||||
res(file);
|
||||
});
|
||||
document.body.appendChild(w.$el);
|
||||
});
|
||||
}
|
@@ -1,17 +0,0 @@
|
||||
import Chooser from '../views/components/drive-folder-chooser.vue';
|
||||
|
||||
export default function(opts) {
|
||||
return new Promise((res, rej) => {
|
||||
const o = opts || {};
|
||||
const w = new Chooser({
|
||||
propsData: {
|
||||
title: o.title,
|
||||
initFolder: o.currentFolder
|
||||
}
|
||||
}).$mount();
|
||||
w.$once('selected', folder => {
|
||||
res(folder);
|
||||
});
|
||||
document.body.appendChild(w.$el);
|
||||
});
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
import OS from '../../mios';
|
||||
import Dialog from '../views/components/dialog.vue';
|
||||
|
||||
export default (os: OS) => opts => {
|
||||
return new Promise<string>((res, rej) => {
|
||||
const o = opts || {};
|
||||
const d = os.new(Dialog, {
|
||||
title: o.title,
|
||||
text: o.text,
|
||||
modal: o.modal,
|
||||
buttons: o.actions
|
||||
});
|
||||
d.$once('clicked', id => {
|
||||
res(id);
|
||||
});
|
||||
document.body.appendChild(d.$el);
|
||||
});
|
||||
};
|
@@ -1,8 +0,0 @@
|
||||
export default function(opts) {
|
||||
return new Promise<string>((res, rej) => {
|
||||
const x = window.prompt(opts.title);
|
||||
if (x) {
|
||||
res(x);
|
||||
}
|
||||
});
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
export default function(message) {
|
||||
alert(message);
|
||||
}
|
@@ -1,24 +0,0 @@
|
||||
import PostForm from '../views/components/post-form-dialog.vue';
|
||||
|
||||
export default (os) => (opts) => {
|
||||
const o = opts || {};
|
||||
|
||||
document.documentElement.style.overflow = 'hidden';
|
||||
|
||||
function recover() {
|
||||
document.documentElement.style.overflow = 'auto';
|
||||
}
|
||||
|
||||
const vm = new PostForm({
|
||||
parent: os.app,
|
||||
propsData: {
|
||||
reply: o.reply,
|
||||
renote: o.renote
|
||||
}
|
||||
}).$mount();
|
||||
vm.$once('cancel', recover);
|
||||
vm.$once('posted', recover);
|
||||
if (o.cb) vm.$once('closed', o.cb);
|
||||
document.body.appendChild(vm.$el);
|
||||
(vm as any).focus();
|
||||
};
|
@@ -2,6 +2,7 @@
|
||||
* Mobile Client
|
||||
*/
|
||||
|
||||
import Vue from 'vue';
|
||||
import VueRouter from 'vue-router';
|
||||
|
||||
// Style
|
||||
@@ -9,13 +10,6 @@ import './style.styl';
|
||||
|
||||
import init from '../init';
|
||||
|
||||
import chooseDriveFolder from './api/choose-drive-folder';
|
||||
import chooseDriveFile from './api/choose-drive-file';
|
||||
import dialog from './api/dialog';
|
||||
import input from './api/input';
|
||||
import post from './api/post';
|
||||
import notify from './api/notify';
|
||||
|
||||
import MkIndex from './views/pages/index.vue';
|
||||
import MkSignup from './views/pages/signup.vue';
|
||||
import MkUser from './views/pages/user.vue';
|
||||
@@ -39,10 +33,94 @@ import MkTag from './views/pages/tag.vue';
|
||||
import MkShare from './views/pages/share.vue';
|
||||
import MkFollow from '../common/views/pages/follow.vue';
|
||||
|
||||
import PostForm from './views/components/post-form-dialog.vue';
|
||||
import FileChooser from './views/components/drive-file-chooser.vue';
|
||||
import FolderChooser from './views/components/drive-folder-chooser.vue';
|
||||
import Dialog from './views/components/dialog.vue';
|
||||
|
||||
/**
|
||||
* init
|
||||
*/
|
||||
init((launch) => {
|
||||
Vue.mixin({
|
||||
methods: {
|
||||
$post(opts) {
|
||||
const o = opts || {};
|
||||
|
||||
document.documentElement.style.overflow = 'hidden';
|
||||
|
||||
function recover() {
|
||||
document.documentElement.style.overflow = 'auto';
|
||||
}
|
||||
|
||||
const vm = this.$root.new(PostForm, {
|
||||
reply: o.reply,
|
||||
renote: o.renote
|
||||
});
|
||||
|
||||
vm.$once('cancel', recover);
|
||||
vm.$once('posted', recover);
|
||||
if (o.cb) vm.$once('closed', o.cb);
|
||||
(vm as any).focus();
|
||||
},
|
||||
|
||||
$chooseDriveFile(opts) {
|
||||
return new Promise((res, rej) => {
|
||||
const o = opts || {};
|
||||
const vm = this.$root.new(FileChooser, {
|
||||
title: o.title,
|
||||
multiple: o.multiple,
|
||||
initFolder: o.currentFolder
|
||||
});
|
||||
vm.$once('selected', file => {
|
||||
res(file);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
$chooseDriveFolder(opts) {
|
||||
return new Promise((res, rej) => {
|
||||
const o = opts || {};
|
||||
const vm = this.$root.new(FolderChooser, {
|
||||
title: o.title,
|
||||
initFolder: o.currentFolder
|
||||
});
|
||||
vm.$once('selected', folder => {
|
||||
res(folder);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
$input(opts) {
|
||||
return new Promise<string>((res, rej) => {
|
||||
const x = window.prompt(opts.title);
|
||||
if (x) {
|
||||
res(x);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
$dialog(opts) {
|
||||
return new Promise<string>((res, rej) => {
|
||||
const o = opts || {};
|
||||
const d = this.$root.new(Dialog, {
|
||||
title: o.title,
|
||||
text: o.text,
|
||||
modal: o.modal,
|
||||
buttons: o.actions
|
||||
});
|
||||
d.$once('clicked', id => {
|
||||
res(id);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
$notify(message) {
|
||||
alert(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Register directives
|
||||
require('./views/directives');
|
||||
|
||||
@@ -85,12 +163,5 @@ init((launch) => {
|
||||
});
|
||||
|
||||
// Launch the app
|
||||
launch(router, os => ({
|
||||
chooseDriveFolder,
|
||||
chooseDriveFile,
|
||||
dialog: dialog(os),
|
||||
input,
|
||||
post: post(os),
|
||||
notify
|
||||
}));
|
||||
launch(router);
|
||||
}, true);
|
||||
|
@@ -101,7 +101,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
move() {
|
||||
this.$root.apis.chooseDriveFolder().then(folder => {
|
||||
this.$chooseDriveFolder().then(folder => {
|
||||
this.$root.api('drive/files/update', {
|
||||
fileId: this.file.id,
|
||||
folderId: folder == null ? null : folder.id
|
||||
|
@@ -439,7 +439,7 @@ export default Vue.extend({
|
||||
alert(this.$t('root-move-alert'));
|
||||
return;
|
||||
}
|
||||
this.$root.apis.chooseDriveFolder().then(folder => {
|
||||
this.$chooseDriveFolder().then(folder => {
|
||||
this.$root.api('drive/folders/update', {
|
||||
parentId: folder ? folder.id : null,
|
||||
folderId: this.folder.id
|
||||
|
@@ -196,13 +196,13 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
reply() {
|
||||
this.$root.apis.post({
|
||||
this.$post({
|
||||
reply: this.p
|
||||
});
|
||||
},
|
||||
|
||||
renote() {
|
||||
this.$root.apis.post({
|
||||
this.$post({
|
||||
renote: this.p
|
||||
});
|
||||
},
|
||||
|
@@ -220,7 +220,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
chooseFileFromDrive() {
|
||||
this.$root.apis.chooseDriveFile({
|
||||
this.$chooseDriveFile({
|
||||
multiple: true
|
||||
}).then(files => {
|
||||
files.forEach(this.attachMedia);
|
||||
@@ -279,7 +279,7 @@ export default Vue.extend({
|
||||
},
|
||||
|
||||
addVisibleUser() {
|
||||
this.$root.apis.input({
|
||||
this.$input({
|
||||
title: this.$t('username-prompt')
|
||||
}).then(acct => {
|
||||
if (acct.startsWith('@')) acct = acct.substr(1);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
<button class="nav" @click="$parent.isDrawerOpening = true"><fa icon="bars"/></button>
|
||||
<i v-if="hasUnreadNotification || hasUnreadMessagingMessage || hasGameInvitation" class="circle"><fa icon="circle"/></i>
|
||||
<h1>
|
||||
<slot>{{ os.instanceName }}</slot>
|
||||
<slot>{{ $root.instanceName }}</slot>
|
||||
</h1>
|
||||
<slot name="func"></slot>
|
||||
</div>
|
||||
|
@@ -139,7 +139,7 @@ export default Vue.extend({
|
||||
|
||||
methods: {
|
||||
fn() {
|
||||
this.$root.apis.post();
|
||||
this.$post();
|
||||
},
|
||||
|
||||
saveSrc() {
|
||||
|
@@ -339,16 +339,16 @@ export default Vue.extend({
|
||||
|
||||
checkForUpdate() {
|
||||
this.checkingForUpdate = true;
|
||||
checkForUpdate((this as any).os, true, true).then(newer => {
|
||||
checkForUpdate(this.$root, true, true).then(newer => {
|
||||
this.checkingForUpdate = false;
|
||||
this.latestVersion = newer;
|
||||
if (newer == null) {
|
||||
this.$root.apis.dialog({
|
||||
this.$dialog({
|
||||
title: this.$t('no-updates'),
|
||||
text: this.$t('no-updates-desc')
|
||||
});
|
||||
} else {
|
||||
this.$root.apis.dialog({
|
||||
this.$dialog({
|
||||
title: this.$t('update-available'),
|
||||
text: this.$t('update-available-desc')
|
||||
});
|
||||
|
@@ -38,7 +38,7 @@ export default Vue.extend({
|
||||
},
|
||||
methods: {
|
||||
fn() {
|
||||
this.$root.apis.input({
|
||||
this.$input({
|
||||
title: this.$t('enter-list-name'),
|
||||
}).then(async title => {
|
||||
const list = await this.$root.api('users/lists/create', {
|
||||
|
Reference in New Issue
Block a user