This commit is contained in:
syuilo 2018-02-22 18:37:47 +09:00
parent eec84157a3
commit 79698314ad
4 changed files with 38 additions and 15 deletions

View file

@ -55,6 +55,7 @@ init((launch) => {
{ path: '/i/messaging/:username', component: MkMessagingRoom }, { path: '/i/messaging/:username', component: MkMessagingRoom },
{ path: '/i/drive', component: MkDrive }, { path: '/i/drive', component: MkDrive },
{ path: '/i/drive/folder/:folder', component: MkDrive }, { path: '/i/drive/folder/:folder', component: MkDrive },
{ path: '/i/drive/file/:file', component: MkDrive },
{ path: '/selectdrive', component: MkSelectDrive }, { path: '/selectdrive', component: MkSelectDrive },
{ path: '/:user', component: MkUser } { path: '/:user', component: MkUser }
]); ]);

View file

@ -66,8 +66,8 @@
<script lang="ts"> <script lang="ts">
import Vue from 'vue'; import Vue from 'vue';
import EXIF from 'exif-js'; import * as EXIF from 'exif-js';
import hljs from 'highlight.js'; import * as hljs from 'highlight.js';
import gcd from '../../../common/scripts/gcd'; import gcd from '../../../common/scripts/gcd';
export default Vue.extend({ export default Vue.extend({

View file

@ -1,7 +1,7 @@
<template> <template>
<div class="mk-drive"> <div class="mk-drive">
<nav ref="nav"> <nav ref="nav">
<a @click.prevent="goRoot" href="/i/drive">%fa:cloud%%i18n:mobile.tags.mk-drive.drive%</a> <a @click.prevent="goRoot()" href="/i/drive">%fa:cloud%%i18n:mobile.tags.mk-drive.drive%</a>
<template v-for="folder in hierarchyFolders"> <template v-for="folder in hierarchyFolders">
<span :key="folder.id + '>'">%fa:angle-right%</span> <span :key="folder.id + '>'">%fa:angle-right%</span>
<a :key="folder.id" @click.prevent="cd(folder)" :href="`/i/drive/folder/${folder.id}`">{{ folder.name }}</a> <a :key="folder.id" @click.prevent="cd(folder)" :href="`/i/drive/folder/${folder.id}`">{{ folder.name }}</a>
@ -158,7 +158,7 @@ export default Vue.extend({
this.file = null; this.file = null;
if (target == null) { if (target == null) {
this.goRoot(); this.goRoot(silent);
return; return;
} else if (typeof target == 'object') { } else if (typeof target == 'object') {
target = target.id; target = target.id;
@ -235,12 +235,12 @@ export default Vue.extend({
this.addFolder(folder, true); this.addFolder(folder, true);
}, },
goRoot() { goRoot(silent = false) {
if (this.folder || this.file) { if (this.folder || this.file) {
this.file = null; this.file = null;
this.folder = null; this.folder = null;
this.hierarchyFolders = []; this.hierarchyFolders = [];
this.$emit('move-root'); this.$emit('move-root', silent);
this.fetch(); this.fetch();
} }
}, },

View file

@ -2,15 +2,15 @@
<mk-ui :func="fn"> <mk-ui :func="fn">
<span slot="header"> <span slot="header">
<template v-if="folder">%fa:R folder-open%{{ folder.name }}</template> <template v-if="folder">%fa:R folder-open%{{ folder.name }}</template>
<template v-if="file"><mk-file-type-icon class="icon"/>{{ file.name }}</template> <template v-if="file"><mk-file-type-icon class="icon" :type="file.type"/>{{ file.name }}</template>
<template v-else>%fa:cloud%%i18n:mobile.tags.mk-drive-page.drive%</template> <template v-if="!folder && !file">%fa:cloud%%i18n:mobile.tags.mk-drive-page.drive%</template>
</span> </span>
<template slot="funcIcon">%fa:ellipsis-h%</template> <template slot="funcIcon">%fa:ellipsis-h%</template>
<mk-drive <mk-drive
ref="browser" ref="browser"
:init-folder="folder" :init-folder="initFolder"
:init-file="file" :init-file="initFile"
is-naked :is-naked="true"
:top="48" :top="48"
@begin-fetch="Progress.start()" @begin-fetch="Progress.start()"
@fetched-mid="Progress.set(0.5)" @fetched-mid="Progress.set(0.5)"
@ -31,21 +31,43 @@ export default Vue.extend({
return { return {
Progress, Progress,
folder: null, folder: null,
file: null file: null,
initFolder: null,
initFile: null
}; };
}, },
created() {
this.initFolder = this.$route.params.folder;
this.initFile = this.$route.params.file;
window.addEventListener('popstate', this.onPopState);
},
mounted() { mounted() {
document.title = 'Misskey Drive'; document.title = 'Misskey Drive';
}, },
beforeDestroy() {
window.removeEventListener('popstate', this.onPopState);
},
methods: { methods: {
onPopState() {
if (this.$route.params.folder) {
(this.$refs as any).browser.cd(this.$route.params.folder, true);
} else if (this.$route.params.file) {
(this.$refs as any).browser.cf(this.$route.params.file, true);
} else {
(this.$refs as any).browser.goRoot(true);
}
},
fn() { fn() {
(this.$refs as any).browser.openContextMenu(); (this.$refs as any).browser.openContextMenu();
}, },
onMoveRoot() { onMoveRoot(silent) {
const title = 'Misskey Drive'; const title = 'Misskey Drive';
// Rewrite URL if (!silent) {
history.pushState(null, title, '/i/drive'); // Rewrite URL
history.pushState(null, title, '/i/drive');
}
document.title = title; document.title = title;