From c96df58dea918a0bb56c3eca163f2c49eeda51f5 Mon Sep 17 00:00:00 2001 From: Vidocq <949867756@qq.com> Date: Thu, 4 Mar 2021 01:17:23 +0800 Subject: [PATCH] prettified --- src/views/settings.vue | 46 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/views/settings.vue b/src/views/settings.vue index f70a413..2308254 100644 --- a/src/views/settings.vue +++ b/src/views/settings.vue @@ -244,10 +244,12 @@ export default { size: "0KB", length: 0, }, - allOutputDevices: [{ - deviceId: "default", - label: "settings.permissionRequired" - }], + allOutputDevices: [ + { + deviceId: "default", + label: "settings.permissionRequired", + }, + ], withoutAudioPriviledge: true, }; }, @@ -399,25 +401,27 @@ export default { }, methods: { getAllOutputDevices() { - navigator.mediaDevices. - getUserMedia({ audio: true }) - .then(() => { - this.withoutAudioPriviledge = false; - navigator.mediaDevices - .enumerateDevices() - .then( - (devices) => - (this.allOutputDevices = devices.filter( - (device) => device.kind == "audiooutput" - )) - ); - }) - .catch(() => { - this.allOutputDevices = [{ + navigator.mediaDevices + .getUserMedia({ audio: true }) + .then(() => { + this.withoutAudioPriviledge = false; + navigator.mediaDevices + .enumerateDevices() + .then( + (devices) => + (this.allOutputDevices = devices.filter( + (device) => device.kind == "audiooutput" + )) + ); + }) + .catch(() => { + this.allOutputDevices = [ + { deviceId: "default", label: "settings.permissionDenied", - }]; - }) + }, + ]; + }); }, logout() { doLogout();