From 2ba6b59359e9dfe140157b4a18c9cc8f08bf69be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Chaocao=E2=80=9D?= <“haocao@iflytek.com”> Date: Fri, 28 Sep 2018 21:10:40 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=97=B6=E9=97=B4=E4=B8=8D=E5=AF=B9=E4=BC=9A?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E8=BA=AB=E4=BB=BD=E8=AF=81=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E5=99=A8=E5=A4=B1=E6=95=88=EF=BC=8C=E5=9C=A8=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E9=87=8C=E9=9D=A2=E6=B7=BB=E5=8A=A0=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E7=9A=84=E9=85=8D=E7=BD=AE=EF=BC=8C=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E7=9B=B4=E6=8E=A5=E5=8F=AF=E4=BB=A5=E5=9C=A8=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E9=85=8D=E7=BD=AE=E8=B0=83=E6=95=B4=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2.邮箱没有配置的时候创建账号,实际成功了但是没发邮件,完全红色的提示容易有误解-->改为绿底红色显示。 --- .../www/teleport/static/js/system/config.js | 74 +++++++++++++++++++ server/www/teleport/static/js/tp-utils.js | 12 +++ server/www/teleport/view/system/config.mako | 19 +++++ .../webroot/app/controller/__init__.py | 2 + .../teleport/webroot/app/controller/system.py | 35 +++++++++ .../teleport/webroot/app/controller/user.py | 5 +- 6 files changed, 146 insertions(+), 1 deletion(-) mode change 100644 => 100755 server/www/teleport/static/js/system/config.js mode change 100644 => 100755 server/www/teleport/static/js/tp-utils.js mode change 100644 => 100755 server/www/teleport/view/system/config.mako mode change 100644 => 100755 server/www/teleport/webroot/app/controller/system.py diff --git a/server/www/teleport/static/js/system/config.js b/server/www/teleport/static/js/system/config.js old mode 100644 new mode 100755 index 085eeb6..68934b6 --- a/server/www/teleport/static/js/system/config.js +++ b/server/www/teleport/static/js/system/config.js @@ -21,6 +21,7 @@ $app.on_init = function (cb_stack) { $app.storage = $app.create_config_storage(); cb_stack.add($app.storage.init); + $app.systime = $app.create_config_systime(); cb_stack.exec(); }; @@ -769,3 +770,76 @@ $app.create_config_storage = function () { return _sto; }; + +$app.create_config_systime = function () { + var _st = {}; + + _st.dom = { + tp_time: $('#system-time'), + sys_data_set: $("#system-data-set"), + sys_time_set: $("#system-time-set"), + btn_sys_time_save: $('#btn-system-time-save') + }; + + $app.sys_time = 0; + + _st.init = function (cb_stack) { + cb_stack.exec(); + }; + + // 获取服务器时间 + _st.sync_tp_time = function () { + var data_str; + $tp.ajax_post_json('/system/get-time', {}, + function (ret) { + if (ret.code === TPE_OK) { + _st.tp_time = tp_utc2local(ret.data); + _st.show_tp_time(); + // 引用一下当前系统时间,因为一般只是微调 + data_str = tp_format_datetime(_st.tp_time).split(" "); + _st.dom.sys_data_set.val(data_str[0]); + _st.dom.sys_time_set.val(data_str[1]); + } + }, + function () { + } + ); + }; + + _st.sync_tp_time(); + + _st.show_tp_time = function () { + if (_st.tp_time === 0) + return; + _st.dom.tp_time.text(tp_format_datetime(_st.tp_time)); + _st.tp_time += 1; + }; + + setInterval(_st.show_tp_time, 1000); + // 每五分钟同步一次服务器时间,避免长时间误差积累导致显示不正确 + setInterval(_st.sync_tp_time, 1000 * 60 * 5); + + _st.dom.btn_sys_time_save.click(function () { + var nDate = _st.dom.sys_data_set.val(); + var nTime = _st.dom.sys_time_set.val(); + var full_time = nDate + " " + nTime; + if (check_date_valid(full_time) == true) { + $tp.ajax_post_json('/system/set-time', {settime: full_time}, + function (ret) { + if (ret.code === TPE_OK) { + //立即更新页面显示的时间 + _st.sync_tp_time(); + $tp.notify_success('系统时间更新成功!'); + } else { + $tp.notify_error('系统时间更新失败:' + tp_error_msg(ret.code, ret.message)); + } + }, + function () { + $tp.notify_error('网络故障,系统时间更新失败!'); + } + ); + } + }); + + return _st; +}; diff --git a/server/www/teleport/static/js/tp-utils.js b/server/www/teleport/static/js/tp-utils.js old mode 100644 new mode 100755 index c5e9410..de59640 --- a/server/www/teleport/static/js/tp-utils.js +++ b/server/www/teleport/static/js/tp-utils.js @@ -387,3 +387,15 @@ function tp_check_strong_password(p) { return !!((s & 1) && (s & 2) && (s & 4)); } + +//检查日期合法性 +function check_date_valid(date) { + var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; + var r = date.match(reg); + if(r == null) { + $tp.notify_error("输入格式不正确!" + date); + return false; + } else { + return true; + } +} \ No newline at end of file diff --git a/server/www/teleport/view/system/config.mako b/server/www/teleport/view/system/config.mako old mode 100644 new mode 100755 index 69b29f9..8084cf2 --- a/server/www/teleport/view/system/config.mako +++ b/server/www/teleport/view/system/config.mako @@ -22,6 +22,7 @@