perf: Register magnet handler (#784)

This commit is contained in:
Rémi Marseault 2023-05-01 21:38:09 +02:00 committed by GitHub
parent d1ffa2b143
commit 82310c843d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 1 deletions

View file

@ -220,6 +220,18 @@
</v-col>
</v-row>
</v-list-item>
<v-list-item>
<v-row dense>
<v-col cols="7" sm="7" md="10">
<p class="subtitle-1">
{{ $t('modals.settings.pageVueTorrent.pageGeneral.registerMagnetHeader') }}
</p>
</v-col>
<v-col cols="4" sm="4" md="2">
<v-btn @click="registerMagnetHandler">{{ $t('modals.settings.pageVueTorrent.pageGeneral.registerMagnetButton') }}</v-btn>
</v-col>
</v-row>
</v-list-item>
<v-list-item>
<v-textarea v-model="settingsField" />
</v-list-item>
@ -296,6 +308,15 @@ export default {
resetSettings() {
window.localStorage.clear()
location.reload()
},
registerMagnetHandler() {
if (typeof navigator.registerProtocolHandler !== 'function') {
this.$toast.error(this.$t("toast.magnetHandlerNotSupported").toString());
return;
}
const templateUrl = location.href.replace('/settings', '/download=%s')
navigator.registerProtocolHandler('magnet', templateUrl);
}
}
}

View file

@ -237,6 +237,8 @@
"showShutdownButton": "Show shutdown button",
"currentVersion": "Current Version:",
"qbittorrentVersion": "QBittorrent Version:",
"registerMagnetHeader": "Register to handle magnet links...",
"registerMagnetButton": "Register",
"importSettings": "Import Settings",
"exportSettings": "Export Settings",
"resetSettings": "Reset Settings"
@ -556,7 +558,8 @@
"pasteNotSupported": "Unable to paste, context isn't secured",
"shutdownSuccess": "qBittorrent was shutdown successfully!",
"shutdownError": "Unable to shutdown app. Make sure qBittorrent is running!",
"invalidJson": "Invalid JSON! Check console for details"
"invalidJson": "Invalid JSON! Check console for details",
"magnetHandlerNotSupported": "Unable to register handler, context isn't secured!"
},
"rightClick": {
"resume": "resume",

View file

@ -133,6 +133,16 @@ exports[`General > render correctly 1`] = `
</a></v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub data-v-7da6d3e2=\\"\\" activeclass=\\"\\" tag=\\"div\\">
<v-row-stub data-v-7da6d3e2=\\"\\" tag=\\"div\\" dense=\\"true\\">
<v-col-stub data-v-7da6d3e2=\\"\\" cols=\\"7\\" sm=\\"7\\" md=\\"10\\" tag=\\"div\\">
<p data-v-7da6d3e2=\\"\\" class=\\"subtitle-1\\"> </p>
</v-col-stub>
<v-col-stub data-v-7da6d3e2=\\"\\" cols=\\"4\\" sm=\\"4\\" md=\\"2\\" tag=\\"div\\">
<v-btn-stub data-v-7da6d3e2=\\"\\" tag=\\"button\\" activeclass=\\"\\" type=\\"button\\"></v-btn-stub>
</v-col-stub>
</v-row-stub>
</v-list-item-stub>
<v-list-item-stub data-v-7da6d3e2=\\"\\" activeclass=\\"\\" tag=\\"div\\">
<v-textarea-stub data-v-7da6d3e2=\\"\\" errorcount=\\"1\\" errormessages=\\"\\" messages=\\"\\" rules=\\"\\" successmessages=\\"\\" value=\\"\\" backgroundcolor=\\"\\" loaderheight=\\"2\\" clearicon=\\"$clear\\" type=\\"text\\" rowheight=\\"24\\" rows=\\"5\\"></v-textarea-stub>
</v-list-item-stub>