From 99b34993640eb91a591faa4bccf7d7b6f176ad97 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 18 Feb 2018 12:35:18 +0900 Subject: [PATCH] wip --- .../views/components/messaging-form.vue | 2 +- .../views/components/messaging-message.vue | 4 +- .../views/components/messaging-room.vue | 10 +- .../app/common/views/components/messaging.vue | 12 +- src/web/app/common/views/components/poll.vue | 2 +- .../app/common/views/components/post-menu.vue | 2 +- .../views/components/reaction-picker.vue | 2 +- .../app/common/views/components/signin.vue | 4 +- .../app/common/views/components/signup.vue | 6 +- .../views/components/stream-indicator.vue | 12 +- .../app/common/views/components/uploader.vue | 2 +- .../views/components/widgets/photo-stream.vue | 8 +- .../views/components/widgets/slideshow.vue | 4 +- .../desktop/-tags/drive/browser-window.tag | 60 -------- .../desktop/-tags/drive/file-contextmenu.tag | 99 ------------ .../-tags/drive/folder-contextmenu.tag | 63 -------- src/web/app/desktop/api/choose-drive-file.ts | 18 +++ .../app/desktop/api/choose-drive-folder.ts | 8 +- src/web/app/desktop/api/contextmenu.ts | 16 ++ src/web/app/desktop/api/dialog.ts | 19 +++ src/web/app/desktop/api/input.ts | 19 +++ src/web/app/desktop/script.ts | 8 +- .../desktop/views/components/2fa-setting.vue | 10 +- .../desktop/views/components/api-setting.vue | 4 +- .../views/components/context-menu-menu.vue | 113 ++++++++++++++ .../desktop/views/components/context-menu.vue | 74 +++++++++ .../desktop/views/components/contextmenu.vue | 142 ----------------- .../app/desktop/views/components/dialog.vue | 15 +- .../views/components/drive-contextmenu.vue | 46 ------ .../desktop/views/components/drive-file.vue | 123 ++++++++++++--- .../desktop/views/components/drive-folder.vue | 93 ++++++++--- .../views/components/drive-nav-folder.vue | 4 +- .../desktop/views/components/drive-window.vue | 53 +++++++ .../app/desktop/views/components/drive.vue | 145 ++++++++++++------ .../views/components/follow-button.vue | 10 +- .../views/components/friends-maker.vue | 2 +- src/web/app/desktop/views/components/home.vue | 26 ++-- src/web/app/desktop/views/components/index.ts | 8 + .../desktop/views/components/input-dialog.vue | 10 +- .../views/components/messaging-window.vue | 1 - .../desktop/views/components/mute-setting.vue | 2 +- .../views/components/notifications.vue | 10 +- .../views/components/password-setting.vue | 2 +- .../views/components/post-detail-sub.vue | 2 +- .../desktop/views/components/post-detail.vue | 6 +- .../desktop/views/components/post-form.vue | 18 +-- .../desktop/views/components/posts-post.vue | 22 +-- .../views/components/profile-setting.vue | 14 +- .../desktop/views/components/repost-form.vue | 2 +- .../views/components/sub-post-content.vue | 2 +- .../app/desktop/views/components/timeline.vue | 12 +- .../views/components/ui-header-account.vue | 6 +- .../views/components/ui-header-nav.vue | 14 +- .../components/ui-header-notifications.vue | 12 +- .../desktop/views/components/ui-header.vue | 6 +- src/web/app/desktop/views/components/ui.vue | 2 +- .../views/components/user-followers.vue | 2 +- .../views/components/user-following.vue | 2 +- .../desktop/views/components/user-preview.vue | 4 +- .../views/components/user-timeline.vue | 4 +- .../desktop/views/components/users-list.vue | 2 +- .../app/desktop/views/components/window.vue | 6 +- src/web/app/desktop/views/pages/home.vue | 8 +- src/web/app/desktop/views/pages/index.vue | 2 +- .../desktop/views/pages/messaging-room.vue | 2 +- src/web/app/desktop/views/pages/post.vue | 2 +- src/web/app/desktop/views/pages/search.vue | 4 +- .../pages/user/user-followers-you-know.vue | 2 +- .../desktop/views/pages/user/user-friends.vue | 2 +- .../desktop/views/pages/user/user-header.vue | 4 +- .../desktop/views/pages/user/user-home.vue | 2 +- .../desktop/views/pages/user/user-photos.vue | 2 +- .../desktop/views/pages/user/user-profile.vue | 10 +- src/web/app/desktop/views/pages/user/user.vue | 2 +- src/web/app/init.ts | 49 +++--- src/web/app/mobile/views/components/drive.vue | 26 ++-- .../mobile/views/components/follow-button.vue | 10 +- .../mobile/views/components/friends-maker.vue | 2 +- .../mobile/views/components/notifications.vue | 10 +- .../mobile/views/components/post-detail.vue | 6 +- .../mobile/views/components/posts-post.vue | 12 +- .../views/components/sub-post-content.vue | 2 +- .../app/mobile/views/components/timeline.vue | 12 +- .../app/mobile/views/components/ui-header.vue | 14 +- .../app/mobile/views/components/ui-nav.vue | 16 +- src/web/app/mobile/views/components/ui.vue | 12 +- .../views/components/user-followers.vue | 2 +- .../views/components/user-following.vue | 2 +- .../mobile/views/components/user-timeline.vue | 2 +- .../mobile/views/components/users-list.vue | 2 +- src/web/app/mobile/views/pages/followers.vue | 2 +- src/web/app/mobile/views/pages/following.vue | 2 +- src/web/app/mobile/views/pages/home.vue | 8 +- .../app/mobile/views/pages/notification.vue | 2 +- src/web/app/mobile/views/pages/post.vue | 2 +- src/web/app/mobile/views/pages/search.vue | 4 +- src/web/app/mobile/views/pages/user.vue | 4 +- .../views/pages/user/followers-you-know.vue | 2 +- .../mobile/views/pages/user/home-activity.vue | 2 +- .../mobile/views/pages/user/home-friends.vue | 2 +- .../mobile/views/pages/user/home-photos.vue | 2 +- .../mobile/views/pages/user/home-posts.vue | 2 +- src/web/app/mobile/views/pages/user/home.vue | 2 +- 103 files changed, 878 insertions(+), 790 deletions(-) delete mode 100644 src/web/app/desktop/-tags/drive/browser-window.tag delete mode 100644 src/web/app/desktop/-tags/drive/file-contextmenu.tag delete mode 100644 src/web/app/desktop/-tags/drive/folder-contextmenu.tag create mode 100644 src/web/app/desktop/api/choose-drive-file.ts create mode 100644 src/web/app/desktop/api/contextmenu.ts create mode 100644 src/web/app/desktop/api/dialog.ts create mode 100644 src/web/app/desktop/api/input.ts create mode 100644 src/web/app/desktop/views/components/context-menu-menu.vue create mode 100644 src/web/app/desktop/views/components/context-menu.vue delete mode 100644 src/web/app/desktop/views/components/contextmenu.vue delete mode 100644 src/web/app/desktop/views/components/drive-contextmenu.vue create mode 100644 src/web/app/desktop/views/components/drive-window.vue diff --git a/src/web/app/common/views/components/messaging-form.vue b/src/web/app/common/views/components/messaging-form.vue index bf4dd17ba..18d45790e 100644 --- a/src/web/app/common/views/components/messaging-form.vue +++ b/src/web/app/common/views/components/messaging-form.vue @@ -62,7 +62,7 @@ export default Vue.extend({ send() { this.sending = true; - this.$root.$data.os.api('messaging/messages/create', { + (this as any).api('messaging/messages/create', { user_id: this.user.id, text: this.text }).then(message => { diff --git a/src/web/app/common/views/components/messaging-message.vue b/src/web/app/common/views/components/messaging-message.vue index b1afe7a69..6f44332af 100644 --- a/src/web/app/common/views/components/messaging-message.vue +++ b/src/web/app/common/views/components/messaging-message.vue @@ -8,7 +8,7 @@

%i18n:common.tags.mk-messaging-message.is-read%

- +
image
@@ -30,7 +30,7 @@ export default Vue.extend({ props: ['message'], computed: { isMe(): boolean { - return this.message.user_id == this.$root.$data.os.i.id; + return this.message.user_id == (this as any).os.i.id; }, urls(): string[] { if (this.message.ast) { diff --git a/src/web/app/common/views/components/messaging-room.vue b/src/web/app/common/views/components/messaging-room.vue index 838e1e265..978610d7f 100644 --- a/src/web/app/common/views/components/messaging-room.vue +++ b/src/web/app/common/views/components/messaging-room.vue @@ -48,7 +48,7 @@ export default Vue.extend({ }, mounted() { - this.connection = new MessagingStreamConnection(this.$root.$data.os.i, this.user.id); + this.connection = new MessagingStreamConnection((this as any).os.i, this.user.id); this.connection.on('message', this.onMessage); this.connection.on('read', this.onRead); @@ -72,7 +72,7 @@ export default Vue.extend({ return new Promise((resolve, reject) => { const max = this.existMoreMessages ? 20 : 10; - this.$root.$data.os.api('messaging/messages', { + (this as any).api('messaging/messages', { user_id: this.user.id, limit: max + 1, until_id: this.existMoreMessages ? this.messages[0].id : undefined @@ -99,7 +99,7 @@ export default Vue.extend({ const isBottom = this.isBottom(); this.messages.push(message); - if (message.user_id != this.$root.$data.os.i.id && !document.hidden) { + if (message.user_id != (this as any).os.i.id && !document.hidden) { this.connection.send({ type: 'read', id: message.id @@ -109,7 +109,7 @@ export default Vue.extend({ if (isBottom) { // Scroll to bottom this.scrollToBottom(); - } else if (message.user_id != this.$root.$data.os.i.id) { + } else if (message.user_id != (this as any).os.i.id) { // Notify this.notify('%i18n:common.tags.mk-messaging-room.new-message%'); } @@ -157,7 +157,7 @@ export default Vue.extend({ onVisibilitychange() { if (document.hidden) return; this.messages.forEach(message => { - if (message.user_id !== this.$root.$data.os.i.id && !message.is_read) { + if (message.user_id !== (this as any).os.i.id && !message.is_read) { this.connection.send({ type: 'read', id: message.id diff --git a/src/web/app/common/views/components/messaging.vue b/src/web/app/common/views/components/messaging.vue index f45f99b53..1b56382b0 100644 --- a/src/web/app/common/views/components/messaging.vue +++ b/src/web/app/common/views/components/messaging.vue @@ -71,13 +71,13 @@ export default Vue.extend({ }; }, mounted() { - this.connection = this.$root.$data.os.streams.messagingIndexStream.getConnection(); - this.connectionId = this.$root.$data.os.streams.messagingIndexStream.use(); + this.connection = (this as any).os.streams.messagingIndexStream.getConnection(); + this.connectionId = (this as any).os.streams.messagingIndexStream.use(); this.connection.on('message', this.onMessage); this.connection.on('read', this.onRead); - this.$root.$data.os.api('messaging/history').then(messages => { + (this as any).api('messaging/history').then(messages => { this.fetching = false; this.messages = messages; }); @@ -85,11 +85,11 @@ export default Vue.extend({ beforeDestroy() { this.connection.off('message', this.onMessage); this.connection.off('read', this.onRead); - this.$root.$data.os.stream.dispose(this.connectionId); + (this as any).os.stream.dispose(this.connectionId); }, methods: { isMe(message) { - return message.user_id == this.$root.$data.os.i.id; + return message.user_id == (this as any).os.i.id; }, onMessage(message) { this.messages = this.messages.filter(m => !( @@ -109,7 +109,7 @@ export default Vue.extend({ this.result = []; return; } - this.$root.$data.os.api('users/search', { + (this as any).api('users/search', { query: this.q, max: 5 }).then(users => { diff --git a/src/web/app/common/views/components/poll.vue b/src/web/app/common/views/components/poll.vue index 19ce557e7..d06c019db 100644 --- a/src/web/app/common/views/components/poll.vue +++ b/src/web/app/common/views/components/poll.vue @@ -47,7 +47,7 @@ }, vote(id) { if (this.poll.choices.some(c => c.is_voted)) return; - this.$root.$data.os.api('posts/polls/vote', { + (this as any).api('posts/polls/vote', { post_id: this.post.id, choice: id }).then(() => { diff --git a/src/web/app/common/views/components/post-menu.vue b/src/web/app/common/views/components/post-menu.vue index 7a33360f6..e14d67fc8 100644 --- a/src/web/app/common/views/components/post-menu.vue +++ b/src/web/app/common/views/components/post-menu.vue @@ -48,7 +48,7 @@ export default Vue.extend({ }, methods: { pin() { - this.$root.$data.os.api('i/pin', { + (this as any).api('i/pin', { post_id: this.post.id }).then(() => { this.$destroy(); diff --git a/src/web/app/common/views/components/reaction-picker.vue b/src/web/app/common/views/components/reaction-picker.vue index 0446d7b18..f3731cd63 100644 --- a/src/web/app/common/views/components/reaction-picker.vue +++ b/src/web/app/common/views/components/reaction-picker.vue @@ -68,7 +68,7 @@ export default Vue.extend({ }, methods: { react(reaction) { - this.$root.$data.os.api('posts/reactions/create', { + (this as any).api('posts/reactions/create', { post_id: this.post.id, reaction: reaction }).then(() => { diff --git a/src/web/app/common/views/components/signin.vue b/src/web/app/common/views/components/signin.vue index 989c01705..31243e99a 100644 --- a/src/web/app/common/views/components/signin.vue +++ b/src/web/app/common/views/components/signin.vue @@ -28,7 +28,7 @@ export default Vue.extend({ }, methods: { onUsernameChange() { - this.$root.$data.os.api('users/show', { + (this as any).api('users/show', { username: this.username }).then(user => { this.user = user; @@ -37,7 +37,7 @@ export default Vue.extend({ onSubmit() { this.signing = true; - this.$root.$data.os.api('signin', { + (this as any).api('signin', { username: this.username, password: this.password, token: this.user && this.user.two_factor_enabled ? this.token : undefined diff --git a/src/web/app/common/views/components/signup.vue b/src/web/app/common/views/components/signup.vue index 34d17ef0e..1fdc49a18 100644 --- a/src/web/app/common/views/components/signup.vue +++ b/src/web/app/common/views/components/signup.vue @@ -88,7 +88,7 @@ export default Vue.extend({ this.usernameState = 'wait'; - this.$root.$data.os.api('username/available', { + (this as any).api('username/available', { username: this.username }).then(result => { this.usernameState = result.available ? 'ok' : 'unavailable'; @@ -115,12 +115,12 @@ export default Vue.extend({ this.passwordRetypeState = this.password == this.retypedPassword ? 'match' : 'not-match'; }, onSubmit() { - this.$root.$data.os.api('signup', { + (this as any).api('signup', { username: this.username, password: this.password, 'g-recaptcha-response': (window as any).grecaptcha.getResponse() }).then(() => { - this.$root.$data.os.api('signin', { + (this as any).api('signin', { username: this.username, password: this.password }).then(() => { diff --git a/src/web/app/common/views/components/stream-indicator.vue b/src/web/app/common/views/components/stream-indicator.vue index 00bd58c1f..c1c0672e4 100644 --- a/src/web/app/common/views/components/stream-indicator.vue +++ b/src/web/app/common/views/components/stream-indicator.vue @@ -26,10 +26,10 @@ export default Vue.extend({ }; }, created() { - this.stream = this.$root.$data.os.stream.borrow(); + this.stream = (this as any).os.stream.borrow(); - this.$root.$data.os.stream.on('connected', this.onConnected); - this.$root.$data.os.stream.on('disconnected', this.onDisconnected); + (this as any).os.stream.on('connected', this.onConnected); + (this as any).os.stream.on('disconnected', this.onDisconnected); this.$nextTick(() => { if (this.stream.state == 'connected') { @@ -38,12 +38,12 @@ export default Vue.extend({ }); }, beforeDestroy() { - this.$root.$data.os.stream.off('connected', this.onConnected); - this.$root.$data.os.stream.off('disconnected', this.onDisconnected); + (this as any).os.stream.off('connected', this.onConnected); + (this as any).os.stream.off('disconnected', this.onDisconnected); }, methods: { onConnected() { - this.stream = this.$root.$data.os.stream.borrow(); + this.stream = (this as any).os.stream.borrow(); setTimeout(() => { anime({ diff --git a/src/web/app/common/views/components/uploader.vue b/src/web/app/common/views/components/uploader.vue index 21f92caab..6367b6997 100644 --- a/src/web/app/common/views/components/uploader.vue +++ b/src/web/app/common/views/components/uploader.vue @@ -50,7 +50,7 @@ export default Vue.extend({ reader.readAsDataURL(file); const data = new FormData(); - data.append('i', this.$root.$data.os.i.token); + data.append('i', (this as any).os.i.token); data.append('file', file); if (folder) data.append('folder_id', folder); diff --git a/src/web/app/common/views/components/widgets/photo-stream.vue b/src/web/app/common/views/components/widgets/photo-stream.vue index afbdc2162..4d6b66069 100644 --- a/src/web/app/common/views/components/widgets/photo-stream.vue +++ b/src/web/app/common/views/components/widgets/photo-stream.vue @@ -26,12 +26,12 @@ export default define({ }; }, mounted() { - this.connection = this.$root.$data.os.stream.getConnection(); - this.connectionId = this.$root.$data.os.stream.use(); + this.connection = (this as any).os.stream.getConnection(); + this.connectionId = (this as any).os.stream.use(); this.connection.on('drive_file_created', this.onDriveFileCreated); - this.$root.$data.os.api('drive/stream', { + (this as any).api('drive/stream', { type: 'image/*', limit: 9 }).then(images => { @@ -41,7 +41,7 @@ export default define({ }, beforeDestroy() { this.connection.off('drive_file_created', this.onDriveFileCreated); - this.$root.$data.os.stream.dispose(this.connectionId); + (this as any).os.stream.dispose(this.connectionId); }, methods: { onDriveFileCreated(file) { diff --git a/src/web/app/common/views/components/widgets/slideshow.vue b/src/web/app/common/views/components/widgets/slideshow.vue index c24e3003c..a200aa061 100644 --- a/src/web/app/common/views/components/widgets/slideshow.vue +++ b/src/web/app/common/views/components/widgets/slideshow.vue @@ -89,7 +89,7 @@ export default define({ fetch() { this.fetching = true; - this.$root.$data.os.api('drive/files', { + (this as any).api('drive/files', { folder_id: this.props.folder, type: 'image/*', limit: 100 @@ -102,7 +102,7 @@ export default define({ }); }, choose() { - this.$root.$data.api.chooseDriveFolder().then(folder => { + (this as any).apis.chooseDriveFolder().then(folder => { this.props.folder = folder ? folder.id : null; this.fetch(); }); diff --git a/src/web/app/desktop/-tags/drive/browser-window.tag b/src/web/app/desktop/-tags/drive/browser-window.tag deleted file mode 100644 index c9c765252..000000000 --- a/src/web/app/desktop/-tags/drive/browser-window.tag +++ /dev/null @@ -1,60 +0,0 @@ - - - -

{ parent.usage.toFixed(1) }% %i18n:desktop.tags.mk-drive-browser-window.used%

- %fa:cloud%%i18n:desktop.tags.mk-drive-browser-window.drive% -
- - - -
- - -
diff --git a/src/web/app/desktop/-tags/drive/file-contextmenu.tag b/src/web/app/desktop/-tags/drive/file-contextmenu.tag deleted file mode 100644 index 8776fcc02..000000000 --- a/src/web/app/desktop/-tags/drive/file-contextmenu.tag +++ /dev/null @@ -1,99 +0,0 @@ - - -
    -
  • -

    %fa:i-cursor%%i18n:desktop.tags.mk-drive-browser-file-contextmenu.rename%

    -
  • -
  • -

    %fa:link%%i18n:desktop.tags.mk-drive-browser-file-contextmenu.copy-url%

    -
  • -
  • %fa:download%%i18n:desktop.tags.mk-drive-browser-file-contextmenu.download%
  • -
  • -
  • -

    %fa:R trash-alt%%i18n:common.delete%

    -
  • -
  • -
  • -

    %i18n:desktop.tags.mk-drive-browser-file-contextmenu.else-files%%fa:caret-right%

    -
      -
    • -

      %i18n:desktop.tags.mk-drive-browser-file-contextmenu.set-as-avatar%

      -
    • -
    • -

      %i18n:desktop.tags.mk-drive-browser-file-contextmenu.set-as-banner%

      -
    • -
    -
  • -
  • -

    %i18n:desktop.tags.mk-drive-browser-file-contextmenu.open-in-app%...%fa:caret-right%

    -
      -
    • -

      %i18n:desktop.tags.mk-drive-browser-file-contextmenu.add-app%...

      -
    • -
    -
  • -
-
- -
diff --git a/src/web/app/desktop/-tags/drive/folder-contextmenu.tag b/src/web/app/desktop/-tags/drive/folder-contextmenu.tag deleted file mode 100644 index a0146410f..000000000 --- a/src/web/app/desktop/-tags/drive/folder-contextmenu.tag +++ /dev/null @@ -1,63 +0,0 @@ - - -
    -
  • -

    %fa:arrow-right%%i18n:desktop.tags.mk-drive-browser-folder-contextmenu.move-to-this-folder%

    -
  • -
  • -

    %fa:R window-restore%%i18n:desktop.tags.mk-drive-browser-folder-contextmenu.show-in-new-window%

    -
  • -
  • -
  • -

    %fa:i-cursor%%i18n:desktop.tags.mk-drive-browser-folder-contextmenu.rename%

    -
  • -
  • -
  • -

    %fa:R trash-alt%%i18n:common.delete%

    -
  • -
-
- -
diff --git a/src/web/app/desktop/api/choose-drive-file.ts b/src/web/app/desktop/api/choose-drive-file.ts new file mode 100644 index 000000000..e04844171 --- /dev/null +++ b/src/web/app/desktop/api/choose-drive-file.ts @@ -0,0 +1,18 @@ +import MkChooseFileFromDriveWindow from '../views/components/choose-file-from-drive-window.vue'; + +export default function(opts) { + return new Promise((res, rej) => { + const o = opts || {}; + const w = new MkChooseFileFromDriveWindow({ + propsData: { + title: o.title, + multiple: o.multiple, + initFolder: o.currentFolder + } + }).$mount(); + w.$once('selected', file => { + res(file); + }); + document.body.appendChild(w.$el); + }); +} diff --git a/src/web/app/desktop/api/choose-drive-folder.ts b/src/web/app/desktop/api/choose-drive-folder.ts index a5116f7bc..9b33a20d9 100644 --- a/src/web/app/desktop/api/choose-drive-folder.ts +++ b/src/web/app/desktop/api/choose-drive-folder.ts @@ -1,12 +1,12 @@ -import MkChooseFolderFromDriveWindow from '../../../common/views/components/choose-folder-from-drive-window.vue'; +import MkChooseFolderFromDriveWindow from '../views/components/choose-folder-from-drive-window.vue'; -export default function(this: any, opts) { +export default function(opts) { return new Promise((res, rej) => { const o = opts || {}; const w = new MkChooseFolderFromDriveWindow({ - parent: this, propsData: { - title: o.title + title: o.title, + initFolder: o.currentFolder } }).$mount(); w.$once('selected', folder => { diff --git a/src/web/app/desktop/api/contextmenu.ts b/src/web/app/desktop/api/contextmenu.ts new file mode 100644 index 000000000..b70d7122d --- /dev/null +++ b/src/web/app/desktop/api/contextmenu.ts @@ -0,0 +1,16 @@ +import Ctx from '../views/components/context-menu.vue'; + +export default function(e, menu, opts?) { + const o = opts || {}; + const vm = new Ctx({ + propsData: { + menu, + x: e.pageX - window.pageXOffset, + y: e.pageY - window.pageYOffset, + } + }).$mount(); + vm.$once('closed', () => { + if (o.closed) o.closed(); + }); + document.body.appendChild(vm.$el); +} diff --git a/src/web/app/desktop/api/dialog.ts b/src/web/app/desktop/api/dialog.ts new file mode 100644 index 000000000..07935485b --- /dev/null +++ b/src/web/app/desktop/api/dialog.ts @@ -0,0 +1,19 @@ +import Dialog from '../views/components/dialog.vue'; + +export default function(opts) { + return new Promise((res, rej) => { + const o = opts || {}; + const d = new Dialog({ + propsData: { + title: o.title, + text: o.text, + modal: o.modal, + buttons: o.actions + } + }).$mount(); + d.$once('clicked', id => { + res(id); + }); + document.body.appendChild(d.$el); + }); +} diff --git a/src/web/app/desktop/api/input.ts b/src/web/app/desktop/api/input.ts new file mode 100644 index 000000000..a5ab07138 --- /dev/null +++ b/src/web/app/desktop/api/input.ts @@ -0,0 +1,19 @@ +import InputDialog from '../views/components/input-dialog.vue'; + +export default function(opts) { + return new Promise((res, rej) => { + const o = opts || {}; + const d = new InputDialog({ + propsData: { + title: o.title, + placeholder: o.placeholder, + default: o.default, + type: o.type || 'text' + } + }).$mount(); + d.$once('done', text => { + res(text); + }); + document.body.appendChild(d.$el); + }); +} diff --git a/src/web/app/desktop/script.ts b/src/web/app/desktop/script.ts index cd894170e..cb7a53fb2 100644 --- a/src/web/app/desktop/script.ts +++ b/src/web/app/desktop/script.ts @@ -11,6 +11,9 @@ import HomeStreamManager from '../common/scripts/streaming/home-stream-manager'; import composeNotification from '../common/scripts/compose-notification'; 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 MkIndex from './views/pages/index.vue'; @@ -30,7 +33,10 @@ init(async (launch) => { require('./views/components'); const app = launch({ - chooseDriveFolder + chooseDriveFolder, + chooseDriveFile, + dialog, + input }); /** diff --git a/src/web/app/desktop/views/components/2fa-setting.vue b/src/web/app/desktop/views/components/2fa-setting.vue index 146d707e1..8271cbbf3 100644 --- a/src/web/app/desktop/views/components/2fa-setting.vue +++ b/src/web/app/desktop/views/components/2fa-setting.vue @@ -36,7 +36,7 @@ export default Vue.extend({ methods: { register() { passwordDialog('%i18n:desktop.tags.mk-2fa-setting.enter-password%', password => { - this.$root.$data.os.api('i/2fa/register', { + (this as any).api('i/2fa/register', { password: password }).then(data => { this.data = data; @@ -46,21 +46,21 @@ export default Vue.extend({ unregister() { passwordDialog('%i18n:desktop.tags.mk-2fa-setting.enter-password%', password => { - this.$root.$data.os.api('i/2fa/unregister', { + (this as any).api('i/2fa/unregister', { password: password }).then(() => { notify('%i18n:desktop.tags.mk-2fa-setting.unregistered%'); - this.$root.$data.os.i.two_factor_enabled = false; + (this as any).os.i.two_factor_enabled = false; }); }); }, submit() { - this.$root.$data.os.api('i/2fa/done', { + (this as any).api('i/2fa/done', { token: this.token }).then(() => { notify('%i18n:desktop.tags.mk-2fa-setting.success%'); - this.$root.$data.os.i.two_factor_enabled = true; + (this as any).os.i.two_factor_enabled = true; }).catch(() => { notify('%i18n:desktop.tags.mk-2fa-setting.failed%'); }); diff --git a/src/web/app/desktop/views/components/api-setting.vue b/src/web/app/desktop/views/components/api-setting.vue index 78429064b..08c5a0c51 100644 --- a/src/web/app/desktop/views/components/api-setting.vue +++ b/src/web/app/desktop/views/components/api-setting.vue @@ -1,6 +1,6 @@ @@ -28,10 +28,12 @@ + + + diff --git a/src/web/app/desktop/views/components/drive.vue b/src/web/app/desktop/views/components/drive.vue index 5d398dab9..2b33265e5 100644 --- a/src/web/app/desktop/views/components/drive.vue +++ b/src/web/app/desktop/views/components/drive.vue @@ -2,17 +2,17 @@