diff --git a/README.md b/README.md index 494df77..35399af 100644 --- a/README.md +++ b/README.md @@ -17,13 +17,12 @@ #### 说明 : 示例网站是在公网环境中,为了更好的展示传输功能,所以默认开启了中继服务,如果各位是验证能否走p2p传输,只需关闭中继服务,且p2p检测后,如果能看到内网环境ip,webrtc连接大概率可以走p2p,跑到10M/s轻轻松松,公网环境下的内网用户一般情况下来说也会自动识别到的,如果内网速度慢,可以反馈留言,会尽快优化处理 -#### - #### 体验 : https://im.iamtsm.cn/file - **qq交流群 : 624214498** +![EN-DOC](doc/README_EN.md) + ## 准备 安装node,npm后进入项目目录 diff --git a/build/webpack/dev/webpackall.js b/build/webpack/dev/webpackall.js index c44c9eb..bc2c96a 100644 --- a/build/webpack/dev/webpackall.js +++ b/build/webpack/dev/webpackall.js @@ -62,7 +62,18 @@ module.exports = { optimization: { minimize: true, minimizer: [ - new UglifyJSPlugin() + new UglifyJSPlugin({ + uglifyOptions: { + output: { + comments: true, + beautify: true, + }, + compress: { + collapse_vars: false, + reduce_vars: false, + }, + }, + }) ] }, }; diff --git a/build/webpack/pro/webpackall.js b/build/webpack/pro/webpackall.js index b0b6091..3f2b204 100644 --- a/build/webpack/pro/webpackall.js +++ b/build/webpack/pro/webpackall.js @@ -46,7 +46,6 @@ module.exports = { filename: '[name].min.css', ignoreOrder: false, }), - new watchNewEntry(), ], resolve: { extensions: [ @@ -62,7 +61,46 @@ module.exports = { optimization: { minimize: true, minimizer: [ - new UglifyJSPlugin() + new UglifyJSPlugin({ + uglifyOptions: { + output: { + comments: false, // 移除所有注释 + beautify: false, // 不要美化输出,以使其更加紧凑 + }, + compress: { + booleans: true, + collapse_vars: true, + comparisons: true, + conditionals: true, + dead_code: true, + drop_console: true, + drop_debugger: true, + evaluate: true, + hoist_funs: true, + hoist_props: true, + hoist_vars: true, + if_return: true, + inline: true, + join_vars: true, + keep_infinity: true, + loops: true, + negate_iife: true, + properties: true, + reduce_funcs: true, + reduce_vars: true, + sequences: true, + side_effects: true, + switches: true, + toplevel: true, + typeofs: true, + unused: true, + }, + mangle: { + toplevel: true, + }, + extractComments: true, + }, + }) ] }, }; diff --git a/res/css/index.css b/res/css/index.css index 94540a5..e5db234 100644 --- a/res/css/index.css +++ b/res/css/index.css @@ -1,14 +1,17 @@ html { box-sizing: border-box; - --bgColorMenu : #ffffff12; - --duration: 1s; + --bgColorMenu: #5C76E7; + --duration: 1s; + background-image: linear-gradient(to right, #C5EDFF, #E6F7FF, #E6F7FF, #E6F7FF, #E6F7FF, #C5EDFF, #C5EDFF); } + html *, html *::before, html *::after { box-sizing: inherit; } -body{ + +body { margin: 0; margin-left: 5%; max-width: 90%; @@ -17,145 +20,443 @@ body{ transition: background-color var(--duration); -webkit-tap-highlight-color: transparent; } -.layui-layer-title{ - border-top-right-radius: 15px; - border-top-left-radius: 15px; + +.layui-layer-title { + border-radius: 8px !important; } -.layui-layer{ - border-radius: 20px; + +.layui-layer { + border-radius: 8px !important; } -#self .layui-upload-drag{ - border: 1px dashed #e2e2e2; - background-color: unset !important; + +.layui-card { + box-shadow: none; } -#self .layui-upload-drag[lay-over]{ - border: 2px dashed #e2e2e2; - background-color: unset !important; + +#tl-rtc-file-app { + margin-top: 35px; + border-radius: 15px; + max-width: 90%; + margin-left: 5%; } -.header-tool { + +.tl-rtc-file-header-tool { position: absolute; top: 10px; left: 10px; cursor: pointer; } -.menu{ - display: flex; - width: 90%; - font-size: .8em; - padding: 0 2.85em; - bottom: 0; - align-items: center; - justify-content: center; - border-radius: 10px; - background-color: var(--bgColorMenu); - position: fixed; - z-index: 1000; - transition: background-color 0.8s; -} -.menuItem{ - all: unset; - flex-grow: 1; - z-index: 80; - display: flex; - cursor: pointer; - position: relative; - align-items: center; - justify-content: center; - padding: 0.55em 0 0.85em; - transition: transform var(--duration); -} -.menuItem::before{ - content: ""; - z-index: -1; - width: 4.2em; - height: 4.2em; - border-radius: 50%; + +.tl-rtc-file-side-tool { position: absolute; - transform: scale(0); - transition: background-color 0.8s; - transition: background-color var(--duration), transform var(--duration); -} -.menuItem.active { - transform: translate3d(0, -.8em , 0); -} -.menuItem.active::before{ - transform: scale(1); - background-color: var(--bgColorMenu); + right: 10px; + float: right; + top: 20%; + display: grid; + transition: top 0.5s; } -.menuLowBackground{ - transition: background-color 0.8s; - background-color: #1d1d277a !important; +.tl-rtc-file-side-tool a { + margin-top: 20px; } -.menuLowBackground .menuItem::before{ - transition: background-color 0.8s; - background-color: #4f4f5a7a !important; -} - -.icon{ - width: 2.6em; - height: 2.6em; - stroke: white; - fill: transparent; - stroke-width: 1pt; - stroke-miterlimit: 10; - stroke-linecap: round; - stroke-linejoin: round; - stroke-dasharray: 400; - -} -.menuItem.active .icon { - animation: strok 1.5s reverse; -} -@keyframes strok { - 100% { - stroke-dashoffset: 400; - } -} -.menuBorder{ - left: 0; - bottom: 99%; - width: 10.9em; - height: 2.4em; - position: absolute; - clip-path: url(#menu); - transition: background-color 0.8s; - background-color: var(--bgColorMenu); - transition: transform var(--duration); -} -#fileApp .cusInput{ - border-radius: 10px; - width: 70%; - margin-left: 15%; +.tl-rtc-file-side-tool a i { + font-size: 23px; font-weight: bold; - height: 54px; - padding: 0 10px; - font-size: 16px; - font-family: "微软雅黑"; - border: none; - color: #332828; - vertical-align: middle; - outline: none; - overflow: hidden; - background-color: #e9e9e9; -} -#fileApp .maskBottom{ - position: fixed; - top: 50%; - left: 0; - height: 50%; - width: 100%; - background: white; - z-index: 10000; - box-shadow: 0 0px 20px rgba(0,0,0,.4); - transition: all 1s; - -moz-transition: all 1s; - -webkit-transition: all 1s; - -o-transition: all 1s; + margin-right: 10px; + cursor: pointer; + color: black; } -#fileApp .maskRight{ +.tl-rtc-file-header-intro { + border-radius: 15px; + position: relative; + top: -25px; +} + +.tl-rtc-file-header-intro-txt { + text-align: center; + font-size: 20px; + color: #2E2C2B; + font-weight: bold; +} + +.tl-rtc-file-header-intro-qq { + text-align: center; + font-size: 15px; + color: #2E2C2B; + font-weight: lighter; + margin-bottom: 5px; + margin-top: 8px; +} + +.tl-rtc-file-header-intro-qq a { + font-weight: lighter; +} + +.tl-rtc-file-header-user-online { + color: black; + text-align: center; + font-size: 12px; + margin-bottom: 5px; + margin-top: 8px; +} + +.tl-rtc-file-header-user-online svg { + width: 13px; + height: 8px; +} + +.tl-rtc-file-send-file-tool { + cursor: pointer; + margin: 20px 30px 20px 15%; + max-width: 70%; + background-color: #5C76E7; + border-radius: 15px; + box-shadow: rgba(0, 0, 0, 0.4) 0px 8px 10px +} + +.tl-rtc-file-send-file-tool-i-one { + color: #ffffff0d; + font-size: 70px; + position: absolute; + left: 35px; +} + +.tl-rtc-file-send-file-tool-i-two { + color: #ffffff0d; + font-size: 70px; + position: absolute; + left: 275px; + top: 0px; +} + +.tl-rtc-file-send-file-tool-i-three { + color: white; + font-weight: bold; + font-size: 30px; + position: relative; + top: 10px; +} + +.tl-rtc-file-send-file-tool-send { + font-size: 15px; + letter-spacing: 2px; + margin-top: 30px; + margin-bottom: 20px; + border-radius: 15px; + color: white; + background: #7187e685; + transition: font-size 0.3s; +} + +.tl-rtc-file-send-txt-tool { + cursor: pointer; + margin: 20px 30px 20px 15%; + max-width: 70%; + background-color: #5C76E7; + border-radius: 15px; + box-shadow: rgba(0, 0, 0, 0.4) 0px 8px 10px +} + +.tl-rtc-file-send-txt-tool-i-one { + color: #ffffff0d; + font-size: 80px; + position: absolute; + left: 10px; + top: 100px; +} + +.tl-rtc-file-send-txt-tool-i-two { + color: #ffffff0d; + font-size: 80px; + position: absolute; + right: 10px; +} + +.tl-rtc-file-send-txt-tool-i-three { + color: white; + font-weight: bold; + font-size: 30px; + position: relative; + top: 10px; +} + +.tl-rtc-file-send-txt-tool-send { + font-size: 15px; + letter-spacing: 2px; + margin-top: 30px; + margin-bottom: 20px; + border-radius: 15px; + color: white; + background: #7187e685; + transition: font-size 0.3s; +} + +.tl-rtc-file-tool-list .swiper-slide { + text-align: center; +} + +.tl-rtc-file-receive-list-icon{ + position: fixed; + padding: 0px 10px 0px 10px; + right: 2%; + bottom: 2%; + font-size: 35px; + color: black; +} + +/* .tl-rtc-file-send-file-txt-tool .swiper-slide{ + transition: all 0.3s; +} */ + + +.tl-rtc-file-tool { + cursor: pointer; + background-color: rgb(248 253 255 / 45%); + border-radius: 10px; + display: inline-flex; + /* box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 3px; */ + transition: all 0.3s; +} + +.tl-rtc-file-tool:hover { + box-shadow: rgba(0, 0, 0, 0.4) 0px 7px 14px; +} + +.tl-rtc-file-tool i { + color: black; + margin: 12px 10px 10px 10px; + transition: color 0.8s; +} + +.tl-rtc-file-tool b { + margin: 10px 10px 10px 0; + letter-spacing: 2px; +} + +.tl-rtc-file-tool-disabled, +.tl-rtc-file-tool-disabled i, +.tl-rtc-file-tool-disabled b { + cursor: no-drop !important; + color: #80808061 !important; +} + +.tl-rtc-file-send-file-tool .layui-disabled{ + color: #d2d2d25c !important; +} + + +.tl-rtc-file-user-list { + text-align: center; + padding: 10px 10px 0 10px; +} + +.tl-rtc-file-user { + padding: 10px 20px 0px 10px; + cursor: pointer; + background-color: rgb(248, 253, 255); + border-radius: 10px; + box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 3px; + transition: box-shadow 0.3s; + display: flex; +} + +.tl-rtc-file-user:hover { + box-shadow: rgba(0, 0, 0, 0.4) 0px 7px 14px; +} + +.tl-rtc-file-user-body { + display: flex; + padding-top: 10px; +} + +.tl-rtc-file-send-body svg { + position: absolute; +} + +.tl-rtc-file-user-body-left { + display: grid; + text-align: left; + position: relative; + top: -15px; + margin-right: 50px; +} + +.tl-rtc-file-user-body-left-nick { + margin: 10px; + font-size: 13px; + overflow: hidden; + text-overflow: ellipsis; + word-break: break-all; +} + +.tl-rtc-file-user-body-left-id { + margin-left: 10px; + font-weight: 200; + font-size: 12px; + overflow: hidden; + text-overflow: ellipsis; + word-break: keep-all; +} + +.tl-rtc-file-user-body-right { + position: absolute; + right: 25px; + float: right; + top: 36px; +} + +.tl-rtc-file-user-body-right i { + color: #00000099; + font-size: 18px; + position: relative; + margin-left: 5px; + transition: font-weight 0.3s; +} + +.tl-rtc-file-user-body-right i:hover { + font-weight: bold; +} + +.tl-rtc-file-create-room-btn { + position: fixed; + padding: 0px 10px 0px 10px; + left: 2%; + bottom: 2%; + z-index: 1000; + color: white; + background-color: #79b0e8; + border: 0; + outline: none; + border-radius: 15px; + font-size: 1.4rem; + display: -ms-inline-flexbox; + display: inline-flex; + -ms-flex-align: center; + align-items: center; + -ms-flex-pack: center; + justify-content: center; + height: 48px; + line-height: 50px; + cursor: pointer; + box-shadow: 0 0px 20px rgb(0 0 0 / 40%); + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + transition: all .3s ease; +} + +.tl-rtc-file-exit-room-btn { + position: fixed; + padding: 0px 10px 0px 10px; + left: 2%; + bottom: 2%; + z-index: 1000; + font-weight: bold; + color: white; + background-color: #b2363099; + border: 0; + outline: none; + border-radius: 15px; + display: -ms-inline-flexbox; + display: inline-flex; + font-size: 1.4rem; + -ms-flex-align: center; + align-items: center; + -ms-flex-pack: center; + justify-content: center; + height: 48px; + cursor: pointer; + box-shadow: 0 0px 20px rgb(0 0 0 / 40%); + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + transition: all .2s ease; +} + +.tl-rtc-file-create-room-input { + width: 0%; + position: fixed; + padding: 0px 15px 0px 15px; + left: 2%; + bottom: 2%; + z-index: 1000; + color: white; + background-color: #79b0e8; + border: 0; + outline: none; + border-radius: 15px; + font-size: 1.4rem; + display: -ms-inline-flexbox; + display: inline-flex; + -ms-flex-align: center; + align-items: center; + -ms-flex-pack: center; + justify-content: center; + height: 48px; + box-shadow: 0 0px 20px rgb(0 0 0 / 40%); + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + transition: all .3s ease; +} + +.tl-rtc-file-send-file-list-btn { + position: absolute; + padding: 0px 15px 0px 15px; + right: 2%; + bottom: 2%; + z-index: 1000000; + font-weight: bold; + color: white; + background-color: #3052bcb0; + border: 0; + outline: none; + border-radius: 15px; + display: -ms-inline-flexbox; + display: inline-flex; + font-size: 1.4rem; + -ms-flex-align: center; + align-items: center; + -ms-flex-pack: center; + justify-content: center; + height: 50px; + cursor: pointer; + box-shadow: 0 0px 20px rgb(0 0 0 / 40%); + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + transition: all .3s ease; +} + +.tl-rtc-file-create-room-btn:hover, +.tl-rtc-file-exit-room-btn:hover, +.tl-rtc-file-send-file-list-btn:hover { + box-shadow: 0 8px 35px rgba(0, 0, 0, .4); + transition: all .2s ease; + -webkit-tap-highlight-color: rgba(4, 32, 23, .2); +} + +.tl-rtc-file-create-room-btn i, +.tl-rtc-file-exit-room-btn i, +.tl-rtc-file-send-file-list-btn i { + font-size: 18px; + margin-right: 10px; +} + +.tl-rtc-file-create-room-btn b, +.tl-rtc-file-exit-room-btn b, +.tl-rtc-file-send-file-list-btn div { + font-size: 14px; + word-break: keep-all; +} + +.tl-rtc-file-mask-media-list { position: fixed; top: 0; left: 50%; @@ -170,416 +471,160 @@ body{ -o-transition: all 1s; } -.sendTxt{ - background-color: var(--bgColorBody); - margin-top: -38px; - border-radius: 20px; - border-top-left-radius: 0px; - border-top-right-radius: 0px; - border-top: solid 1px; - width: 50%; -} - -.setting-main{ - height: 100%; - background-color: #fff; - position: relative; - left: 0; - top: 0; -} - -.setting-main-body{ - position: relative; - width: 100%; - height: 100%; - overflow: hidden; -} - -.setting-main-body ul{ - padding: 15px; - margin: 0px; - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - background-color: #f8f8f8; - transition-duration: .3s; - -webkit-transition-duration: .3s; -} - -.setting-main-body ul li{ - text-align: center; - cursor: pointer; - margin-bottom: 15px; -} - -.setting-main-body ul li cite { - font-weight: bold; - position: relative; - top: 2px; - display: block; - color: #e4d8d8; - text-overflow: ellipsis; - overflow: hidden; - white-space: nowrap; - font-size: 14px; -} - -.setting-main-body ul li i { - display: inline-block; - width: 100%; - height: 60px; - line-height: 60px; - text-align: center; - border-radius: 2px; - font-size: 30px; - color: #333; - transition: all .3s; - -webkit-transition: all .3s; -} - -#fileApp table tr td span{ - word-break: break-all; -} -#fileApp .exitBtn{ - position: absolute; - right: 20%; -} -#fileApp .roomClass{ - margin-top: 5%; - transition : margin-top 0.5s; -} -#fileApp .roomClass button{ - -webkit-appearance: none; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - display: flex; - align-items: center; - justify-content: center; - outline: none; - cursor: pointer; - width: 7rem; - height: 3rem; - background-image: linear-gradient(to top, #D8D9DB 0%, #fff 80%, #FDFDFD 100%); - border-radius: 30px; - border: 1px solid #8F9092; - box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 3px 0 #CECFD1; - transition: all 0.2s ease; - font-family: "Source Sans Pro", sans-serif; - font-size: 12px; - font-weight: 600; - color: #606060; - text-shadow: 0 1px #fff; - margin-left: 20px; - margin-right: 20px; -} -#fileApp .roomClass button[disabled]{ - border: 1px solid #e6e6e6; - background-color: #FBFBFB; - color: #C9C9C9; - cursor: not-allowed; - opacity: 1; -} -#fileApp .roomClass button:hover{ - box-shadow: 0 4px 3px 1px #FCFCFC, 0 6px 8px #D6D7D9, 0 -4px 4px #CECFD1, 0 -6px 4px #FEFEFE, inset 0 0 3px 3px #CECFD1; -} -#fileApp .roomClass .center{ - padding: 10px; - display: inline-flex; - width: 70%; - margin-left: 15%; - margin-top: 20px; -} -#fileApp .roomClass .mobileCenter{ - padding: 10px; - display: inline-flex; - width: 100%; - margin-top: 20px; -} -#fileApp #self{ - width: 70%; - margin-left: 15%; - margin-top: 20px; -} -#fileApp #self span{ - margin-bottom: 10px; -} -#fileApp #self input{ - margin-bottom: 10px; - width: 72px; -} -#fileApp #self button{ - margin-bottom: 10px; -} -.sendFileBtn { +.tl-rtc-file-mask-send-file-list { position: fixed; - padding: 0 25px; - right: 20px; - bottom: 80px; - z-index: 1000000; - color: #0d1322; - background-color: #3be8b0; - border: 0; - outline: none; - border-radius: 25px; - font-size: 1.4rem; - display: -ms-inline-flexbox; - display: inline-flex; - -ms-flex-align: center; - align-items: center; - -ms-flex-pack: center; - justify-content: center; - height: 50px; - line-height: 50px; - cursor: pointer; - box-shadow: 0 0px 20px rgb(0 0 0 / 40%); - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - transition: all .2s ease; -} -.sendFileBtn-disable { - margin-left: 30%; - border: 0; - padding: 0 25px; - outline: none; - width: 40%; - border-radius: 25px; - font-size: 1.4rem; - display: -ms-inline-flexbox; - display: inline-flex; - -ms-flex-align: center; - align-items: center; - -ms-flex-pack: center; - justify-content: center; - height: 50px; - line-height: 50px; - cursor: pointer; - box-shadow: 0 0px 20px rgba(0,0,0,.4); - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -.sendFileBtn:hover{ - box-shadow: 0 8px 35px rgba(0,0,0,.4); - transition: all .2s ease; - -webkit-tap-highlight-color: rgba(4,32,23,.2); -} - -.side-shadown-rigth{ - border-radius: 50%; - position: absolute; - width: 10px; - height: 100%; - right: 0; - background: -webkit-gradient(linear,left top,right top,from(hsla(0,0%,94.1%,0)),to(rgb(155 90 9))); - background: -webkit-linear-gradient(left,hsla(0,0%,94.1%,0),rgb(155 90 9)); - background: -o-linear-gradient(left,hsla(0,0%,94.1%,0) 0,rgb(155 90 9) 100%); - background: linear-gradient(270deg,hsla(0,0%,94.1%,0),rgb(155 90 9)); - opacity: .5; -} - -.side-shadown-left{ - border-radius: 50%; - position: absolute; - width: 10px; - height: 100%; + border-top-left-radius: 15px; + border-top-right-radius: 15px; + top: 20%; left: 0; - background: -webkit-gradient(linear,left top,right top,from(hsla(0,0%,94.1%,0)),to(rgb(155 90 9))); - background: -webkit-linear-gradient(left,hsla(0,0%,94.1%,0),rgb(155 90 9)); - background: -o-linear-gradient(left,hsla(0,0%,94.1%,0) 0,rgb(155 90 9) 100%); - background: linear-gradient(270deg,hsla(0,0%,94.1%,0),rgb(155 90 9)); - opacity: .5; + height: 80%; + width: 100%; + background: white; + z-index: 10000; + box-shadow: 0 0px 20px rgba(0, 0, 0, .4); + transition: all 1s; + -moz-transition: all 1s; + -webkit-transition: all 1s; + -o-transition: all 1s; } -.tool{ - position: absolute; - right: 10px; - float: right; - top: 30%; - display: grid; - transition: top 0.5s; +.tl-rtc-file-choose-file-list { + width: 100%; + box-shadow: 0 0px 20px rgb(255 255 255 / 40%); } -.tool a{ +.tl-rtc-file-send-list-all { margin-top: 10px; + padding-bottom: 30px; } -.tool svg{ - width: 30px; - height: 30px; + +.tl-rtc-file-send-list { + text-align: center; + padding: 10px 10px 0 10px; +} + +.tl-rtc-file-send { + padding: 10px 20px 0px 10px; + cursor: pointer; + background-color: rgb(248, 253, 255); + border-radius: 10px; + box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 3px; + display: flex; + background: linear-gradient(90deg, #ffffff, #b8bff773 var(--progress), transparent 0); + transition: all 0.3s; +} + +.tl-rtc-file-send:hover { + box-shadow: rgba(0, 0, 0, 0.4) 0px 7px 14px; +} + +.tl-rtc-file-send-body { + display: flex; + padding-top: 10px; +} + +.tl-rtc-file-send-body svg{ + position: absolute; +} + +.tl-rtc-file-send-body-left { + display: grid; + text-align: left; + position: relative; + top: -15px; + left: 32px; + margin-right: 32px; +} + +.tl-rtc-file-send-body-left-nick { + margin: 10px; + font-size: 13px; + overflow: hidden; + text-overflow: ellipsis; + word-break: break-all; + font-family: monospace; +} + +.tl-rtc-file-send-body-left-id { + margin-left: 10px; + font-weight: 200; + font-size: 12px; + overflow: hidden; + text-overflow: ellipsis; + word-break: keep-all; +} + +.tl-rtc-file-send-body-left-icon { + margin: 10px 10px 0px; + font-weight: 100; + transition: font-weight 0.3s; +} + +.tl-rtc-file-send-body-left-icon:hover { + font-weight: bold; +} + +.tl-rtc-file-send-body-right { + font-family: monospace; + position: absolute; + right: 25px; + float: right; + top: 40px; +} + +.tl-rtc-file-send-body-right i { + color: #00000099; + font-size: 18px; + position: absolute; + right: -10px; cursor: pointer; } -#refresh { - cursor: pointer; - left: 75%; +.tl-rtc-file-msg-dot { + padding: 0px 0px; position: absolute; - font-size: 24px; - margin-top: -40px; - transition: left .5s; + border-radius: 50%; + height: 12px; + width: 12px; + line-height: 12px; + right: -10px; + top: -8px; } -.onlineCount{ - text-align: center; - font-size: 12px; - color: beige; - margin-bottom: 5px; - margin-top: 8px; -} - -.userRoom{ - padding-left: 15px !important; - width: 80%; - margin-left: 10% !important; - height: 130px; - display: inline-flex; -} -.userBlock{ - text-align: center; - font-weight: bold; - cursor: pointer !important; - margin: 0 0 15px !important; - display: grid !important; -} - -.fileRoom{ - margin-top: 1%; - width: 100%; - height: auto; - display: inline-flex; -} -.fileBlock{ - margin-right: 15px !important; - cursor: pointer !important; - display: grid !important; - color: bisque; -} - -video{ - width: 100%; -} - -.mediaShareRoom{ - border-radius: 20px; - padding-left: 15px !important; - width: 80%; - margin-left: 10% !important; - margin-top: 8%; - display: inline-flex; -} -.mediaShareBlock{ - width: 48% !important; - margin-right: 1% !important; - cursor: pointer !important; - display: grid !important; - color: bisque; -} - -.chooseFileName { - word-break: break-all; - padding: 7px 3px 7px 3px; - background: rgb(255, 180, 87); - border-radius: 6px; - display: grid; - margin: 10px auto; - margin-top: 20px; - transition: all 1s; -} -.remoteId{ - margin-top: 0; - position: relative; +.tl-rtc-file-mask-log-list { + position: fixed; top: 0; - right: 0; - word-break: break-all; - height: auto; + left: 50%; + height: 100%; + width: 50%; + background: white; + z-index: 10000; + box-shadow: 0 0px 20px rgb(0 0 0 / 40%); + transition: all 1s; + -moz-transition: all 1s; + -webkit-transition: all 1s; + -o-transition: all 1s; } -.sendFilePannel{ - transition: all .2s ease-in-out; - border-radius: 5px; - box-shadow: 0 8px 35px rgba(0,0,0,.4); -} -.sendFileHeader{ - border-bottom: 1px solid #fbe1e1; - padding: .3rem 1rem; - display: -ms-flexbox; - display: flex; - -ms-flex-align: baseline; - align-items: baseline; - -ms-flex-pack: justify; - justify-content: space-between; - font-size: 15px; -} -.sendFiles{ - margin: 5px 0; - max-height: 330px; - padding: 0 0px 10px; -} -.sendFile{ - display: -ms-flexbox; - display: flex; - -ms-flex-align: center; - align-items: center; - max-height: 340px; - padding: 5px 5px 4px; - overflow-x: hidden; - margin: 5px 11px; -} -.sendFileType{ - margin-right: 1rem; - color: #636979; -} -.sendFileInfo{ - text-align: left; - -ms-flex: 1; - flex: 1; - width: 60%; - margin-right: 1rem; -} -.sendFileName{ - font-weight: 500; - font-size: 15px; - margin-bottom: 5px; - text-overflow: ellipsis; - overflow-x: hidden; - white-space: nowrap; - width: 100%; -} -.sendFileOther{ - margin: 0; - font-weight: 500; - color: #636979; - font-size: 12px; -} -.sendInfoBackgroud{ - display: none; - background: #ff00002e; - width: 116px; - height: 40px; - position: absolute; - padding: 25px; - border-radius: 3px; - margin-left: -20px; -} -.logs{ +.tl-rtc-file-mask-log { text-align: center; border-bottom: 1px solid #f6f6f6; word-break: break-all; } -.logs .logs-time{ - font-size: 12px; - text-align: left; + +.tl-rtc-file-mask-log input { + border-radius: 4px; + padding-right: 10px; +} + +.tl-rtc-file-mask-log .tl-rtc-file-mask-log-time { + font-size: 12px; + text-align: left; font-weight: bold; } -.logs .logs-time svg{ +.tl-rtc-file-mask-log .tl-rtc-file-mask-log-time svg { width: 16px; height: 16px; position: absolute; @@ -587,157 +632,126 @@ video{ top: 14px; } -.logs .logs-msg{ +.tl-rtc-file-mask-log .tl-rtc-file-mask-log-msg { margin: 10px 0 10px 0; text-align: left; - border: 1px dashed #e2e2e2; - border-radius: 4px; - padding: 5px; + border: 1px dashed #e2e2e2; + border-radius: 4px; + padding: 5px; background: #f1f8fe; } -.infoMsg{ - width: 70%; - margin-left: 15%; - text-align: center; - font-size: 0.1rem; -} -.layui-table td, .layui-table th{ - font-size: 12px !important; -} - -.layui-btn-disabled, .layui-btn-disabled:active, .layui-btn-disabled:hover { - border-color: #eee!important; - background-color: #fbfbfb!important; - color: #d2d2d2!important; - cursor: not-allowed!important; - opacity: 1; -} - -.layui-layedit { - border: none; - border-radius: 20px; - box-shadow: 0 0px 20px rgb(255 255 255 / 40%); -} - -.new-dot { - padding: 0px 3px; - position: absolute; - border-radius: 50%; - height: 18px; - width: 18px; - font-size: 10px; - line-height: 18px; - right: -5px; -} - -.toolList { - transition: all 0.3s ease-in-out; +.setting-main { + height: 100%; + background-color: #fff; position: relative; - right: 0; - width: 40px; - height: 40px; - display: grid; + left: 0; + top: 0; } -.toolList a { - z-index: 10000; +.setting-main-body { + position: relative; + width: 100%; + height: 100%; + overflow: hidden; +} + +.setting-main-body ul { + padding: 15px; + margin: 0px; position: absolute; - font-size: 24px; - color: #d8c9c9; - background-color: rgb(244 129 80 / 0%); + left: 0; + top: 0; + width: 100%; + height: 100%; + background-color: #f8f8f8; + transition-duration: .3s; + -webkit-transition-duration: .3s; +} + +.setting-main-body ul li { + text-align: center; cursor: pointer; - transition: transform 0.5s ease-in-out; } -.toolList a:hover { - color: #fff; +.setting-main-body ul li cite { + font-weight: bold; + position: relative; + top: 2px; + display: block; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + font-size: 14px; } -.toolList.fan-out a { - opacity: 1; - transform: translate(-50%, -50%) scale(1); -} - -#closeTool{ - height: 32px; - transform: translate(0%, -50%) scale(1); - width: 40px; - top: 15px; - right: 1px; - background-color: rgb(75, 75, 74); -} - -.toolList.fan-out a:nth-child(1) { - transform: translate(-20%, 0%) rotate(-180deg) translateY(-100px) scale(1); -} - -.toolList.fan-out a:nth-child(2) { - transform: translate(-20%, 0%) rotate(-150deg) translateY(-100px) scale(1); -} - -.toolList.fan-out a:nth-child(3) { - transform: translate(-20%, 0%) rotate(-120deg) translateY(-100px) scale(1); -} - -.toolList.fan-out a:nth-child(4) { - transform: translate(-20%, 0%) rotate(-90deg) translateY(-100px) scale(1); -} - -.toolList.fan-out a:nth-child(5) { - transform: translate(-20%, 0%) rotate(-60deg) translateY(-100px) scale(1); -} - -.toolList.fan-out a:nth-child(6) { - transform: translate(-20%, 0%) rotate(-30deg) translateY(-100px) scale(1); -} - -.toolList.fan-out a:nth-child(7) { - transform: translate(-20%, 0%) rotate(0deg) translateY(-100px) scale(1); -} - -.toolDisabled i, .toolDisabled svg path{ - cursor: no-drop !important; - color: grey !important; - fill: grey !important; +.setting-main-body ul li i { + display: inline-block; + width: 100%; + height: 60px; + line-height: 60px; + text-align: center; + border-radius: 2px; + font-size: 30px; + color: #333; + transition: all .3s; + -webkit-transition: all .3s; } -/* 480px以下 */ -@media screen and (max-width: 480px) { - #fileApp .exitBtn{ - position: absolute; - right: 10%; - } - #fileApp .roomClass button{ - width: 6rem; - height: 2.5rem; - } - #fileApp .roomClass .center{ - width: 100%; - margin-top: 20px; - margin-left: 0; - } - #refresh{ - left: 70%; - } -} /* 500px以下 */ @media screen and (max-width: 500px) { + .tl-rtc-file-send-txt-tool-send{ + font-size: 12px; + font-weight: bold; + } + .tl-rtc-file-send-file-tool-send { + font-size: 12px; + font-weight: bold; + } } /* 480px到765px */ @media screen and (min-width: 480px) and (max-width: 765px) { + } /* 765px到1280px */ @media screen and (min-width: 765px) and (max-width: 1280px) { - #refresh{ - left: 77%; - } + } /** 1280px以上 */ @media screen and (min-width: 1280px) { - #refresh{ - left: 79%; - } + +} + + +.tl-rtc-file-mask-media-container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100%; + width: 100%; +} + +.tl-rtc-file-mask-media-video { + display: flex; + justify-content: center; + align-items: center; + height: 50%; + width: 100%; + background-color: black; + margin-bottom: 15px; +} + +.tl-rtc-file-mask-media-video video{ + height: 100%; + width: 100%; + object-fit: cover; +} + +.tl-rtc-file-mask-media-video b{ + position: absolute; + left: 20px; + top: 10px; } \ No newline at end of file diff --git a/res/home.html b/res/home.html index 698e36c..776e335 100644 --- a/res/home.html +++ b/res/home.html @@ -17,7 +17,7 @@ font-family: Rubik,Fallback; width: 100%; height: 100%; - background: linear-gradient(90deg, rgb(128 117 103), rgb(252, 182, 159)); + background-image: linear-gradient(to right, #C5EDFF, #E6F7FF, #E6F7FF, #E6F7FF, #E6F7FF, #C5EDFF, #C5EDFF); } .layui-nav{ text-align: right; @@ -31,7 +31,7 @@ top: 15px; font-size: 20px; font-weight:bolder; - -webkit-text-stroke:1px #ffffff; + -webkit-text-stroke:1px black; -webkit-text-fill-color:transparent; position: absolute; z-index: 10000; @@ -48,13 +48,13 @@ text-align: center; } .tl-rtc-file-intro-main{ - color: #fcfcfc; + color: black; font-size: 36px; font-weight: 300; } .tl-rtc-file-intro-tag{ margin-top: 30px; - color: #fcfcfc; + color: black; font-size: 25px; font-weight: 300; width: 70%; @@ -82,7 +82,7 @@ .tl-rtc-file-goto-btn{ width: 20%; padding: 0 25px; - background-color: #b6c95e; + background-color: #5963af; border: 0; font-weight: bold; outline: none; @@ -133,17 +133,17 @@ - +
@@ -174,7 +174,7 @@
- Copyright @ 2021 iamtsm + Copyright @ 2021 ~ 2023 iamtsm
@@ -196,7 +196,7 @@ , btnAlign: 'c' , moveType: 1 , content: ` -
+
如需支持功能定制,或技术支持,加群联系我即可
qq群交流群 : diff --git a/res/home_en.html b/res/home_en.html index f31ae94..7eccc0a 100644 --- a/res/home_en.html +++ b/res/home_en.html @@ -17,7 +17,7 @@ font-family: Rubik,Fallback; width: 100%; height: 100%; - background: linear-gradient(90deg, rgb(128 117 103), rgb(252, 182, 159)); + background-image: linear-gradient(to right, #C5EDFF, #E6F7FF, #E6F7FF, #E6F7FF, #E6F7FF, #C5EDFF, #C5EDFF); } .layui-nav{ text-align: right; @@ -31,7 +31,7 @@ top: 15px; font-size: 20px; font-weight:bolder; - -webkit-text-stroke:1px #ffffff; + -webkit-text-stroke:1px black; -webkit-text-fill-color:transparent; position: absolute; z-index: 10000; @@ -48,13 +48,13 @@ text-align: center; } .tl-rtc-file-intro-main{ - color: #fcfcfc; + color: black; font-size: 36px; font-weight: 300; } .tl-rtc-file-intro-tag{ margin-top: 30px; - color: #fcfcfc; + color: black; font-size: 25px; font-weight: 300; width: 70%; @@ -82,7 +82,7 @@ .tl-rtc-file-goto-btn{ width: 20%; padding: 0 25px; - background-color: #b6c95e; + background-color: #5963af; border: 0; font-weight: bold; outline: none; @@ -134,15 +134,15 @@
@@ -199,7 +199,7 @@ , btnAlign: 'c' , moveType: 1 , content: ` -
+
If you need support or feature customization or help, just add a qq group to contact me
qq number : diff --git a/res/index.html b/res/index.html index 44daf06..9309c37 100644 --- a/res/index.html +++ b/res/index.html @@ -9,8 +9,8 @@ - + @@ -23,10 +23,6 @@ window.Bus = new Vue({}); window.prefix = ""; - - @@ -35,17 +31,19 @@
-
-
+
+ + + -
- + + -
注 : 仅用于学习用途, 请勿他用
-
qq交流群 : 624214498
-
- - - - 当前在线人数 : {{allManCount}} -
-
- - -
- - + +
+
注 : 仅用于学习用途, 请勿他用
+
qq交流群 : 624214498
+
+ + + + 当前在线人数 : {{allManCount}}
-
- -
- -
-
- -

(当前禁选),请确保双方先加入房间,才可选择文件发送,支持多文件拖拽发送

-
-
- -

正在发送中...

-

当前已发送 {{getFileSizeStr(currentSendAllSize)}} -

-
-
-
- - - - - {{file.name}} + +
+
+
+
+
+ + + + + {{Math.min(sendFileList.length, 99)}} +
+
+ +
-
-
- -

点击选取文件,或将文件拖拽到此处,支持多文件拖拽发送

-
-
-
- - - - - {{file.name}} +
+
+
+ + + + + {{Math.min(receiveTxtList.length, 99)}} + +
+
+
-
- - - + +
+
+
+
+ + 公共聊天 + +
+
+
+
+ + 屏幕共享 +
+
+
+
+ + 视频通话 +
+
+
+
+ + 屏幕录制 +
+
+
+
+ + AI 聊天 +
+
+
+
+ + 密码房间 +
+
+
+
+ + 取件码 +
+
+
-
-
-
-
发送的文件/文本 - + +
+
+
+
+ + + + + + + + + + +
+ {{nickName}} - 自己 + {{socketId}} +
-
- - - - - - - - - - - - - - - - - - - - - -
- 进度: - +
+ + + + {{Math.min(receiveFileList.length, 99)}} + +
+
+ + + + +
+
+
+
+ + + + + + + + + +
+ {{remote.nickName}} + {{remote.id}} +
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ +
+ +
+ + + + {{Math.min(receiveFileList.length, 99)}} + +
+
+ + +
+
+
+ 待发送({{chooseFileList.length}})- 共{{Object.keys(remoteMap).length}}人 - 共需发送{{sendFileList.length}}次 + +
+
+ +

点击选取文件,或将文件拖拽到此处,支持多文件拖拽发送

+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 名称: {{file.name}}, 类型: {{file.type === '' ? '未知类型' : file.type}}, 大小: {{getFileSizeStr(file.size)}} + + + 发送给: {{file.id}} - {{file.nickName}} - {{file.process}}% - {{file.cost}}s + + + + +
-
-
名称格式大小进度耗时暂存状态暂存进度{{uploadCodeFileProcess}}%
{{file.name}}
{{file.type}}{{getFileSizeStr(file.size)}}{{file.process}}%{{file.cost}}秒暂存 -
+
+
+ +
+
+ +
+
+ +
+
-
-
-
-
接收的文件 - -
-
- - - - - - - - - - - - - - - - - - - - - -
- 进度: - + +
+
+
+ 共接收{{receiveFileList.length}}个文件 + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + 名称: {{file.name}}, 类型: {{file.type === '' ? '未知类型' : file.type}}, 大小: {{getFileSizeStr(file.size)}} + + + 文件来自: {{file.id}} - {{file.nickName}} - {{file.process}}% - {{file.cost}}s + + + + + +
-
-
用户名称格式大小进度耗时
{{file.id}}
{{file.name}}
{{file.name}}
{{file.type}}{{getFileSizeStr(file.size)}}{{file.process}}%{{file.cost}}秒
+
+
+ +
+
-
-
-
-
- 接收的文本内容 - -
-
- - - - - - - - - - - - - - - -
发送方ID接收内容接收时间
{{txt.id}} - - -
{{txt.content}}
-
-
{{txt.time}}
-
-
-
-
- - -
-
-
-
- 取件码接收的文件 - -
-
- - - - - - - - - - - - - - - -
取件码文件名称文件大小
{{code.codeId}}
{{code.name}}
{{code.size}}
-
-
-
-
- -
+ +
@@ -485,14 +686,14 @@
-
- +
+
-
-
-
+
+
+
{{log.time}}
@@ -507,14 +708,15 @@ fill="#FFFFFF" p-id="2765">
-
- {{log.type}} - {{log.type}} +
+ {{log.type}} + {{log.type}} {{log.msg}}
-
- {{log.type}} - {{log.type}} +
+ {{log.type}} + {{log.type}} {{log.msg}}
@@ -523,161 +725,46 @@
-
-
-
-
-
- -
-
-
-
-
-
自己
-
- - - - - - - - - -
-
-
{{nickName}}
+ +
+
+
+
+ 音视频通话 +
-
-
- - - - - - - - - +
+
+
+
+
-
{{remote.nickName}}
-
- - - - - - - - - - - - -
- - - - - + +
+
+
+
+ 屏幕共享 + +
+
+
+
+
+
+
+
+
+
+
@@ -687,55 +774,6 @@ +
+
+ + +
+ ` + } + if (this.isMobile) { + delete options.area + } + layer.closeAll(function () { + let index = layer.open(options) + if (that.isMobile) { + layer.full(index) + } + }) + } + this.addUserLogs("打开公共聊天面板") + }, + chatingCommTpl: function () { + let that = this; + let tpl_html = document.getElementById("chating_comm_tpl"); + let tpl_view_html = document.getElementById("chating_comm_tpl_view"); + + if (tpl_html && tpl_view_html) { + + this.tpl(tpl_html, this.chatingCommList, tpl_view_html) + + let chatDom = document.querySelector("#chating_comm_tpl_view") + let chatDomHeight = chatDom.clientHeight + + let height = 0; + if (this.isMobile) { + height = document.documentElement.clientHeight - 235; + } else { + height = 350 + } + + if (chatDomHeight > height) { + chatDom.style.height = height + "px" + chatDom.style.overflowY = "scroll" + } else { + chatDom.style.overflowY = "none" + } + + if(window.tlrtcfile.scrollToBottom){ + window.tlrtcfile.scrollToBottom(chatDom, 1000, 100) + } + } + }, + tpl: function (tpl_html, data, tpl_view_html, callback) { + if (window.laytpl) { + laytpl(tpl_html.innerHTML).render(data, (html) => { + tpl_view_html.innerHTML = html; + if (callback) { + callback() + } + }); + } + }, + sendChatingComm: function () { + if (!this.isJoined) { + if (window.layer) { + layer.msg("请先加入房间,才能发言哦") + } + this.addUserLogs("请先加入房间,才能发言哦") + return + } + let content = document.querySelector("#chating_comm_value").value; + if (content === '' || content === undefined) { + if (window.layer) { + layer.msg("请先填写内容哦") + } + this.addUserLogs("请先填写内容哦") + return + } + if (content.length > 1000) { + if (window.layer) { + layer.msg("内容太长啦,不能超过1000个字") + } + this.addUserLogs("内容太长啦,不能超过1000个字") + return + } + this.socket.emit('chatingComm', { + msg: encodeURIComponent(content), + room: this.roomId, + socketId: this.socketId, + }); + + this.addUserLogs("公共频道发言成功"); + + document.querySelector("#chating_comm_value").value = '' + }, + // 房间内群聊弹窗 + openChatingRoom: function () { + let that = this; + if (window.layer) { + let options = { + type: 1, + fixed: false, //不固定 + maxmin: false, + area: ['600px', '600px'], + title: `【${this.roomId}】` + "聊天频道", + success: function (layero, index) { + if (window.layer && window.layui && window.layedit) { + that.txtEditId = layedit.build('chating_room_value', { + tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right', 'face'], + height: 120 + }); + } + that.chatingRoomTpl(); + }, + content: ` +
+
+ +
+
+ + +
+ ` + } + if (this.isMobile) { + delete options.area + } + layer.closeAll(function () { + let index = layer.open(options) + if (that.isMobile) { + layer.full(index) + } + }) + } + this.addUserLogs("打开房间聊天面板") + }, + // 房间内群聊渲染 + chatingRoomTpl: function () { + let tpl_html = document.getElementById("chating_room_tpl"); + let tpl_view_html = document.getElementById("chating_room_tpl_view"); + + if (tpl_html && tpl_view_html) { + + this.tpl(tpl_html, this.receiveTxtList, tpl_view_html) + + let chatDom = document.querySelector("#chating_room_tpl_view") + let chatDomHeight = chatDom.clientHeight + + let height = 0; + if (this.isMobile) { + height = document.documentElement.clientHeight - 335; + } else { + height = 300 + } + + if (chatDomHeight > height) { + chatDom.style.height = height + "px" + chatDom.style.overflowY = "scroll" + } else { + chatDom.style.overflowY = "none" + } + + if(window.tlrtcfile.scrollToBottom){ + window.tlrtcfile.scrollToBottom(chatDom, 1000, 100) + } + } + }, + // 房间内群聊发言 + sendChatingRoom: function () { + if (!this.isJoined) { + if (window.layer) { + layer.msg("请先加入房间,再发送内容") + } + this.addUserLogs("请先加入房间,再发送内容"); + return + } + if (!this.hasManInRoom) { + if (window.layer) { + layer.msg("房间内至少需要两个人才能发送内容") + } + this.addUserLogs("房间内至少需要两个人才能发送内容"); + return + } + let realContent = layedit.getContent(this.txtEditId) + if (realContent.length <= 0) { + if (window.layer) { + layer.msg("请输入文本内容") + } + this.addUserLogs("请输入文本内容"); + return + } + if (realContent.length > 10000) { + if (window.layer) { + layer.msg("文字内容过长,长度最多1w单词!") + } + this.addUserLogs("文字内容过长,长度最多1w单词"); + return + } + this.socket.emit('message', { + emitType: "sendChatingRoom", + content: encodeURIComponent(realContent), + room: this.roomId, + from: this.socketId, + nickName : this.nickName, + recoderId: this.recoderId + }); + + let now = new Date().toLocaleString(); + this.receiveTxtList.push({ + socketId: this.socketId, + content: realContent, + nickName : this.nickName, + time: now, + timeAgo : window.util ? util.timeAgo(now) : now + }); + + this.chatingRoomTpl(); + + layer.msg("文本内容发送完毕") + this.addUserLogs("文本内容发送完毕"); + + layedit.setContent(this.txtEditId, "", false) + }, + useTurnMsg: function () { + if (window.layer) { + layer.msg("当前已启用中继服务器,更多信息请到设置查看") + } + this.addUserLogs("当前已启用中继服务器,更多信息请到设置查看") + }, + networkMsg: function () { + if (window.layer) { + layer.msg("当前网络状态为" + (this.network !== 'wifi' ? '移动流量' : this.network)) + } + this.addUserLogs("当前网络状态为" + (this.network !== 'wifi' ? '移动流量' : this.network)) + }, + addPopup: function (msg) { + window.Bus.$emit("addPopup", msg); + }, + cleanPopup: function () { + window.Bus.$emit("popupMap"); + }, + addSysLogs: function (msg) { + this.addLogs(msg, "【系统日志】: ") + }, + addUserLogs: function (msg) { + this.addLogs(msg, "【操作日志】: ") + }, + addLogs: function (msg, type) { + if (this.logs.length > 1000) { + this.logs.shift(); + } + this.logs.unshift({ + type: type, + msg: msg, + time: new Date().toLocaleString() + }) + }, + cleanLogs: function () { + this.logs = [] + this.addSysLogs("清空日志") + }, + sendBugs: function () { + if (window.layer) { + let that = this; + $("#sendBugs").removeClass("layui-anim-rotate") + setTimeout(() => { + $("#sendBugs").addClass("layui-anim-rotate") + }, 50) + setTimeout(() => { + layer.prompt({ + formType: 2, + title: '请描述您需要反馈的问题', + }, function (value, index, elem) { + that.socket.emit('message', { + emitType: "sendBugs", + msg: value, + room: that.roomId, + }); + layer.msg("问题反馈成功,更多问题可以加群交流,将更快解决") + layer.close(index); + that.addUserLogs("问题反馈成功,更多问题可以加群交流,将更快解决 ,问题:" + value); + }); + }, 500); + } + }, + refleshRoom: function () { + if (!this.isJoined) { + this.roomId = parseInt(Math.random() * 100000); + this.addPopup("你刷新了房间号, 当前房间号为 " + this.roomId); + this.addUserLogs("你刷新了房间号, 当前房间号为 " + this.roomId); + } + }, shareUrl: function () { document.querySelector("#shareUrl").setAttribute("data-clipboard-text", window.location.href + "#r=" + this.roomId); var clipboard = new ClipboardJS('#shareUrl'); @@ -989,6 +1280,7 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { layer.confirm("进入房间" + this.roomId, (index) => { window.location.hash = ""; layer.close(index) + that.openRoomInput = true; that.createFileRoom(); }, (index) => { that.roomId = ""; @@ -1001,490 +1293,101 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { } } }, - chating: function () { - if (!this.switchData.openCommRoom) { - if (window.layer) { - layer.msg("当前功能已暂时关闭,有问题可以加群交流") - } - this.addUserLogs("当前功能已暂时关闭,有问题可以加群交流") - return - } - let that = this; + // 赞助 + coffee: function () { if (window.layer) { let options = { type: 1, - fixed: false, //不固定 + fixed: false, maxmin: false, - area: ['600px', '600px'], - title: "公共聊天频道", + shadeClose: true, + area: ['300px', '350px'], + title: "赞助一下,为爱发电", success: function (layero, index) { - let active = null; - if (that.currentMenu === 1) { - active = document.querySelector("#btnHome"); - } else if (that.currentMenu === 2) { - active = document.querySelector("#btnReceive"); - } else if (that.currentMenu === 3) { - active = document.querySelector("#btnTxt"); - } else if (that.currentMenu === 4) { - active = document.querySelector("#btnCodeFile"); - } - document.querySelector(".layui-layer-title").style.borderTopRightRadius = "15px" - document.querySelector(".layui-layer-title").style.borderTopLeftRadius = "15px" - document.querySelector(".layui-layer-title").style.color = "white"; - document.querySelector(".layui-layer").style.borderRadius = "15px" - document.querySelector(".chating-content").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector(".layui-textarea").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector(".layui-layer-title").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector(".layui-layer").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - - that.chatingTpl(); + document.querySelector(".layui-layer-title").style.borderTopRightRadius = "8px"; + document.querySelector(".layui-layer-title").style.borderTopLeftRadius = "8px"; + document.querySelector(".layui-layer").style.borderRadius = "8px"; }, - content: ` -
-
- -
-
- - -
- ` - } - if (this.isMobile) { - delete options.area + content: `img ` } layer.closeAll(function () { - let index = layer.open(options) - if (that.isMobile) { - layer.full(index) - } + layer.open(options) }) } - this.addUserLogs("打开公共聊天面板") - }, - chatingTpl: function () { - let tpl_html = document.getElementById("chating_tpl"); - let tpl_view_html = document.getElementById("chating_tpl_view"); - - if (tpl_html && tpl_view_html) { - - this.tpl(tpl_html, this.chatingList, tpl_view_html) - - let chatDom = document.querySelector("#chating_tpl_view") - let chatDomHeight = chatDom.clientHeight - - let height = 0; - if (this.isMobile) { - height = document.documentElement.clientHeight - 235; - } else { - height = 350 - } - if (chatDomHeight > height) { - chatDom.style.height = height + "px" - chatDom.style.overflowY = "scroll" - } else { - chatDom.style.overflowY = "none" - } - - if(window.tlrtcfile.scrollToBottom){ - window.tlrtcfile.scrollToBottom(chatDom, 1000, 100) - } - } - }, - tpl: function (tpl_html, data, tpl_view_html, callback) { - if (window.laytpl) { - laytpl(tpl_html.innerHTML).render(data, (html) => { - tpl_view_html.innerHTML = html; - if (callback) { - callback() - } - }); - } - }, - sendChating: function () { - let content = document.querySelector("#chating_value").value; - if (!this.createDisabled) { - if (window.layer) { - layer.msg("请先加入房间,才能发言哦") - } - this.addUserLogs("请先加入房间,才能发言哦") - return - } - if (content === '' || content === undefined) { - if (window.layer) { - layer.msg("请先填写内容哦") - } - this.addUserLogs("请先填写内容哦") - return - } - if (content.length > 1000) { - if (window.layer) { - layer.msg("内容太长啦,不能超过1000个字") - } - this.addUserLogs("内容太长啦,不能超过1000个字") - return - } - this.socket.emit('chating', { - msg: encodeURIComponent(content), - room: this.roomId, - socketId: this.socketId, - }); - - this.addUserLogs("公共频道发言成功"); - - document.querySelector("#chating_value").value = '' - }, - sendBugs: function () { - if (window.layer) { - let that = this; - $("#sendBugs").removeClass("layui-anim-rotate") - setTimeout(() => { - $("#sendBugs").addClass("layui-anim-rotate") - }, 50) - setTimeout(() => { - layer.prompt({ - formType: 2, - title: '请描述您需要反馈的问题', - }, function (value, index, elem) { - that.socket.emit('message', { - emitType: "sendBugs", - msg: value, - room: that.roomId, - }); - layer.msg("问题反馈成功,更多问题可以加群交流,将更快解决") - layer.close(index); - that.addUserLogs("问题反馈成功,更多问题可以加群交流,将更快解决 ,问题:" + value); - }); - }, 500); - } - }, - refleshRoom: function () { - if (!this.createDisabled) { - this.roomId = parseInt(Math.random() * 100000); - this.addPopup("你刷新了房间号, 当前房间号为 " + this.roomId); - this.addUserLogs("你刷新了房间号, 当前房间号为 " + this.roomId); - $("#refresh").removeClass("layui-anim-rotate") - setTimeout(() => { - $("#refresh").addClass("layui-anim-rotate") - }, 50) - } - }, - addPopup: function (msg) { - window.Bus.$emit("addPopup", msg); - }, - cleanPopup: function () { - window.Bus.$emit("popupMap"); - }, - addSysLogs: function (msg) { - this.addLogs(msg, "【系统日志】: ") - }, - addUserLogs: function (msg) { - this.addLogs(msg, "【操作日志】: ") - }, - addLogs: function (msg, type) { - if (this.logs.length > 1000) { - this.logs.shift(); - } - this.logs.unshift({ - type: type, - msg: msg, - time: new Date().toLocaleString() - }) - }, - cleanLogs: function () { - this.logs = [] - this.addSysLogs("清空日志") - }, - sendTxt: function (isRealContentMode) { - if (!this.createDisabled) { - if (window.layer) { - layer.msg("请先加入房间,再发送内容") - } - this.addUserLogs("请先加入房间,再发送内容"); - return - } - if (this.noOthersInRoom) { - if (window.layer) { - layer.msg("房间内至少需要两个人才能发送内容") - } - this.addUserLogs("房间内至少需要两个人才能发送内容"); - return - } - if (isRealContentMode) { - let realContent = layedit.getContent(this.txtEditId) - if (realContent.length <= 0) { - if (window.layer) { - layer.msg("请输入发送的富文本内容") - } - this.addUserLogs("请输入发送的富文本内容"); - return - } - if (realContent.length > 1000) { - if (window.layer) { - layer.msg("富文本文字内容过长,长度最多1w单词!") - } - this.addUserLogs("富文本文字内容过长,长度最多1w单词"); - return - } - this.socket.emit('message', { - emitType: "sendTxt", - real: isRealContentMode, - content: encodeURIComponent(realContent), - room: this.roomId, - from: this.socketId, - recoderId: this.recoderId - }); - if (window.layer) { - if (window.layui && window.layedit) { - this.txtEditId = window.layedit.build('txt', { - tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right', 'face'], - height: 180 - }); - } - this.sendFileList.push({ - id: "txt", - name: realContent, - size: realContent.length, - type: "富文本内容", - process: 100, - done: true, - toIdStr: "", - start: 0, - cost: 0 - }); - layer.msg("富文本内容发送完毕") - this.addUserLogs("富文本内容发送完毕"); - } - } else { - let content = layedit.getText(this.txtEditId) - if (content.length <= 0) { - if (window.layer) { - layer.msg("请输入发送的文本内容") - } - this.addUserLogs("请输入发送的文本内容"); - return - } - if (content.length > 1000) { - if (window.layer) { - layer.msg("文字内容过长,最多1000单词!") - } - this.addUserLogs("文字内容过长,最多1000单词"); - return - } - this.socket.emit('message', { - emitType: "sendTxt", - real: isRealContentMode, - content: encodeURIComponent(content), - room: this.roomId, - from: this.socketId, - recoderId: this.recoderId - }); - if (window.layer) { - if (window.layui && window.layedit) { - this.txtEditId = window.layedit.build('txt', { - tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right', 'face'], - height: 180 - }); - } - this.sendFileList.push({ - id: "txt", - name: content, - size: content.length, - type: "文本内容", - process: 100, - done: true, - toIdStr: "", - start: 0, - cost: 0 - }); - layer.msg("内容发送完毕") - this.addUserLogs("内容发送完毕"); - } - } - }, - clickHome: function (show = true) { - this.currentMenu = 1; - - let active = document.querySelector("#btnHome") - - document.querySelector("#iamtsm").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector("#chooseFileListDisable").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector("#chooseFileList").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - - if (this.toolListShadeIndex === -1) { // 没展开状态下才同步颜色 - document.querySelector("#closeTool").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - } - - let menuBorder = document.querySelector(".menuBorder"); - let box = active.getBoundingClientRect(); - offsetMenuBorder(box, menuBorder); - - function offsetMenuBorder(box, menuBorder) { - let left = Math.floor(box.left - menuBorder.closest("menu").offsetLeft - (menuBorder.offsetWidth - box.width) / 2) + "px"; - menuBorder.style.transform = `translate3d(${left}, 0 , 0)` - } - - if (show) { - this.clickSendFile(); - } - }, - clickReceive: function (show = true) { - this.currentMenu = 2; - - let active = document.querySelector("#btnReceive") - - document.querySelector("#iamtsm").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector("#chooseFileListDisable").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector("#chooseFileList").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - if (this.toolListShadeIndex === -1) { // 没展开状态下才同步颜色 - document.querySelector("#closeTool").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - } - - let menuBorder = document.querySelector(".menuBorder"); - let box = active.getBoundingClientRect(); - offsetMenuBorder(box, menuBorder); - - function offsetMenuBorder(box, menuBorder) { - let left = Math.floor(box.left - menuBorder.closest("menu").offsetLeft - (menuBorder.offsetWidth - box.width) / 2) + "px"; - menuBorder.style.transform = `translate3d(${left}, 0 , 0)` - } - - if (show) { - this.clickReceiveFile() - } - }, - clickTxt: function (show = true) { - this.currentMenu = 3; - - let active = document.querySelector("#btnTxt") - - document.querySelector("#iamtsm").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector("#chooseFileListDisable").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector("#chooseFileList").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - if (this.toolListShadeIndex === -1) { // 没展开状态下才同步颜色 - document.querySelector("#closeTool").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - } - - let menuBorder = document.querySelector(".menuBorder"); - let box = active.getBoundingClientRect(); - offsetMenuBorder(box, menuBorder); - - function offsetMenuBorder(box, menuBorder) { - let left = Math.floor(box.left - menuBorder.closest("menu").offsetLeft - (menuBorder.offsetWidth - box.width) / 2) + "px"; - menuBorder.style.transform = `translate3d(${left}, 0 , 0)` - } - - if (show) { - this.clickReceiveTxt() - } - }, - clickCodeFile: function (show = true) { - this.currentMenu = 4; - - let active = document.querySelector("#btnCodeFile"); - document.querySelector("#iamtsm").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector("#chooseFileListDisable").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - document.querySelector("#chooseFileList").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - if (this.toolListShadeIndex === -1) { // 没展开状态下才同步颜色 - document.querySelector("#closeTool").style.backgroundColor = active.style.getPropertyValue("--bgColorBody"); - } - - let menuBorder = document.querySelector(".menuBorder"); - let box = active.getBoundingClientRect(); - offsetMenuBorder(box, menuBorder); - - function offsetMenuBorder(box, menuBorder) { - let left = Math.floor(box.left - menuBorder.closest("menu").offsetLeft - (menuBorder.offsetWidth - box.width) / 2) + "px"; - menuBorder.style.transform = `translate3d(${left}, 0 , 0)` - } - - if (show) { - this.clickReceiveCodeFile() - } - }, - //点击切换发送文件或者发送文本 - changeFileOrTxt: function () { - let that = this; - this.isTxtMode = !this.isTxtMode; - if (window.layui && window.layedit) { - this.txtEditId = window.layedit.build('txt', { - tool: ['strong', 'italic', 'underline', 'del', '|', 'left', 'center', 'right', 'face'], - height: 180 - }); - } - $("#changeMode").removeClass("layui-anim-rotate") - setTimeout(() => { - $("#changeMode").addClass("layui-anim-rotate") - if (window.layer) { - layer.msg(`切换为${this.isTxtMode ? '文本模式' : '文件模式'}`) - } - this.addUserLogs(`切换为${this.isTxtMode ? '文本模式' : '文件模式'}`); - }, 50) + this.addUserLogs("打开赞助窗口") }, //点击下载文件面板 clickReceiveFile: function () { + if(this.receiveFileList.length === 0){ + if(window.layer){ + layer.msg("暂时没有收到文件") + } + return + } this.showReceiveFile = !this.showReceiveFile; if (this.showReceiveFile) { this.addUserLogs("展开接收文件面板"); - this.numReceiveFile = 50; + this.receiveFileMaskHeightNum = 20; } else { - this.numReceiveFile = 150; + this.receiveFileMaskHeightNum = 150; this.addUserLogs("收起接收文件面板"); } }, - //点击接收文字面板 - clickReceiveTxt: function () { - this.showReceiveTxt = !this.showReceiveTxt; - if (this.showReceiveTxt) { - this.addUserLogs("展开接收文字面板"); - this.numReceiveTxt = 50; - } else { - this.numReceiveTxt = 150; - this.addUserLogs("收起接收文字面板"); - } - }, //点击发送文件面板 clickSendFile: function () { + if(!this.hasManInRoom && !this.showSendFile){ + if(window.layer){ + layer.msg("房间内至少需要两个人才能发送内容") + } + return + } this.showSendFile = !this.showSendFile; if (this.showSendFile) { - this.numSendFile = 50; + this.sendFileMaskHeightNum = 20; this.addUserLogs("展开发送文件/文本面板"); } else { - this.numSendFile = 150; + this.sendFileMaskHeightNum = 150; this.addUserLogs("收起发送文件/文本面板"); } }, - //点击取件码面板 - clickReceiveCodeFile: function () { - this.showCodeFile = !this.showCodeFile; - if (this.showCodeFile) { - this.numCodeFile = 50; - this.addUserLogs("展开取件码面板"); - } else { - this.numCodeFile = 150; - this.addUserLogs("收起取件码面板"); - } - }, //点击查看日志面板 clickLogs: function () { this.showLogs = !this.showLogs; if (this.showLogs) { - this.numLogs = 50; + this.logMaskHeightNum = 50; + this.addUserLogs("展开日志面板"); } else { - this.numLogs = 150; + this.logMaskHeightNum = 150; + this.addUserLogs("收起日志面板"); } }, + //点击打开音视频面板 + clickMediaVideo: function () { + this.showMedia = !this.showMedia; + if (this.showMedia) { + this.addUserLogs("展开音视频/屏幕共享面板"); + this.mediaVideoMaskHeightNum = 50; + } else { + this.mediaVideoMaskHeightNum = 150; + this.addUserLogs("收起音视频/屏幕共享面板"); + } + }, + //点击打开屏幕共享面板 + clickMediaScreen: function () { + this.showMedia = !this.showMedia; + if (this.showMedia) { + this.addUserLogs("展开音视频/屏幕共享面板"); + this.mediaScreenMaskHeightNum = 50; + } else { + this.mediaScreenMaskHeightNum = 150; + this.addUserLogs("收起音视频/屏幕共享面板"); + } + }, + typeInArr: function(arr, type){ + return arr.filter(item=>{ + return type.includes(item); + }).length > 0; + }, //文件大小 getFileSizeStr: function (size) { let sizeStr = (size / 1048576).toString(); @@ -1497,6 +1400,12 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { }, //创建文件发送房间 createFileRoom: function () { + this.openRoomInput = !this.openRoomInput; + + if(this.openRoomInput){ + return + } + this.roomId = this.roomId.toString().replace(/\s*/g, "") if (this.roomId === null || this.roomId === undefined || this.roomId === '') { if (window.layer) { @@ -1689,20 +1598,24 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { //当前用户开启了屏幕共享时建立 stream share 链接 initMediaShareChannel: function (rtcConnect, type, track, stream) { rtcConnect.ontrack = (event) => { - setTimeout(() => { - $("#mediaShareRoomList").append(` -
- -
- `); - var video = document.querySelector("#otherMediaShareVideo"); - video.srcObject = event.streams[0] - // ios 微信浏览器兼容问题 + if(event.track.kind === 'audio'){ + return; + } + $(`${type === 'screen' ? '#mediaScreenRoomList': '#mediaVideoRoomList'}`).append(` +
+ +
+ `); + + var video = document.querySelector("#otherMediaShareVideo"); + video.srcObject = event.streams[0] + // ios 微信浏览器兼容问题 + video.addEventListener('loadedmetadata', function() { video.play(); document.addEventListener('WeixinJSBridgeReady', function () { video.play(); }, false); - }, 100) + }); }; if (track && stream) { @@ -1737,6 +1650,12 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { }, // 初始发送 initSendFile: function () { + if(!this.hasManInRoom){ + if(window.layer){ + layer.msg("房间内至少需要两个人才能发送内容") + } + return + } //选中一个文件 this.changeSendFileNext(); @@ -1869,7 +1788,6 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { sendChannel.send(event.target.result); fileOffset += event.target.result.byteLength; remote[this.currentChooseFile.index + "offset"] = fileOffset - this.currentSendSize += event.target.result.byteLength; this.currentSendAllSize += event.target.result.byteLength; //更新发送进度 @@ -1879,7 +1797,6 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { //发送完一份重置相关数据 if (fileOffset === this.currentChooseFile.size) { - this.currentSendSize = 0 this.addPopup("正在发送给" + nextSendingId.substr(0, 4) + ",100%。"); this.addSysLogs("正在发送给" + nextSendingId.substr(0, 4) + ",100%。") this.socket.emit('message', { @@ -2006,10 +1923,8 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { receiveBuffer.push(event.data); receivedSize += event.data.byteLength; - document.querySelector("#receiveProgress").value = receivedSize; this.setRemoteInfo(id, { receiveBuffer: receiveBuffer, receivedSize: receivedSize }) - this.currentReceiveSize += event.data.byteLength; //更新接收进度 this.updateReceiveProcess(id, { @@ -2017,9 +1932,7 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { }); if (receivedSize === size) { - this.currentReceiveSize = 0; this.addSysLogs(name + " 接收完毕"); - document.querySelector("#receiveProgress").value = 0; this.addPopup("文件[ " + name + " ]接收完毕,可点击右下角查看。"); //更新接收进度 @@ -2065,7 +1978,7 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { if (item.start === 0) { item.start = Date.now(); } - data.cost = parseInt((Date.now() - item.start) / 1000); + data.cost = ((Date.now() - item.start) / 1000).toFixed(3) Object.assign(this.receiveFileList[i], data); } } @@ -2075,7 +1988,7 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { for (let i = 0; i < this.sendFileList.length; i++) { let item = this.sendFileList[i]; if (item.id === id && item.index === this.currentChooseFile.index && !item.done) { - data.cost = parseInt((Date.now() - item.start) / 1000); + data.cost = ((Date.now() - item.start) / 1000).toFixed(3); Object.assign(this.sendFileList[i], data); } } @@ -2154,11 +2067,14 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { that.socketId = data.id; that.roomId = data.room; that.recoderId = data.recoderId; - if (data.type === 'screen' && data['peers'].length === 0) { - window.Bus.$emit("startScreenShare", data.id); - } - if (data.type === 'video' && data['peers'].length === 0) { - window.Bus.$emit("startVideoShare", data.id); + // 获取自己本地流 + if (data['peers'].length === 0) { + if(data.type === 'screen'){ + window.Bus.$emit("startScreenShare", data.id); + } + if(data.type === 'video'){ + window.Bus.$emit("startVideoShare", data.id); + } } for (let i = 0; i < data['peers'].length; i++) { let otherSocketId = data['peers'][i].id; @@ -2166,40 +2082,29 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { let rtcConnect = that.getOrCreateRtcConnect(otherSocketId); // 处理完连接后,更新下昵称 that.setRemoteInfo(otherSocketId, { nickName : otherSocketIdNickName }) - // 处理音视频情况 - if (data.type === 'screen') { - await new Promise(resolve => { + + await new Promise(resolve => { + // 处理音视频情况 + if (data.type === 'screen') { window.Bus.$emit("startScreenShare", otherSocketId, (track, stream) => { that.initMediaShareChannel(rtcConnect, data.type, track, stream) resolve() }); - }).then(()=>{ - rtcConnect.createOffer(that.options).then(offer => { - that.offerSuccess(rtcConnect, otherSocketId, offer); - }, error => { - that.offerFailed(rtcConnect, otherSocketId, error); - }); - }) - } else if (data.type === 'video') { - await new Promise(resolve => { + }else if (data.type === 'video') { window.Bus.$emit("startVideoShare", otherSocketId, (track, stream) => { that.initMediaShareChannel(rtcConnect, data.type, track, stream) resolve() }); - }).then(()=>{ - rtcConnect.createOffer(that.options).then(offer => { - that.offerSuccess(rtcConnect, otherSocketId, offer); - }, error => { - that.offerFailed(rtcConnect, otherSocketId, error); - }); - }) - } else { + }else{ + resolve() + } + }).then(()=>{ rtcConnect.createOffer(that.options).then(offer => { that.offerSuccess(rtcConnect, otherSocketId, offer); }, error => { that.offerFailed(rtcConnect, otherSocketId, error); }); - } + }) } that.touchResize(); }); @@ -2279,7 +2184,7 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { that.setRemoteInfo(fromId, { receiveFiles: data }); that.addPopup(data.from + "选择了文件 [ " + data.name + " ],即将发送。"); that.addSysLogs(data.from + "选择了文件 [ " + data.name + " ],即将发送。"); - document.querySelector("#receiveProgress").max = data.size; + // document.querySelector("#receiveProgress").max = data.size; that.receiveFileList.push({ id: fromId, @@ -2315,7 +2220,7 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { }) //发送文字内容 - this.socket.on('sendTxt', function (data) { + this.socket.on('sendChatingRoom', function (data) { let fromId = data.from; that.addPopup(data.from + "发送了文字 [ " + data.content.substr(0, 10) + " ]"); that.addSysLogs(data.from + "发送了文字 [ " + data.content.substr(0, 10) + " ]"); @@ -2325,17 +2230,15 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { } catch (e) { that.addSysLogs("decode msg err : " + data.content); } - that.receiveTxtList.unshift({ - id: fromId, - real: data.real, + let now = new Date().toLocaleString(); + that.receiveTxtList.push({ + socketId: fromId, content: data.content, - time: new Date().toLocaleString(), - c_id: "txt_" + that.receiveTxtList.length, - process: 0, - done: false, - start: 0, - cost: 0 + nickName : data.nickName, + time: now, + timeAgo : window.util ? util.timeAgo(now) : now }) + that.chatingRoomTpl(); }); //在线数量 @@ -2359,7 +2262,10 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { //关闭共享 this.socket.on('stopScreenShare', function (data) { if (data.id === that.socketId) { - $("#selfMediaShareVideo").parent().remove(); + setTimeout(() => { + $("#selfMediaShareVideo").parent().remove(); + }, 500); + that.clickMediaScreen(); } else { $("#otherMediaShareVideo").parent().remove(); } @@ -2368,7 +2274,10 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { //关闭音视频 this.socket.on('stopVideoShare', function (data) { if (data.id === that.socketId) { - $("#selfMediaShareVideo").parent().remove(); + setTimeout(() => { + $("#selfMediaShareVideo").parent().remove(); + }, 500); + that.clickMediaVideo(); } else { $("#otherMediaShareVideo").parent().remove(); } @@ -2398,37 +2307,37 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { this.socket.on('commData', function (data) { that.switchData = data.switchData that.switchDataGet = true; - if(data.chatingData){ - data.chatingData.forEach(elem => { + if(data.chatingCommData){ + data.chatingCommData.forEach(elem => { try { elem.msg = decodeURIComponent(elem.msg) } catch (e) { that.addSysLogs("decode msg err : " + elem.msg); } - that.chatingList.push(elem) + that.chatingCommList.push(elem) }) - that.chatingList.forEach(item => { + that.chatingCommList.forEach(item => { item.timeAgo = window.util ? util.timeAgo(item.time) : item.time; }) } }); //公共聊天频道 - this.socket.on('chating', function (data) { + this.socket.on('chatingComm', function (data) { that.addSysLogs(data.room + "频道的" + data.socketId + "发言: [ " + data.msg + " ]"); try { data.msg = decodeURIComponent(data.msg) } catch (e) { that.addSysLogs("decode msg err : " + data.msg); } - that.chatingList.push(data); - if (that.chatingList.length > 10) { - that.chatingList.shift(); + that.chatingCommList.push(data); + if (that.chatingCommList.length > 10) { + that.chatingCommList.shift(); } - that.chatingList.forEach(item => { + that.chatingCommList.forEach(item => { item.timeAgo = window.util ? util.timeAgo(item.time) : item.time; }) - that.chatingTpl() + that.chatingCommTpl() }); this.socket.on('manageCheck', function (data) { @@ -2522,15 +2431,6 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { }, initCss: function (e) { if (!e) return; - if (this.currentMenu === 1) { - this.clickHome(false); - } else if (this.currentMenu === 2) { - this.clickReceive(false); - } else if (this.currentMenu === 3) { - this.clickTxt(false); - } else if (this.currentMenu === 4) { - this.clickCodeFile(false); - } //re caculate size this.reCaculateSwiperSize(); @@ -2550,24 +2450,17 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { // logs height this.logsHeight = document.documentElement.clientHeight - 55; + this.sendFileListHeight = document.querySelector("#send-file-list").clientHeight - 190; + this.receiveFileListHeight = document.querySelector("#receive-file-list").clientHeight - 40; }, reCaculateSwiperSize: function () { - let clientWidth = document.body.clientWidth; - if (window.userRoomSwiper) { - let slidesPerView = parseInt((clientWidth / 100)) - 1; - window.userRoomSwiper.params.slidesPerView = slidesPerView; + this.clientWidth = document.body.clientWidth; + + if (window.fileTxtToolSwiper) { + window.fileTxtToolSwiper.params.slidesPerView = this.clientWidth < 600 ? 1 : 2; } - if (window.fileRoomSwiper) { - let slidesPerView = parseInt((clientWidth / 100)) - 1; - window.fileRoomSwiper.params.slidesPerView = slidesPerView; - } - if (window.fileRoomDisabledSwiper) { - let slidesPerView = parseInt((clientWidth / 100)) - 1; - window.fileRoomDisabledSwiper.params.slidesPerView = slidesPerView; - } - if (window.mediaShareRoomSwiper) { - let slidesPerView = parseInt((clientWidth / 100)) - 1; - window.mediaShareRoomSwiper.params.slidesPerView = slidesPerView; + if (window.toolSwiper) { + window.toolSwiper.params.slidesPerView = this.toolSlidesPerViewCount; } }, touchResize: function () { @@ -2588,47 +2481,6 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { }); } }, - toolList: function () { - let that = this; - setTimeout(() => { - if (window.$) { - $('.toolList a').on('click', function () { - let $this = $(this); - if ($this.hasClass("layui-icon-component")) { - return - } - if ($this.hasClass('fan-out')) { - $('.toolList').removeClass('fan-out'); - $('.toolList a').removeClass('fan-out'); - $('.toolList').css("marginBottom", "0") - $("#layui-layer-shade" + that.toolListShadeIndex).remove() - $("#closeTool").css("backgroundColor", "rgb(79, 79, 65)") - } else { - $('.toolList').addClass('fan-out'); - $('.toolList a').addClass('fan-out'); - $('.toolList').css("marginBottom", "110px") - $("#closeTool").css("backgroundColor", "rgb(0 0 0)") - layer.msg('', { - shade: 0.8, time: 0, - success: function (layero, index) { - that.toolListShadeIndex = index; - $(layero.selector).remove() - $("#layui-layer-shade" + index).css("zIndex", 1000); - $("#closeTool").css("backgroundColor", "unset") - } - }); - } - }); - layer.tips('更多功能都放在这里啦,点开看看吧~', '#closeToolIcon', { - tips: 1 - }); - } - setInterval(() => { - let colors = ["#deb887", "#faebd7", "#6495ed", "#008b8b", "#87ceeb", "#48d1cc"] - $("#closeToolIcon").css("color", colors[parseInt(Math.random(1000) * 1000) % 6]) - }, 500); - }, 800) - }, windowOnBusEvent: function () { window.Bus.$on("changeScreenState", (res) => { this.isScreen = res @@ -2664,8 +2516,11 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { } this.videoShareTimes = res }) - window.Bus.$on("sendChating", (res) => { - this.sendChating() + window.Bus.$on("sendChatingComm", (res) => { + this.sendChatingComm() + }) + window.Bus.$on("sendChatingRoom", (res) => { + this.sendChatingRoom() }) window.Bus.$on("sendOpenaiChat", (res) => { this.sendOpenaiChat() @@ -2720,33 +2575,50 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { drag: true, multiple: true, choose: function (obj) { - for (let index in obj.pushFile()) { - let hasSendFile = that.sendFileList.filter(file => { - return file.name === obj.pushFile()[index].name && file.size === obj.pushFile()[index].size - && file.type === obj.pushFile()[index].type - }).length > 0; - - if (hasSendFile && window.layer) { - layer.msg("已过滤发送过的文件"); - that.addUserLogs("已过滤发送过的文件"); - } - - if (!hasSendFile) { - that.chooseFileList.push( - Object.assign(obj.pushFile()[index], { - index: 'file' + index, - fileSendStatus: 0, - offset: 0 - }) - ) - } - } + that.chooseFileList = [] + obj.resetFile() + obj.preview((index, file, result)=>{ + that.chooseFileList.push( + Object.assign(file, { + index: 'file' + index, + fileSendStatus: 0, + offset: 0 + }) + ) + }) } }); } + }, + initSwiper: function(){ + let clientWidth = document.body.clientWidth; + //发文件,收文件功能 + let fileTxtToolSwiper = new Swiper('.tl-rtc-file-send-file-txt-tool', { + direction: 'horizontal', + loop: false, + slidesPerView: clientWidth < 600 ? 1 : 2, + observer: true + }) + window.fileTxtToolSwiper = fileTxtToolSwiper; + + //工具功能 + let toolSwiper = new Swiper('.tl-rtc-file-tool-list', { + direction: 'horizontal', + loop: false, + slidesPerView: this.toolSlidesPerViewCount, + observer: true, + }) + window.toolSwiper = toolSwiper; } }, mounted: function () { + this.addSysLogs("刷新随机房间号 初始化中..."); + this.refleshRoom() + this.addSysLogs("刷新随机房间号完成"); + + this.addSysLogs("滑动组件 初始化中..."); + this.initSwiper(); + this.addSysLogs("滑动组件 初始化完成"); this.addSysLogs("SOCKET监听 初始化中..."); this.socketListener(); @@ -2758,6 +2630,9 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { this.addSysLogs("窗口事件监听 初始化中..."); window.onresize = this.initCss; + setInterval(() => { + this.touchResize() + }, 1000); this.addSysLogs("窗口事件监听 初始化完成"); this.addSysLogs("分享组件 初始化中..."); @@ -2774,13 +2649,10 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { this.addSysLogs("文件选择组件 初始化完成"); }, 2000); - this.addSysLogs("右侧工具动画 初始化中..."); - this.toolList(); - this.addSysLogs("右侧工具动画 初始化完成"); - this.addSysLogs("基础样式 初始化中..."); this.logsHeight = document.documentElement.clientHeight - 55; - this.clickHome(false); + this.sendFileListHeight = document.querySelector("#send-file-list").clientHeight - 190; + this.receiveFileListHeight = document.querySelector("#receive-file-list").clientHeight - 40; this.addSysLogs("基础样式 初始化完成"); this.addSysLogs("DEBUG组件 初始化中..."); @@ -2797,9 +2669,13 @@ axios.get(window.prefix + "/api/comm/initData", {}).then((initData) => { window.manageChange = function (data) { window.Bus.$emit("manageChange", data) } - window.sendChating = function () { - window.Bus.$emit("sendChating", {}) + window.sendChatingComm = function () { + window.Bus.$emit("sendChatingComm", {}) } + window.sendChatingRoom = function () { + window.Bus.$emit("sendChatingRoom", {}) + } + window.sendOpenaiChat = function () { window.Bus.$emit("sendOpenaiChat", {}) } diff --git a/res/js/screen.js b/res/js/screen.js index 5b19536..2cb25c9 100644 --- a/res/js/screen.js +++ b/res/js/screen.js @@ -62,11 +62,11 @@ var screen = new Vue({ this.interverlId = setInterval(() => { that.times += 1; window.Bus.$emit("changeScreenTimes", that.times) - $("#screen").css("color","#fb0404") + $("#screenIcon").css("color","#fb0404") $("#screenTimes").css("color","#fb0404") setTimeout(() => { - $("#screen").css("color","#ffffff") - $("#screenTimes").css("color","#ffffff") + $("#screenIcon").css("color","#000000") + $("#screenTimes").css("color","#000000") }, 500) }, 1000); @@ -113,6 +113,10 @@ var screen = new Vue({ layer.msg("录制完成,请在接收文件列表查看") } + setTimeout(() => { + $("#screenIcon").css("color","#000000") + }, 1000); + return; }, }, diff --git a/res/js/screenShare.js b/res/js/screenShare.js index c435ce9..c3149ad 100644 --- a/res/js/screenShare.js +++ b/res/js/screenShare.js @@ -41,7 +41,7 @@ var screenShare = new Vue({ console.log(error) } } - + if (this.stream == null) { if (window.layer) { layer.msg("获取设备屏幕录制权限失败") @@ -53,28 +53,30 @@ var screenShare = new Vue({ return; } - $("#mediaShareRoomList").append(` -
- + $("#mediaScreenRoomList").append(` +
+
`); var video = document.querySelector("#selfMediaShareVideo"); video.srcObject = this.stream - // ios 微信浏览器兼容问题 - video.play(); - document.addEventListener('WeixinJSBridgeReady',function(){ + video.addEventListener('loadedmetadata', function() { + // ios 微信浏览器兼容问题 video.play(); - },false); - + document.addEventListener('WeixinJSBridgeReady', function () { + video.play(); + }, false); + }); + //计算时间 this.interverlId = setInterval(() => { that.times += 1; window.Bus.$emit("changeScreenShareTimes", that.times) - $("#screenShare").css("fill","#fb0404") - $("#screenShareTimes").css("fill","#fb0404") + $("#screenShareIcon").css("color","#fb0404") + $("#screenShareTimes").css("color","#fb0404") setTimeout(() => { - $("#screenShare").css("fill","#ffffff") - $("#screenShareTimes").css("fill","#ffffff") + $("#screenShareIcon").css("color","#ffffff") + $("#screenShareTimes").css("color","#ffffff") }, 500) }, 1000); @@ -102,6 +104,10 @@ var screenShare = new Vue({ layer.msg("屏幕共享结束,本次共享时长 "+this.times+"秒") } + setTimeout(() => { + $("#screenShareIcon").css("color", "#000000") + }, 1000); + this.stream = null; this.times = 0; diff --git a/res/js/videoShare.js b/res/js/videoShare.js index eeaadc2..153cb6c 100644 --- a/res/js/videoShare.js +++ b/res/js/videoShare.js @@ -20,15 +20,19 @@ var videoShare = new Vue({ facingMode: true ? "user" : "environment", // 分辨率 width: { - ideal : 1280 + ideal : parseInt((document.documentElement.clientWidth - 20) / 2), + max : document.documentElement.clientWidth, + min : 100 }, height: { - ideal : 720 + ideal : parseInt((document.documentElement.clientHeight - 20) / 2), + max : document.documentElement.clientHeight, + min : 100 }, // 码率 frameRate: { - ideal: 10, - max: 15 + ideal: 30, + max: 50 }, // 指定设备 // deviceId: "", @@ -79,28 +83,30 @@ var videoShare = new Vue({ return; } - $("#mediaShareRoomList").append(` -
- -
+ $("#mediaVideoRoomList").append(` +
+ +
`); var video = document.querySelector("#selfMediaShareVideo"); video.srcObject = this.stream - // ios 微信浏览器兼容问题 - video.play(); - document.addEventListener('WeixinJSBridgeReady',function(){ + video.addEventListener('loadedmetadata', function() { + // ios 微信浏览器兼容问题 video.play(); - },false); + document.addEventListener('WeixinJSBridgeReady', function () { + video.play(); + }, false); + }); //计算时间 this.interverlId = setInterval(() => { that.times += 1; window.Bus.$emit("changeVideoShareTimes", that.times) - $("#videoShare").css("color", "#fb0404") + $("#videoShareIcon").css("color", "#fb0404") $("#videoShareTimes").css("color", "#fb0404") setTimeout(() => { - $("#videoShare").css("color", "#ffffff") + $("#videoShareIcon").css("color", "#ffffff") $("#videoShareTimes").css("color", "#ffffff") }, 500) }, 1000); @@ -123,11 +129,14 @@ var videoShare = new Vue({ clearInterval(this.interverlId); - window.Bus.$emit("changeVideoShareTimes", 0) + window.Bus.$emit("changeVideoShareTimes", 0); if (window.layer) { layer.msg("音视频通话结束,本次通话时长 " + this.times + "秒") } + setTimeout(() => { + $("#videoShareIcon").css("color", "#000000") + }, 1000); this.stream = null; this.times = 0; diff --git a/src/socket/index.js b/src/socket/index.js index e15507f..0520885 100644 --- a/src/socket/index.js +++ b/src/socket/index.js @@ -48,7 +48,7 @@ let tokens = []; // sql操作 let sql = {}; // 公共聊天数据 -let chating = [] +let chatingComm = [] // 开关数据 let cacheSwitchData = {}; // 通知事件定义 @@ -89,7 +89,7 @@ async function excute(tabs, sequelize, config) { config.ws.beforeInit(); } - chating = await getDogChating10Info({ + chatingComm = await getDogChating10Info({ tables: tables, sql: sql, }); @@ -196,7 +196,7 @@ function listen(io) { handler._message({ emitType: "commData", switchData: switchData, - chatingData: chating, + chatingCommData: chatingComm, }) }) @@ -390,8 +390,7 @@ function listen(io) { if(switchData){ cacheSwitchData = switchData } - handler._message({ - emitType: "commData", + handler._commDataChange({ switchData: switchData, }) @@ -621,7 +620,7 @@ function listen(io) { }); // 公共聊天频道 - socket.on('chating', async function (message) { + socket.on('chatingComm', async function (message) { try { if(!cacheSwitchData.openCommRoom){ handler._message({ @@ -634,14 +633,14 @@ function listen(io) { } message.time = new Date().toLocaleString() - if (chating.length < 10) { - chating.push(message) + if (chatingComm.length < 10) { + chatingComm.push(message) } else { - chating.shift() - chating.push(message) + chatingComm.shift() + chatingComm.push(message) } - handler._chating(message, {}) + handler._chatingComm(message, {}) let handshake = socket.handshake let userAgent = handshake.headers['user-agent'].toString().substr(0, 255); diff --git a/src/socket/template.js b/src/socket/template.js index d7c06df..8158635 100644 --- a/src/socket/template.js +++ b/src/socket/template.js @@ -7,14 +7,27 @@ this.socket = socket; } + /** + * 后台修改配置广播 + * @param {*} message + * @param {*} params + */ + _commDataChange( message, params){ + try{ + this.sockets.emit("commData", message) + }catch(e){ + console.log(e) + } + } + /** * 公共聊天频道 * @param {*} message * @param {*} params */ - _chating( message, params){ + _chatingComm( message, params){ try{ - this.sockets.emit("chating", message) + this.sockets.emit("chatingComm", message) }catch(e){ console.log(e) } @@ -225,7 +238,7 @@ if(emitType === 'commData'){ this.socket.emit('commData',{ switchData : message.switchData, - chatingData : message.chatingData + chatingCommData : message.chatingCommData }); return } @@ -238,7 +251,7 @@ otherSocket.emit(emitType, message); return; } - if(from != otherSocket.id ){ + if(from != otherSocket.id){ otherSocket.emit(emitType, message); } }