From 7511c8ab66219b6b7b53460928ea11807ffe7af6 Mon Sep 17 00:00:00 2001 From: R-L-T-Y Date: Wed, 8 Jul 2020 20:24:54 +0800 Subject: [PATCH] Add feature to shut down qBittorrent application.(ui, api, locale) maybe a better ui? --- src/Api.ts | 4 ++++ src/components/drawer/DrawerFooter.vue | 24 +++++++++++++++++++++++- src/locale/en.ts | 6 +++++- src/locale/zh-CN.ts | 6 +++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Api.ts b/src/Api.ts index b0ddbe8..a11466c 100644 --- a/src/Api.ts +++ b/src/Api.ts @@ -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, diff --git a/src/components/drawer/DrawerFooter.vue b/src/components/drawer/DrawerFooter.vue index 81289af..6fc4b40 100644 --- a/src/components/drawer/DrawerFooter.vue +++ b/src/components/drawer/DrawerFooter.vue @@ -56,6 +56,13 @@ > + + mdi-power-plug-off + @@ -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; } - \ No newline at end of file + diff --git a/src/locale/en.ts b/src/locale/en.ts index db08d27..0a4a190 100644 --- a/src/locale/en.ts +++ b/src/locale/en.ts @@ -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', diff --git a/src/locale/zh-CN.ts b/src/locale/zh-CN.ts index 8b0fc1c..281fbfe 100644 --- a/src/locale/zh-CN.ts +++ b/src/locale/zh-CN.ts @@ -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: '每行一个链接',