browser.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. function browserGenPage() {
  2. var page = '<div id="browser_page" style="display: block;">\
  3. <div class="maintitle">\
  4. <div>业务浏览器设置</div>\
  5. <div class="page_description_text">业务浏览器基于Chromium内核开发。\
  6. </div>\
  7. </div>\
  8. <div id="browserContent">\
  9. <div id="browser_all_content">\
  10. <div id="browser_prompt" class="page_prompt_info page_scenes_info_text hide"\
  11. style="display: none;"></div>\
  12. <div class="clearboth" id="browser_btn_save_div" style="padding-top:50px">\
  13. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  14. <div class="controls"><button class="btn_normal_long btn"\
  15. id="browser_btn_save">浏览器缓存清理</button></div>\
  16. </div>\
  17. <div class="clearboth" style="padding-top: 40px;">\
  18. <div style="width: 170px; margin-right: 10px; margin-top: 8px;" class="control-label"\
  19. lang-id="IDS_lan_ip_filter_mode">使用浏览器</div>\
  20. <div class="controls" style="margin-top:7px;">\
  21. <div class="pull-left">\
  22. <div onclick="radio(this)" name="browser_provider_radio" id="cefclient_browser"\
  23. class="radio_btn_off"></div>\
  24. </div>\
  25. <div class="pull-left" style="width:100px;">第三方</div>\
  26. <div class="pull-left">\
  27. <div onclick="radio(this)" name="browser_provider_radio" id="uos_browser"\
  28. class="radio_btn_on"></div>\
  29. </div>\
  30. <div class="pull-left" style="padding-top:0px;">系统自带\
  31. </div>\
  32. </div>\
  33. </div>\
  34. <div class="clearboth" style="padding-top:20px"></div>\
  35. </div>\
  36. <div id="sogou_management_div" style="margin-top: 40px; padding-bottom: 20px; border-bottom: 1px solid rgb(243, 243, 243);">\
  37. <div style="margin-top: 30px; font-size: 16px; "><span>Sogou输入法</span></div>\
  38. </div>\
  39. <div class="clearboth" id="browser_sogou_info_div" style="padding-top:20px">\
  40. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  41. <div class="controls"><span id="sogou_info_detail">无法获取输入法信息</span>\
  42. </div>\
  43. </div>\
  44. <div class="clearboth" id="browser_sogou_btn_save_div" style="padding-top:50px">\
  45. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  46. <div class="controls"><button class="btn_normal_long"\
  47. id="browser_sogou_btn_restart">重启搜狗输入法服务V3.0</button></div>\
  48. </div>\
  49. <div class="clearboth" id="browser_sogou_btn_fetch_div" style="padding-top:50px">\
  50. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  51. <div class="controls"><button class="btn_normal_long"\
  52. id="browser_sogou_btn_fetch">搜狗输入法信息快照</button></div>\
  53. </div>\
  54. </div>\
  55. <div id="browser_activation_content" class="page_prompt_info page_scenes_info_text hide">\
  56. </div>\
  57. </div>';
  58. $("#rightpagearea").prepend(page);
  59. if (typeof browserRenderPage == "function") {
  60. beforeRenderPage("browser");
  61. browserRenderPage();
  62. afterRenderPage("browser");
  63. }
  64. }
  65. var browserController = (function() {
  66. var gCurrentBrowserMode = '0';
  67. function updateBrowserCacheClearFlag() {
  68. let req = new Request();
  69. req.configType = 7; //GlobalCache
  70. req.section = 'Browser';
  71. req.option = true; //Write
  72. req.key = 'CacheClear';
  73. req.reserved1 = 0;
  74. req.reserved2 = 0;
  75. req.reserved3 = 'true';
  76. req.reserved4 = '';
  77. utilStartSubmitDialog();
  78. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  79. utilStopSubmitDialog();
  80. if (ret.errorCode === 0) {
  81. utilStartAlertDialog("清理指令已下发,请重启应用以执行浏览器缓存清理。");
  82. } else {
  83. RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
  84. }
  85. });
  86. }
  87. function restartSogouSrvRestartFlag() {
  88. let req = new Request();
  89. req.configType = 3; //RunConfig
  90. req.section = 'Browser';
  91. req.option = true; //Write
  92. req.key = 'SogouRestart';
  93. req.reserved1 = 0;
  94. req.reserved2 = 0;
  95. req.reserved3 = 'true';
  96. req.reserved4 = '';
  97. utilStartSubmitDialog();
  98. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  99. utilStopSubmitDialog();
  100. if (ret.errorCode === 0) {
  101. utilStartAlertDialog("重启指令已下发,请重启应用以执行该操作。");
  102. } else {
  103. RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
  104. }
  105. });
  106. }
  107. function restartSogouSrv() {
  108. let req = new Request();
  109. req.configType = 0;
  110. req.timeout = 30000;
  111. req.section = 'SougouInput';
  112. req.option = false;
  113. req.key = 'SogouRestart';
  114. req.reserved1 = 0;
  115. req.reserved2 = 0;
  116. req.reserved3 = '';
  117. req.reserved4 = '';
  118. utilStartSubmitDialog();
  119. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  120. utilStopSubmitDialog();
  121. if (ret.errorCode === 0) {
  122. utilStartAlertDialog("输入法重启成功,请退出当前页面,继续业务办理。"
  123. + "<br><br><span style='color:red'>提示:重启后页面唤起输入法可能会耗时较长,请耐心多次点击内容输入框,如果长时间无响应,请再次进入此页面执行重启。</span>");
  124. } else {
  125. RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
  126. }
  127. });
  128. }
  129. function FetchSogouInputInfo() {
  130. let req = new Request();
  131. req.configType = 0;
  132. req.section = 'SougouInput';
  133. req.option = false;
  134. req.key = 'Snapshot';
  135. req.reserved1 = 0;
  136. req.reserved2 = 0;
  137. req.reserved3 = '';
  138. req.reserved4 = '';
  139. utilStartSubmitDialog();
  140. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  141. utilStopSubmitDialog();
  142. if (ret.errorCode === 0) {
  143. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  144. if(result.reserved3 === '') {
  145. utilStartAlertDialog("操作成功!");
  146. } else {
  147. utilStartAlertDialog(result.reserved3);
  148. }
  149. } else {
  150. RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
  151. }
  152. });
  153. }
  154. function saveButtonHandle() {
  155. utilStartConfirmDialog("确认要清理浏览器缓存吗?", function() {
  156. updateBrowserCacheClearFlag();
  157. });
  158. }
  159. function saveBrowserTypeSelect(usingUOS, failCallback) {
  160. let req = new Request();
  161. req.configType = 7; //GlobalCache
  162. req.section = 'BusinessBrowserType';
  163. req.option = true;
  164. req.key = 'FultureEx';
  165. req.reserved1 = 0;
  166. req.reserved2 = 0;
  167. if(!usingUOS) {
  168. req.reserved3 = '1';
  169. } else {
  170. req.reserved3 = '0';
  171. }
  172. req.reserved4 = '';
  173. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  174. if (ret.errorCode === 0) {
  175. utilShowToast('设置成功!请通过重启应用生效');
  176. } else {
  177. utilStartAlertDialog("设置失败! ErrorCode: " + ErrorCodeStringfy(ret.errorCode), function(){
  178. if(failCallback) {
  179. failCallback();
  180. }
  181. });
  182. }
  183. });
  184. }
  185. function selectBrowserUseMode() {
  186. $(document).on('click', "[name='browser_provider_radio']", function () {
  187. if ($('#cefclient_browser').hasClass('radio_btn_on')) {
  188. gCurrentBrowserMode = '0';
  189. console.log("cefclient!");
  190. saveBrowserTypeSelect(false);
  191. } else {
  192. gCurrentBrowserMode = '1';
  193. console.log("uos!");
  194. saveBrowserTypeSelect(true);
  195. }
  196. });
  197. }
  198. function initBrowserTypeSelect() {
  199. let req = new Request();
  200. req.configType = 7; //GlobalCache
  201. req.section = 'BusinessBrowserType';
  202. req.option = false;
  203. req.key = 'FultureEx';
  204. req.reserved1 = 0;
  205. req.reserved2 = 0;
  206. req.reserved3 = '';
  207. req.reserved4 = '';
  208. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  209. if (ret.errorCode === 0) {
  210. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  211. if(result.value === '1') {
  212. $('#cefclient_browser').addClass('radio_btn_on').removeClass('radio_btn_off');
  213. $('#uos_browser').addClass('radio_btn_off').removeClass('radio_btn_on');
  214. } else {
  215. $('#uos_browser').addClass('radio_btn_on').removeClass('radio_btn_off');
  216. $('#cefclient_browser').addClass('radio_btn_off').removeClass('radio_btn_on');
  217. }
  218. } else {
  219. $('#cefclient_browser').addClass('radio_btn_off_disabled').removeClass('radio_btn_on').removeClass('radio_btn_off');
  220. $('#uos_browser').addClass('radio_btn_off_disabled').removeClass('radio_btn_on').removeClass('radio_btn_off');
  221. }
  222. });
  223. }
  224. function initSogouVersionInfo()
  225. {
  226. let req = new Request();
  227. req.mode = 1;
  228. RVC.ResourceWatcherEntity.GetThirdPartyInstallState(req, function(ret) {
  229. if (ret.errorCode === 0) {
  230. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  231. if(result.status == 1) {
  232. const version = result.version;
  233. const path = result.path;
  234. const installTime = result.reserverd1;
  235. var value = "当前版本:" + version + "<br/>";
  236. value += "安装时间:" + installTime + "<br/>";
  237. console.log(value);
  238. $('#sogou_info_detail').html(value);
  239. } else {
  240. var value = "输入法未安装或未启动!!";
  241. $('#sogou_info_detail').html(value);
  242. }
  243. } else {
  244. var value = "获取输入法版本失败:" + ErrorCodeStringfy(ret.errorCode);
  245. $('#sogou_info_detail').html(value);
  246. }
  247. });
  248. }
  249. function initPage() {
  250. $(document).on('click', '#browser_btn_save', saveButtonHandle);
  251. $(document).on('click', '#browser_sogou_btn_restart', restartSogouSrv);
  252. $(document).on('click', '#browser_sogou_btn_fetch', FetchSogouInputInfo);
  253. selectBrowserUseMode();
  254. initSogouVersionInfo();
  255. initBrowserTypeSelect();
  256. }
  257. var fistTime = true;
  258. function init() {
  259. if (fistTime) {
  260. fistTime = false;
  261. }
  262. initPage();
  263. }
  264. return { init: init };
  265. }());
  266. window.browserRenderPage = function () {
  267. browserController.init();
  268. };