From 984e971949af636be960ed7dcb69fed78b7c23df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=B6=E5=A3=AB=E6=B6=B5?= <630892807@qq.com> Date: Sun, 26 Jul 2020 16:51:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E5=8F=96=E5=85=AC=E5=85=B1js=20css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/css/common.css | 2 ++ static/html/chat_main.html | 9 ++++++--- static/html/chat_page.html | 3 ++- static/js/functions.js | 20 ++++++++++++++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 static/css/common.css create mode 100644 static/js/functions.js diff --git a/static/css/common.css b/static/css/common.css new file mode 100644 index 0000000..560894e --- /dev/null +++ b/static/css/common.css @@ -0,0 +1,2 @@ +.floatRight{float: right;} +.clear{clear: both;} \ No newline at end of file diff --git a/static/html/chat_main.html b/static/html/chat_main.html index bf44c32..6fb1aa8 100644 --- a/static/html/chat_main.html +++ b/static/html/chat_main.html @@ -5,7 +5,9 @@ 聊天界面 + + @@ -122,8 +124,9 @@ - - 发送 + + 发送 +
@@ -167,7 +170,7 @@ leftTabActive:"first", users:[], usersMap:[], - server:"wss://"+window.location.host+"/chat_server", + server:getWsBaseUrl()+"/chat_server", socket:null, messageContent:"", currentGuest:"", diff --git a/static/html/chat_page.html b/static/html/chat_page.html index fa9c928..74afddc 100644 --- a/static/html/chat_page.html +++ b/static/html/chat_page.html @@ -6,6 +6,7 @@ GO-FLY咨询页 + @@ -132,7 +133,7 @@ delimiters:["<{","}>"], data: { window:window, - server:"wss://"+window.location.host+"/chat_server", + server:getWsBaseUrl()+"/chat_server", socket:null, msgList:[], messageContent:"", diff --git a/static/js/functions.js b/static/js/functions.js new file mode 100644 index 0000000..2cca994 --- /dev/null +++ b/static/js/functions.js @@ -0,0 +1,20 @@ +function getBaseUrl() { + var ishttps = 'https:' == document.location.protocol ? true : false; + var url = window.location.host; + if (ishttps) { + url = 'https://' + url; + } else { + url = 'http://' + url; + } + return url; +} +function getWsBaseUrl() { + var ishttps = 'https:' == document.location.protocol ? true : false; + var url = window.location.host; + if (ishttps) { + url = 'wss://' + url; + } else { + url = 'ws://' + url; + } + return url; +} \ No newline at end of file