This commit is contained in:
こぴなたみぽ 2018-02-20 13:58:25 +09:00
parent dfa98a038c
commit eda7534e41
2 changed files with 83 additions and 73 deletions

View File

@ -1,73 +0,0 @@
<mk-drive-page>
<mk-ui ref="ui">
<mk-drive ref="browser" folder={ parent.opts.folder } file={ parent.opts.file } is-naked={ true } top={ 48 }/>
</mk-ui>
<style lang="stylus" scoped>
:scope
display block
</style>
<script lang="typescript">
import ui from '../../scripts/ui-event';
import Progress from '../../../common/scripts/loading';
this.on('mount', () => {
document.title = 'Misskey Drive';
ui.trigger('title', '%fa:cloud%%i18n:mobile.tags.mk-drive-page.drive%');
ui.trigger('func', () => {
this.$refs.ui.refs.browser.openContextMenu();
}, '%fa:ellipsis-h%');
this.$refs.ui.refs.browser.on('begin-fetch', () => {
Progress.start();
});
this.$refs.ui.refs.browser.on('fetched-mid', () => {
Progress.set(0.5);
});
this.$refs.ui.refs.browser.on('fetched', () => {
Progress.done();
});
this.$refs.ui.refs.browser.on('move-root', () => {
const title = 'Misskey Drive';
// Rewrite URL
history.pushState(null, title, '/i/drive');
document.title = title;
ui.trigger('title', '%fa:cloud%%i18n:mobile.tags.mk-drive-page.drive%');
});
this.$refs.ui.refs.browser.on('open-folder', (folder, silent) => {
const title = folder.name + ' | Misskey Drive';
if (!silent) {
// Rewrite URL
history.pushState(null, title, '/i/drive/folder/' + folder.id);
}
document.title = title;
// TODO: escape html characters in folder.name
ui.trigger('title', '%fa:R folder-open%' + folder.name);
});
this.$refs.ui.refs.browser.on('open-file', (file, silent) => {
const title = file.name + ' | Misskey Drive';
if (!silent) {
// Rewrite URL
history.pushState(null, title, '/i/drive/file/' + file.id);
}
document.title = title;
// TODO: escape html characters in file.name
ui.trigger('title', '<mk-file-type-icon class="icon"></mk-file-type-icon>' + file.name);
riot.mount('mk-file-type-icon', {
type: file.type
});
});
});
</script>
</mk-drive-page>

View File

@ -0,0 +1,83 @@
<template>
<mk-ui :func="fn" func-icon="%fa:ellipsis-h%">
<span slot="header">
<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-else>%fa:cloud%%i18n:mobile.tags.mk-drive-page.drive%</template>
</span>
<mk-drive
ref="browser"
:init-folder="folder"
:init-file="file"
is-naked
:top="48"
@begin-fetch="Progress.start()"
@fetched-mid="Progress.set(0.5);"
@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';
export default Vue.extend({
data() {
return {
Progress,
folder: null,
file: null
};
},
mounted() {
document.title = 'Misskey Drive';
},
methods: {
fn() {
(this.$refs as any).browser.openContextMenu();
},
onMoveRoot() {
const title = 'Misskey Drive';
// Rewrite URL
history.pushState(null, title, '/i/drive');
document.title = title;
this.file = null;
this.folder = null;
},
onOpenFolder(folder, silent) {
const title = folder.name + ' | Misskey Drive';
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) {
const title = file.name + ' | Misskey Drive';
if (!silent) {
// Rewrite URL
history.pushState(null, title, '/i/drive/file/' + file.id);
}
document.title = title;
this.file = file;
this.folder = null;
}
}
});
</script>