2018-02-20 04:58:25 +00:00
|
|
|
<template>
|
2018-02-23 17:46:09 +00:00
|
|
|
<mk-ui>
|
2018-02-20 04:58:25 +00:00
|
|
|
<span slot="header">
|
|
|
|
<template v-if="folder">%fa:R folder-open%{{ folder.name }}</template>
|
2018-03-03 02:27:05 +00:00
|
|
|
<template v-if="file"><mk-file-type-icon data-icon :type="file.type"/>{{ file.name }}</template>
|
2018-04-14 16:04:40 +00:00
|
|
|
<template v-if="!folder && !file">%fa:cloud%%i18n:@drive%</template>
|
2018-02-20 04:58:25 +00:00
|
|
|
</span>
|
2018-02-23 17:46:09 +00:00
|
|
|
<template slot="func"><button @click="fn">%fa:ellipsis-h%</button></template>
|
2018-02-20 04:58:25 +00:00
|
|
|
<mk-drive
|
|
|
|
ref="browser"
|
2018-02-22 09:37:47 +00:00
|
|
|
:init-folder="initFolder"
|
|
|
|
:init-file="initFile"
|
|
|
|
:is-naked="true"
|
2018-02-20 04:58:25 +00:00
|
|
|
:top="48"
|
|
|
|
@begin-fetch="Progress.start()"
|
2018-02-20 05:00:20 +00:00
|
|
|
@fetched-mid="Progress.set(0.5)"
|
2018-02-20 04:58:25 +00:00
|
|
|
@fetched="Progress.done()"
|
|
|
|
@move-root="onMoveRoot"
|
|
|
|
@open-folder="onOpenFolder"
|
|
|
|
@open-file="onOpenFile"
|
|
|
|
/>
|
|
|
|
</mk-ui>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import Vue from 'vue';
|
|
|
|
import Progress from '../../../common/scripts/loading';
|
2018-08-07 04:25:50 +00:00
|
|
|
import * as config from '../../../config';
|
2018-02-20 04:58:25 +00:00
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
Progress,
|
|
|
|
folder: null,
|
2018-02-22 09:37:47 +00:00
|
|
|
file: null,
|
|
|
|
initFolder: null,
|
|
|
|
initFile: null
|
2018-02-20 04:58:25 +00:00
|
|
|
};
|
|
|
|
},
|
2018-02-22 09:37:47 +00:00
|
|
|
created() {
|
|
|
|
this.initFolder = this.$route.params.folder;
|
|
|
|
this.initFile = this.$route.params.file;
|
|
|
|
|
|
|
|
window.addEventListener('popstate', this.onPopState);
|
|
|
|
},
|
2018-02-20 04:58:25 +00:00
|
|
|
mounted() {
|
2018-08-07 04:25:50 +00:00
|
|
|
document.title = `${config.name} Drive`;
|
2018-02-22 21:17:10 +00:00
|
|
|
document.documentElement.style.background = '#fff';
|
2018-02-20 04:58:25 +00:00
|
|
|
},
|
2018-02-22 09:37:47 +00:00
|
|
|
beforeDestroy() {
|
|
|
|
window.removeEventListener('popstate', this.onPopState);
|
|
|
|
},
|
2018-02-20 04:58:25 +00:00
|
|
|
methods: {
|
2018-02-22 09:37:47 +00: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 04:58:25 +00:00
|
|
|
fn() {
|
|
|
|
(this.$refs as any).browser.openContextMenu();
|
|
|
|
},
|
2018-02-22 09:37:47 +00:00
|
|
|
onMoveRoot(silent) {
|
2018-08-07 04:25:50 +00:00
|
|
|
const title = `${config.name} Drive`;
|
2018-02-20 04:58:25 +00:00
|
|
|
|
2018-02-22 09:37:47 +00:00
|
|
|
if (!silent) {
|
|
|
|
// Rewrite URL
|
|
|
|
history.pushState(null, title, '/i/drive');
|
|
|
|
}
|
2018-02-20 04:58:25 +00:00
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
this.file = null;
|
|
|
|
this.folder = null;
|
|
|
|
},
|
|
|
|
onOpenFolder(folder, silent) {
|
2018-08-07 04:25:50 +00:00
|
|
|
const title = `${folder.name} | ${config.name} Drive`;
|
2018-02-20 04:58:25 +00:00
|
|
|
|
|
|
|
if (!silent) {
|
|
|
|
// Rewrite URL
|
|
|
|
history.pushState(null, title, '/i/drive/folder/' + folder.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
this.file = null;
|
|
|
|
this.folder = folder;
|
|
|
|
},
|
|
|
|
onOpenFile(file, silent) {
|
2018-08-07 04:25:50 +00:00
|
|
|
const title = `${file.name} | ${config.name} Drive`;
|
2018-02-20 04:58:25 +00:00
|
|
|
|
|
|
|
if (!silent) {
|
|
|
|
// Rewrite URL
|
|
|
|
history.pushState(null, title, '/i/drive/file/' + file.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
this.file = file;
|
|
|
|
this.folder = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|