Add feature to shut down qBittorrent application.(ui, api, locale)

maybe a better ui?
This commit is contained in:
R-L-T-Y
2020-07-08 20:24:54 +08:00
committed by CzBiX
parent ab8f6bcbc2
commit 7511c8ab66
4 changed files with 37 additions and 3 deletions

View File

@@ -38,6 +38,10 @@ class Api {
return this.axios.get('/app/preferences');
}
public shutdownApplication() {
return this.axios.get('/app/shutdown');
}
public getMainData(rid?: number) {
const params = {
rid,

View File

@@ -56,6 +56,13 @@
>
<v-icon v-text="darkModeIcon" />
</v-btn>
<v-btn
icon
@click="triggerApplicationShutdown"
:title="$t('triggerApplicationShutdown')"
>
<v-icon> mdi-power-plug-off</v-icon>
</v-btn>
</div>
</div>
</template>
@@ -65,6 +72,7 @@ import Vue from 'vue'
import Component from 'vue-class-component';
import { mapMutations, mapActions } from 'vuex';
import { Watch } from 'vue-property-decorator';
import api from '../../Api';
import { tr, translations, defaultLocale, LocaleKey } from '@/locale';
import { DialogType, DialogConfig, SnackBarConfig, ConfigPayload } from '@/store/types';
@@ -161,6 +169,20 @@ export default class DrawerFooter extends Vue {
});
}
async triggerApplicationShutdown() {
const v = await this.asyncShowDialog({
title: tr('dialog.trigger_exit_qb.title'),
text: tr('dialog.trigger_exit_qb.text'),
type: DialogType.OkCancel,
});
if (!v) {
return;
}
await api.shutdownApplication();
}
@Watch('currentLocale')
onCurrentLocaleChanged(v: AllLocaleKey) {
this.switchLocale(v)
@@ -177,4 +199,4 @@ export default class DrawerFooter extends Vue {
.footer {
padding: 1em;
}
</style>
</style>

View File

@@ -23,7 +23,7 @@ export default {
refresh: 'Refresh',
location: 'Location',
rename: 'Rename',
triggerApplicationShutdown: 'Exit qBittorrent',
reannounce: 'Reannounce',
recheck: 'Recheck',
@@ -89,6 +89,10 @@ export default {
},
dialog: {
trigger_exit_qb: {
title: 'Exit qBittorrent',
text: 'Are you sure you want to exit qBittorrent?'
},
add_torrents: {
placeholder: 'Upload torrents by drop them here,\nor click attachment button at right to select.',
hint: 'One link per line',

View File

@@ -23,7 +23,7 @@ export default {
refresh: '刷新',
location: '位置',
rename: '重命名',
triggerApplicationShutdown: '退出qBittorrent',
reannounce: '重新通告',
recheck: '重新检查',
@@ -89,6 +89,10 @@ export default {
},
dialog: {
trigger_exit_qb: {
title: '退出 qBittorrent',
text: '您确定要退出qBittorrent吗?'
},
add_torrents: {
placeholder: '将种子拖到这里上传,\n或者点击右边的附件图标来选择。',
hint: '每行一个链接',