From 3b2c47e0ec9052cee610b9e6064b0e7a03bd012a Mon Sep 17 00:00:00 2001 From: luyuan <1162963624@qq.com> Date: Thu, 12 Nov 2020 17:43:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/js/debug/GenerateTestUserSig.js | 78 +++++++++++++++----------- public/js/presetting.js | 26 +++++---- public/zhibo.html | 4 ++ src/views/regime/Liveing.vue | 4 +- 4 files changed, 66 insertions(+), 46 deletions(-) diff --git a/public/js/debug/GenerateTestUserSig.js b/public/js/debug/GenerateTestUserSig.js index 881a07a..fa11132 100644 --- a/public/js/debug/GenerateTestUserSig.js +++ b/public/js/debug/GenerateTestUserSig.js @@ -23,41 +23,51 @@ function genTestUserSig(userID) { * 进入腾讯云实时音视频[控制台](https://console.cloud.tencent.com/rav ) 创建应用,即可看到 SDKAppId, * 它是腾讯云用于区分客户的唯一标识。 */ - const SDKAPPID = 1400435767; + // const SDKAPPID = 1400435767; - /** - * 签名过期时间,建议不要设置的过短 - *

- * 时间单位:秒 - * 默认时间:7 x 24 x 60 x 60 = 604800 = 7 天 - */ - const EXPIRETIME = 604800; + // /** + // * 签名过期时间,建议不要设置的过短 + // *

+ // * 时间单位:秒 + // * 默认时间:7 x 24 x 60 x 60 = 604800 = 7 天 + // */ + // const EXPIRETIME = 604800; - /** - * 计算签名用的加密密钥,获取步骤如下: - * - * step1. 进入腾讯云实时音视频[控制台](https://console.cloud.tencent.com/rav ),如果还没有应用就创建一个, - * step2. 单击“应用配置”进入基础配置页面,并进一步找到“帐号体系集成”部分。 - * step3. 点击“查看密钥”按钮,就可以看到计算 UserSig 使用的加密的密钥了,请将其拷贝并复制到如下的变量中 - * - * 注意:该方案仅适用于调试Demo,正式上线前请将 UserSig 计算代码和密钥迁移到您的后台服务器上,以避免加密密钥泄露导致的流量盗用。 - * 文档:https://cloud.tencent.com/document/product/647/17275#Server - */ - const SECRETKEY = 'dzrUpsgeMo0ygiSmqeDVqxnLbdT3Lbbh'; + // /** + // * 计算签名用的加密密钥,获取步骤如下: + // * + // * step1. 进入腾讯云实时音视频[控制台](https://console.cloud.tencent.com/rav ),如果还没有应用就创建一个, + // * step2. 单击“应用配置”进入基础配置页面,并进一步找到“帐号体系集成”部分。 + // * step3. 点击“查看密钥”按钮,就可以看到计算 UserSig 使用的加密的密钥了,请将其拷贝并复制到如下的变量中 + // * + // * 注意:该方案仅适用于调试Demo,正式上线前请将 UserSig 计算代码和密钥迁移到您的后台服务器上,以避免加密密钥泄露导致的流量盗用。 + // * 文档:https://cloud.tencent.com/document/product/647/17275#Server + // */ + // const SECRETKEY = 'dzrUpsgeMo0ygiSmqeDVqxnLbdT3Lbbh'; - // a soft reminder to guide developer to configure sdkAppId/secretKey - if (SDKAPPID === '' || SECRETKEY === '') { - alert( - '请先配置好您的账号信息: SDKAPPID 及 SECRETKEY ' + - '\r\n\r\nPlease configure your SDKAPPID/SECRETKEY in js/debug/GenerateTestUserSig.js' - ); - } - const generator = new LibGenerateTestUserSig(SDKAPPID, SECRETKEY, EXPIRETIME); - const userSig = window.istow ? "eJwtzdEKgjAUBuB32XXYdJubQhcV2IWBkGYEgohOO1SypoYQvXtLvTzff85-Pig5xtZbauQjx8JoNc1QybaHGibuboWW*dBJnRNMMcYeX9a66l4oBRXybeOUMO7yOZGjAi2NM8YcczJrD8*-uZhhYRPBlhZozJfW4*f9y7EPafmgTXjdnYQagjIRY7Ye4qim20sNaRsGEWk26PsDMPg1Xg__" : "eJwtzE8LgkAQBfDvstdCJt3RTeigl6gMw-7oLUK3GCNZ1Foj*u5t6vH93sz7sEO0t16yZj6zLWDTPlMhq5au1POzkfXZAQ4Ac288aIr7RSkqmD8zzh30XG9oZKeolsYR0TYvg7b0*JsLCAIcjuMK3cx*LmyV5GFXBWGZ6m4VVaejzjax3K3fehsTpk2QJKVeTsSCfX94djN6"; - console.log(userSig) - window.istow = true - return { - sdkAppId: SDKAPPID, - userSig:userSig - }; + // // a soft reminder to guide developer to configure sdkAppId/secretKey + // if (SDKAPPID === '' || SECRETKEY === '') { + // alert( + // '请先配置好您的账号信息: SDKAPPID 及 SECRETKEY ' + + // '\r\n\r\nPlease configure your SDKAPPID/SECRETKEY in js/debug/GenerateTestUserSig.js' + // ); + // } + // const generator = new LibGenerateTestUserSig(SDKAPPID, SECRETKEY, EXPIRETIME); + // const userSig = window.istow ? "eJwtzdEKgjAUBuB32XXYdJubQhcV2IWBkGYEgohOO1SypoYQvXtLvTzff85-Pig5xtZbauQjx8JoNc1QybaHGibuboWW*dBJnRNMMcYeX9a66l4oBRXybeOUMO7yOZGjAi2NM8YcczJrD8*-uZhhYRPBlhZozJfW4*f9y7EPafmgTXjdnYQagjIRY7Ye4qim20sNaRsGEWk26PsDMPg1Xg__" : "eJwtzE8LgkAQBfDvstdCJt3RTeigl6gMw-7oLUK3GCNZ1Foj*u5t6vH93sz7sEO0t16yZj6zLWDTPlMhq5au1POzkfXZAQ4Ac288aIr7RSkqmD8zzh30XG9oZKeolsYR0TYvg7b0*JsLCAIcjuMK3cx*LmyV5GFXBWGZ6m4VVaejzjax3K3fehsTpk2QJKVeTsSCfX94djN6"; + // console.log(userSig) + // window.istow = true + // return { + // sdkAppId: SDKAPPID, + // userSig:userSig + // }; + return new Promise((res)=>{ + $.ajax({ + url: window.url + 'userSig?userid=' + userID, + headers: "Bearer " + localStorage.getItem("token"), + success(data){ + res({data: data.data, id: 1400435767}) + } + }) + }) + } diff --git a/public/js/presetting.js b/public/js/presetting.js index 7ec7b8b..3c0022c 100644 --- a/public/js/presetting.js +++ b/public/js/presetting.js @@ -30,16 +30,22 @@ class Presetting { userId = 'share_' + userId; } console.log(userId) - const config = genTestUserSig(userId); - const sdkAppId = config.sdkAppId; - const userSig = config.userSig; - const roomId = $('#roomId').val(); + + let sdkAppId; + let userSig; + let roomId = $('#roomId').val(); + genTestUserSig(userId).then((res)=>{ + sdkAppId = res.id; + userSig = res.data + callback({ + sdkAppId, + userId, + userSig, + roomId + }); + }) + - callback({ - sdkAppId, - userId, - userSig, - roomId - }); + } } diff --git a/public/zhibo.html b/public/zhibo.html index bc17cf7..7830e3a 100644 --- a/public/zhibo.html +++ b/public/zhibo.html @@ -407,6 +407,10 @@ + diff --git a/src/views/regime/Liveing.vue b/src/views/regime/Liveing.vue index 0107cfe..d102905 100644 --- a/src/views/regime/Liveing.vue +++ b/src/views/regime/Liveing.vue @@ -1,5 +1,5 @@