From be5abe880291d1a533ef579ad69cadb7c789fe03 Mon Sep 17 00:00:00 2001 From: yuanruibin Date: Wed, 31 Jan 2024 16:46:05 +0800 Subject: [PATCH 1/4] 1 --- sdk/demo/demo.html | 28 ++++++++++++++++++++++++++-- sdk/index.html | 20 ++++++++++++++++++-- sdk/src/AppController.js | 9 +++++++-- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html index 1f4c818..7d12652 100644 --- a/sdk/demo/demo.html +++ b/sdk/demo/demo.html @@ -448,10 +448,11 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. + - + + + + @@ -643,17 +643,18 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. // 监听云机复制内容写入移动端端侧粘贴板 cloudapp.on("clipboardDataChangeMobile", function (event, data) { - var clipboard = new ClipboardJS('#clipText', { - text: function () { - return data; - }, - }); - setTimeout(() => { - document.getElementById('clipText').click() - }, 0); - clipboard.on('success', function(e) { - e.clearSelection(); - }); + // var clipboard = new ClipboardJS('#clipText', { + // text: function () { + // return data; + // }, + // }); + // setTimeout(() => { + // document.getElementById('clipText').click() + // }, 0); + // clipboard.on('success', function(e) { + // e.clearSelection(); + // }); + copyVal(data) }); // 监听端侧粘贴,获取粘贴板内容发给云机 @@ -665,10 +666,24 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. // 监听端侧粘贴,获取粘贴板内容发给云机 document.addEventListener('visibilitychange', (event) => { if (document.visibilityState == "visible") { - const pasteContent = event.clipboardData.getData('text/plain'); - cloudapp.sendClipboardData(pasteContent); + navigator.clipboard.readText().then((res) => { + console.log(res) + cloudapp.sendClipboardData(res); + }) + // const pasteContent = event.clipboardData.getData('text/plain'); + // cloudapp.sendClipboardData(pasteContent); } }); + + function copyVal(val) { + var oInput = document.createElement("input"); + oInput.type = "text"; + oInput.value = val; + document.body.appendChild(oInput); + oInput.select(); // 选择对象 + document.execCommand("Copy"); // 执行浏览器复制命令 + oInput.parentNode.removeChild(oInput); //执行完之后删除该对象 + } } } catch (e) { console.log(e); diff --git a/sdk/index.html b/sdk/index.html index 0649d18..2aa0879 100644 --- a/sdk/index.html +++ b/sdk/index.html @@ -448,9 +448,9 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. - + @@ -643,17 +643,18 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. // 监听云机复制内容写入移动端端侧粘贴板 cloudapp.on("clipboardDataChangeMobile", function (event, data) { - var clipboard = new ClipboardJS('#clipText', { - text: function () { - return data; - }, - }); - setTimeout(() => { - document.getElementById('clipText').click() - }, 0); - clipboard.on('success', function(e) { - e.clearSelection(); - }); + // var clipboard = new ClipboardJS('#clipText', { + // text: function () { + // return data; + // }, + // }); + // setTimeout(() => { + // document.getElementById('clipText').click() + // }, 0); + // clipboard.on('success', function(e) { + // e.clearSelection(); + // }); + copyVal(data) }); // 监听端侧粘贴,获取粘贴板内容发给云机 @@ -661,6 +662,16 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. const pasteContent = event.clipboardData.getData('text/plain'); cloudapp.sendClipboardData(pasteContent); }); + + function copyVal(val) { + var oInput = document.createElement("input"); + oInput.type = "text"; + oInput.value = val; + document.body.appendChild(oInput); + oInput.select(); // 选择对象 + document.execCommand("Copy"); // 执行浏览器复制命令 + oInput.parentNode.removeChild(oInput); //执行完之后删除该对象 + } } } catch (e) { console.log(e); -- Gitee From 86f23bfcfe5271f365894419adcc540d19410aa1 Mon Sep 17 00:00:00 2001 From: yuanruibin Date: Thu, 1 Feb 2024 16:41:11 +0800 Subject: [PATCH 3/4] 1 --- sdk/demo/demo.html | 46 ++++++---------------------------------- sdk/index.html | 34 ++++++----------------------- sdk/src/AppController.js | 11 +++------- 3 files changed, 17 insertions(+), 74 deletions(-) diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html index c265824..3c51c93 100644 --- a/sdk/demo/demo.html +++ b/sdk/demo/demo.html @@ -638,23 +638,13 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. // 监听云机复制内容写入端侧粘贴板 cloudapp.on("clipboardDataChange", function (event, data) { - navigator.clipboard.writeText(data); - }); - - // 监听云机复制内容写入移动端端侧粘贴板 - cloudapp.on("clipboardDataChangeMobile", function (event, data) { - // var clipboard = new ClipboardJS('#clipText', { - // text: function () { - // return data; - // }, - // }); - // setTimeout(() => { - // document.getElementById('clipText').click() - // }, 0); - // clipboard.on('success', function(e) { - // e.clearSelection(); - // }); - copyVal(data) + var save = function(e) { + e.clipboardData.setData('text/plain', data); + e.preventDefault(); + } + document.addEventListener('copy', save); + document.execCommand('copy'); + document.removeEventListener('copy',save); }); // 监听端侧粘贴,获取粘贴板内容发给云机 @@ -662,28 +652,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. const pasteContent = event.clipboardData.getData('text/plain'); cloudapp.sendClipboardData(pasteContent); }); - - // 监听端侧粘贴,获取粘贴板内容发给云机 - document.addEventListener('visibilitychange', (event) => { - if (document.visibilityState == "visible") { - navigator.clipboard.readText().then((res) => { - console.log(res) - cloudapp.sendClipboardData(res); - }) - // const pasteContent = event.clipboardData.getData('text/plain'); - // cloudapp.sendClipboardData(pasteContent); - } - }); - - function copyVal(val) { - var oInput = document.createElement("input"); - oInput.type = "text"; - oInput.value = val; - document.body.appendChild(oInput); - oInput.select(); // 选择对象 - document.execCommand("Copy"); // 执行浏览器复制命令 - oInput.parentNode.removeChild(oInput); //执行完之后删除该对象 - } } } catch (e) { console.log(e); diff --git a/sdk/index.html b/sdk/index.html index 2aa0879..3c51c93 100644 --- a/sdk/index.html +++ b/sdk/index.html @@ -638,23 +638,13 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. // 监听云机复制内容写入端侧粘贴板 cloudapp.on("clipboardDataChange", function (event, data) { - navigator.clipboard.writeText(data); - }); - - // 监听云机复制内容写入移动端端侧粘贴板 - cloudapp.on("clipboardDataChangeMobile", function (event, data) { - // var clipboard = new ClipboardJS('#clipText', { - // text: function () { - // return data; - // }, - // }); - // setTimeout(() => { - // document.getElementById('clipText').click() - // }, 0); - // clipboard.on('success', function(e) { - // e.clearSelection(); - // }); - copyVal(data) + var save = function(e) { + e.clipboardData.setData('text/plain', data); + e.preventDefault(); + } + document.addEventListener('copy', save); + document.execCommand('copy'); + document.removeEventListener('copy',save); }); // 监听端侧粘贴,获取粘贴板内容发给云机 @@ -662,16 +652,6 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. const pasteContent = event.clipboardData.getData('text/plain'); cloudapp.sendClipboardData(pasteContent); }); - - function copyVal(val) { - var oInput = document.createElement("input"); - oInput.type = "text"; - oInput.value = val; - document.body.appendChild(oInput); - oInput.select(); // 选择对象 - document.execCommand("Copy"); // 执行浏览器复制命令 - oInput.parentNode.removeChild(oInput); //执行完之后删除该对象 - } } } catch (e) { console.log(e); diff --git a/sdk/src/AppController.js b/sdk/src/AppController.js index e15818a..17b4bf4 100644 --- a/sdk/src/AppController.js +++ b/sdk/src/AppController.js @@ -116,8 +116,7 @@ class AppController { 'appStateChange', 'audioStateChange', 'cloudAppData', - 'clipboardDataChange', - 'clipboardDataChangeMobile' + 'clipboardDataChange' ]); this.cameraMsgHeader = null; this.microPhoneMsgHeader = null; @@ -789,11 +788,7 @@ class AppController { const input = len > 0 ? this.util.decodeUTF8(pkg, PROTOCOL_CONFIG.KEYBOARD_INPUT_HEADER_LENGTH, PROTOCOL_CONFIG.KEYBOARD_INPUT_HEADER_LENGTH + len) : ''; - if (this.isMobile) { - this.subscribe.trigger('clipboardDataChangeMobile', input); - } else { - this.subscribe.trigger('clipboardDataChange', input); - } + this.subscribe.trigger('clipboardDataChange', input); } } @@ -982,7 +977,7 @@ class AppController { aes_iv: iv, sdk_version: this.options.sdkVersion, protocol_version: 'v2', - client_type: '3', + client_type: this.options.isMobile ? '4' :'3', media_config: { ...this.options.mediaConfig, frame_type: this.options.decoderType ? this.options.decoderType.toLowerCase() : FRAME_TYPE_MAP.TYPE264, -- Gitee From 2bf0dbb736a0aba090bf0ac6864abf3ab6d1f15b Mon Sep 17 00:00:00 2001 From: yuanruibin Date: Thu, 1 Feb 2024 17:23:01 +0800 Subject: [PATCH 4/4] 1 --- sdk/demo/demo.html | 2 -- sdk/index.html | 2 -- 2 files changed, 4 deletions(-) diff --git a/sdk/demo/demo.html b/sdk/demo/demo.html index 3c51c93..ece9042 100644 --- a/sdk/demo/demo.html +++ b/sdk/demo/demo.html @@ -450,9 +450,7 @@ Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. - - -