mirror of https://github.com/Kylart/KawAnime.git
Fix magnet protocol handling on Windows
This commit is contained in:
parent
2bdea831e7
commit
87778a1dc3
|
@ -4304,8 +4304,7 @@
|
|||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
|
||||
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"coa": {
|
||||
"version": "2.0.2",
|
||||
|
@ -8124,8 +8123,7 @@
|
|||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
|
@ -8146,14 +8144,12 @@
|
|||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
|
@ -8168,20 +8164,17 @@
|
|||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
|
@ -8298,8 +8291,7 @@
|
|||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
|
@ -8311,7 +8303,6 @@
|
|||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
|
@ -8326,7 +8317,6 @@
|
|||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
|
@ -8334,14 +8324,12 @@
|
|||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.3.5",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.2",
|
||||
"yallist": "^3.0.0"
|
||||
|
@ -8360,7 +8348,6 @@
|
|||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
|
@ -8441,8 +8428,7 @@
|
|||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
|
@ -8454,7 +8440,6 @@
|
|||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
|
@ -8540,8 +8525,7 @@
|
|||
"safe-buffer": {
|
||||
"version": "5.1.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
|
@ -8577,7 +8561,6 @@
|
|||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
@ -8597,7 +8580,6 @@
|
|||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
|
@ -8641,14 +8623,12 @@
|
|||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.3",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -14264,11 +14244,6 @@
|
|||
"resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.1.1.tgz",
|
||||
"integrity": "sha512-w7fLxIRCRT7U8Qu53jQnJyPkYZIaR4n5151KMfcJlO/A9397Wxb1amJvROTK6TOnp7PfoAmg/qXiNHI+08jRfA=="
|
||||
},
|
||||
"rage-edit": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/rage-edit/-/rage-edit-1.2.0.tgz",
|
||||
"integrity": "sha512-0RspBRc2s6We4g7hRCvT5mu7YPEnfjvQK8Tt354a2uUNJCMC7MKLvo/1mLvHUCQ/zbP6siQyp5VRZN7UCpMFZg=="
|
||||
},
|
||||
"ramda": {
|
||||
"version": "0.24.1",
|
||||
"resolved": "https://registry.npmjs.org/ramda/-/ramda-0.24.1.tgz",
|
||||
|
@ -16344,8 +16319,7 @@
|
|||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
|
||||
"integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
"dev": true
|
||||
},
|
||||
"json-schema-traverse": {
|
||||
"version": "0.3.1",
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
"mime": "^2.4.3",
|
||||
"moment": "^2.24.0",
|
||||
"nyaapi": "^2.0.5",
|
||||
"rage-edit": "^1.2.0",
|
||||
"range-parser": "^1.2.1",
|
||||
"register-service-worker": "^1.6.2",
|
||||
"rimraf": "^2.6.3",
|
||||
|
|
|
@ -40,9 +40,6 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
// Comes from https://github.com/electron/electron/issues/14108
|
||||
import { Registry } from 'rage-edit'
|
||||
|
||||
// Mixins
|
||||
import Update from '@/mixins/config/update.js'
|
||||
|
||||
|
@ -103,17 +100,10 @@ export default {
|
|||
this.$log('Registering as default torrent app...')
|
||||
this.defaultLoading = true
|
||||
|
||||
let isOk = false
|
||||
|
||||
if (process.platform === 'win32') {
|
||||
isOk = await this.installWindows()
|
||||
} else {
|
||||
const { app } = this.$electron.remote
|
||||
|
||||
isOk = this.protocols
|
||||
.map((protocol) => app.setAsDefaultProtocolClient(protocol))
|
||||
.every(Boolean)
|
||||
}
|
||||
const { app } = this.$electron.remote
|
||||
const isOk = this.protocols
|
||||
.map((protocol) => app.setAsDefaultProtocolClient(protocol, process.platform === 'darwin' ? undefined : app.getPath('exe')))
|
||||
.every(Boolean)
|
||||
|
||||
if (isOk) {
|
||||
this.$log('Success!')
|
||||
|
@ -124,27 +114,6 @@ export default {
|
|||
}
|
||||
|
||||
this.defaultLoading = false
|
||||
},
|
||||
async installWindows () {
|
||||
const appName = 'KawAnime'
|
||||
|
||||
try {
|
||||
await Promise.all(
|
||||
this.protocols.map(async (protocol) => {
|
||||
await Registry.set(`HKCU\\Software\\${appName}\\Capabilities`, 'ApplicationName', `${appName}`)
|
||||
await Registry.set(`HKCU\\Software\\${appName}\\Capabilities`, 'ApplicationDescription', `${appName}`)
|
||||
await Registry.set(`HKCU\\Software\\${appName}\\Capabilities\\URLAssociations`, `${protocol}`, `${appName}.${protocol}`)
|
||||
await Registry.set(`HKCU\\Software\\Classes\\${appName}.${protocol}\\DefaultIcon`, ``, process.execPath)
|
||||
await Registry.set(`HKCU\\Software\\Classes\\${appName}.${protocol}\\shell\\open\\command`, ``, `"${process.execPath}" "%1"`)
|
||||
await Registry.set(`HKCU\\Software\\RegisteredApplications`, `${appName}`, `Software\\${appName}\\Capabilities`)
|
||||
})
|
||||
)
|
||||
|
||||
return true
|
||||
} catch (e) {
|
||||
this.$log('Could not register the app as default client.', e)
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue