1
0
mirror of https://github.com/hotomoe/hotomoe synced 2024-11-25 07:36:24 +09:00

既定のアップロード先フォルダを設定できるように

This commit is contained in:
syuilo 2019-07-08 04:17:53 +09:00
parent 5c2ed9e5d3
commit 841c8d619f
7 changed files with 74 additions and 7 deletions

View File

@ -958,7 +958,7 @@ desktop/views/components/drive.file.vue:
unmark-as-sensitive: "閲覧注意を解除"
copy-url: "URLをコピー"
download: "ダウンロード"
else-files: "その他..."
else-files: "その他"
set-as-avatar: "アイコンに設定"
set-as-banner: "バナーに設定"
open-in-app: "アプリで開く"
@ -969,6 +969,7 @@ desktop/views/components/drive.file.vue:
copied-url-to-clipboard: "URLをクリップボードにコピーしました"
desktop/views/components/drive.folder.vue:
upload-folder: "既定アップロード先"
unable-to-process: "操作を完了できません"
circular-reference-detected: "移動先のフォルダーは、移動するフォルダーのサブフォルダーです。"
unhandled-error: "不明なエラー"
@ -980,6 +981,8 @@ desktop/views/components/drive.folder.vue:
rename: "名前を変更"
rename-folder: "フォルダ名の変更"
input-new-folder-name: "新しいフォルダ名を入力してください"
else-folders: "その他"
set-as-upload-folder: "既定アップロード先に設定"
desktop/views/components/drive.vue:
search: "検索"
@ -1143,6 +1146,9 @@ common/views/components/drive-settings.vue:
max: "容量"
in-use: "使用中"
stats: "統計"
default-upload-folder: "既定のアップロード先フォルダ"
default-upload-folder-name: "フォルダ"
change-default-upload-folder: "フォルダを変更"
common/views/components/mute-and-block.vue:
mute-and-block: "ミュートとブロック"

View File

@ -245,7 +245,7 @@ export default (opts) => ({
},
upload(file) {
(this.$refs.uploader as any).upload(file);
(this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder);
},
onChangeUploadings(uploads) {

View File

@ -158,7 +158,7 @@ export default Vue.extend({
},
upload(file) {
(this.$refs.uploader as any).upload(file);
(this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder);
},
onUploaded(file) {

View File

@ -11,6 +11,12 @@
<header>{{ $t('stats') }}</header>
<div ref="chart" style="margin-bottom: -16px; margin-left: -8px; color: #000;"></div>
</section>
<section>
<header>{{ $t('default-upload-folder') }}</header>
<ui-input v-model="uploadFolderName" readonly>{{ $t('default-upload-folder-name') }}</ui-input>
<ui-button @click="chooseUploadFolder()">{{ $t('change-default-upload-folder') }}</ui-button>
</section>
</ui-card>
</template>
@ -26,7 +32,8 @@ export default Vue.extend({
return {
fetching: true,
usage: null,
capacity: null
capacity: null,
uploadFolderName: null
};
},
@ -40,10 +47,25 @@ export default Vue.extend({
l: 0.5
})
};
}
},
uploadFolder: {
get() { return this.$store.state.settings.uploadFolder; },
set(value) { this.$store.dispatch('settings/set', { key: 'uploadFolder', value }); }
},
},
mounted() {
if (this.uploadFolder == null) {
this.uploadFolderName = this.$t('@._settings.root');
} else {
this.$root.api('drive/folders/show', {
folderId: this.uploadFolder
}).then(folder => {
this.uploadFolderName = folder.name;
});
}
this.$root.api('drive').then(info => {
this.capacity = info.capacity;
this.usage = info.usage;
@ -152,6 +174,13 @@ export default Vue.extend({
chart.render();
});
},
chooseUploadFolder() {
this.$chooseDriveFolder().then(folder => {
this.uploadFolder = folder ? folder.id : null;
this.uploadFolderName = folder ? folder.name : this.$t('@._settings.root');
})
}
}
});

View File

@ -122,7 +122,7 @@ export default define({
},
upload(file) {
(this.$refs.uploader as any).upload(file);
(this.$refs.uploader as any).upload(file, this.$store.state.settings.uploadFolder);
},
onDragover(e) {

View File

@ -20,6 +20,9 @@
<template v-if="!hover"><fa :icon="['far', 'folder']" fixed-width/></template>
{{ folder.name }}
</p>
<p class="upload" v-if="$store.state.settings.uploadFolder == folder.id">
{{ $t('upload-folder') }}
</p>
</div>
</template>
@ -73,6 +76,14 @@ export default Vue.extend({
text: this.$t('@.delete'),
icon: ['far', 'trash-alt'],
action: this.deleteFolder
}, null, {
type: 'nest',
text: this.$t('contextmenu.else-folders'),
menu: [{
type: 'item',
text: this.$t('contextmenu.set-as-upload-folder'),
action: this.setAsUploadFolder
}]
}], {
closed: () => {
this.isContextmenuShowing = false;
@ -213,6 +224,13 @@ export default Vue.extend({
deleteFolder() {
this.$root.api('drive/folders/delete', {
folderId: this.folder.id
}).then(() => {
if (this.$store.state.settings.uploadFolder === this.folder.id) {
this.$store.dispatch('settings/set', {
key: 'uploadFolder',
value: null
});
}
}).catch(err => {
switch(err.id) {
case 'b0fc8a17-963c-405d-bfbc-859a487295e1':
@ -229,7 +247,14 @@ export default Vue.extend({
});
}
});
}
},
setAsUploadFolder() {
this.$store.dispatch('settings/set', {
key: 'uploadFolder',
value: this.folder.id
});
},
}
});
</script>
@ -279,4 +304,10 @@ export default Vue.extend({
margin-left 2px
text-align left
> .upload
margin 4px 4px
font-size 0.8em
text-align right
color var(--desktopDriveFolderFg)
</style>

View File

@ -38,6 +38,7 @@ const defaultSettings = {
homeProfiles: {},
mobileHomeProfiles: {},
deckProfiles: {},
uploadFolder: null,
};
const defaultDeviceSettings = {