2018-02-20 13:58:25 +09:00
|
|
|
<template>
|
2018-02-24 02:46:09 +09:00
|
|
|
<mk-ui>
|
2018-02-20 13:58:25 +09:00
|
|
|
<span slot="header">
|
2018-11-06 01:40:11 +09:00
|
|
|
<template v-if="folder"><span style="margin-right:4px;"><fa :icon="['far', 'folder-open']"/></span>{{ folder.name }}</template>
|
2018-09-19 14:18:34 +09:00
|
|
|
<template v-if="file"><mk-file-type-icon data-icon :type="file.type" style="margin-right:4px;"/>{{ file.name }}</template>
|
2018-11-09 03:44:35 +09:00
|
|
|
<template v-if="!folder && !file"><span style="margin-right:4px;"><fa icon="cloud"/></span>{{ $t('@.drive') }}</template>
|
2018-02-20 13:58:25 +09:00
|
|
|
</span>
|
2018-11-06 01:40:11 +09:00
|
|
|
<template slot="func"><button @click="fn"><fa icon="ellipsis-h"/></button></template>
|
2018-02-20 13:58:25 +09:00
|
|
|
<mk-drive
|
|
|
|
ref="browser"
|
2018-02-22 18:37:47 +09:00
|
|
|
:init-folder="initFolder"
|
|
|
|
:init-file="initFile"
|
|
|
|
:is-naked="true"
|
2018-09-01 12:05:25 +09:00
|
|
|
:top="$store.state.uiHeaderHeight"
|
2018-02-20 13:58:25 +09:00
|
|
|
@begin-fetch="Progress.start()"
|
2018-02-20 14:00:20 +09:00
|
|
|
@fetched-mid="Progress.set(0.5)"
|
2018-02-20 13:58:25 +09:00
|
|
|
@fetched="Progress.done()"
|
|
|
|
@move-root="onMoveRoot"
|
|
|
|
@open-folder="onOpenFolder"
|
|
|
|
@open-file="onOpenFile"
|
|
|
|
/>
|
|
|
|
</mk-ui>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
2018-11-09 03:44:35 +09:00
|
|
|
import i18n from '../../../i18n';
|
2018-02-20 13:58:25 +09:00
|
|
|
import Progress from '../../../common/scripts/loading';
|
|
|
|
|
|
|
|
export default Vue.extend({
|
2018-11-09 03:44:35 +09:00
|
|
|
i18n: i18n(),
|
2018-02-20 13:58:25 +09:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
Progress,
|
|
|
|
folder: null,
|
2018-02-22 18:37:47 +09:00
|
|
|
file: null,
|
|
|
|
initFolder: null,
|
|
|
|
initFile: null
|
2018-02-20 13:58:25 +09:00
|
|
|
};
|
|
|
|
},
|
2018-02-22 18:37:47 +09:00
|
|
|
created() {
|
|
|
|
this.initFolder = this.$route.params.folder;
|
|
|
|
this.initFile = this.$route.params.file;
|
|
|
|
|
|
|
|
window.addEventListener('popstate', this.onPopState);
|
|
|
|
},
|
2018-02-20 13:58:25 +09:00
|
|
|
mounted() {
|
2018-11-09 08:26:32 +09:00
|
|
|
document.title = `${this.$root.instanceName} Drive`;
|
2018-02-20 13:58:25 +09:00
|
|
|
},
|
2018-02-22 18:37:47 +09:00
|
|
|
beforeDestroy() {
|
|
|
|
window.removeEventListener('popstate', this.onPopState);
|
|
|
|
},
|
2018-02-20 13:58:25 +09:00
|
|
|
methods: {
|
2018-02-22 18:37:47 +09:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
},
|
2018-02-20 13:58:25 +09:00
|
|
|
fn() {
|
|
|
|
(this.$refs as any).browser.openContextMenu();
|
|
|
|
},
|
2018-02-22 18:37:47 +09:00
|
|
|
onMoveRoot(silent) {
|
2018-11-09 08:26:32 +09:00
|
|
|
const title = `${this.$root.instanceName} Drive`;
|
2018-02-20 13:58:25 +09:00
|
|
|
|
2018-02-22 18:37:47 +09:00
|
|
|
if (!silent) {
|
|
|
|
// Rewrite URL
|
|
|
|
history.pushState(null, title, '/i/drive');
|
|
|
|
}
|
2018-02-20 13:58:25 +09:00
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
this.file = null;
|
|
|
|
this.folder = null;
|
|
|
|
},
|
|
|
|
onOpenFolder(folder, silent) {
|
2018-11-09 08:26:32 +09:00
|
|
|
const title = `${folder.name} | ${this.$root.instanceName} Drive`;
|
2018-02-20 13:58:25 +09:00
|
|
|
|
|
|
|
if (!silent) {
|
|
|
|
// Rewrite URL
|
2018-09-01 23:12:51 +09:00
|
|
|
history.pushState(null, title, `/i/drive/folder/${folder.id}`);
|
2018-02-20 13:58:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
this.file = null;
|
|
|
|
this.folder = folder;
|
|
|
|
},
|
|
|
|
onOpenFile(file, silent) {
|
2018-11-09 08:26:32 +09:00
|
|
|
const title = `${file.name} | ${this.$root.instanceName} Drive`;
|
2018-02-20 13:58:25 +09:00
|
|
|
|
|
|
|
if (!silent) {
|
|
|
|
// Rewrite URL
|
2018-09-01 23:12:51 +09:00
|
|
|
history.pushState(null, title, `/i/drive/file/${file.id}`);
|
2018-02-20 13:58:25 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
this.file = file;
|
|
|
|
this.folder = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|