browser.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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"></div>\
  11. <div class="clearboth" id="browser_restart_chromium_div" style="padding-top:50px">\
  12. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  13. <div class="controls"><button class="btn_normal_long"\
  14. id="btn_restart_chromium">重启浏览器</button></div>\
  15. </div>\
  16. <div class="clearboth" style="padding-top: 2px;"></div>\
  17. <div id="browser_prompt" class="page_prompt_info page_scenes_info_text hide"\
  18. style="display: none;"></div>\
  19. <div class="clearboth" id="browser_btn_save_div" style="padding-top:50px">\
  20. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  21. <div class="controls"><button class="btn_normal_long btn"\
  22. id="browser_btn_save">浏览器缓存清理</button></div>\
  23. </div>\
  24. <div class="clearboth" style="padding-top: 40px;">\
  25. <div style="width: 170px; margin-right: 10px; margin-top: 8px;" class="control-label"\
  26. lang-id="IDS_lan_ip_filter_mode">使用浏览器</div>\
  27. <div class="controls" style="margin-top:7px;">\
  28. <div class="pull-left">\
  29. <div onclick="radio(this)" name="browser_provider_radio" id="cefclient_browser"\
  30. class="radio_btn_off"></div>\
  31. </div>\
  32. <div class="pull-left" style="width:100px;">第三方</div>\
  33. <div class="pull-left">\
  34. <div onclick="radio(this)" name="browser_provider_radio" id="uos_browser"\
  35. class="radio_btn_on"></div>\
  36. </div>\
  37. <div class="pull-left" style="padding-top:0px;">系统自带\
  38. </div>\
  39. </div>\
  40. </div>\
  41. <div class="clearboth" style="padding-top:20px"></div>\
  42. </div>\
  43. <div id="sogou_management_div" style="margin-top: 40px; padding-bottom: 20px; border-bottom: 1px solid rgb(243, 243, 243);">\
  44. <div style="margin-top: 30px; font-size: 16px; "><span>Sogou输入法</span></div>\
  45. </div>\
  46. <div class="clearboth" id="browser_sogou_info_div" style="padding-top:20px">\
  47. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  48. <div class="controls"><span id="sogou_info_detail">无法获取输入法信息</span>\
  49. </div>\
  50. </div>\
  51. <div class="clearboth" id="browser_sogou_btn_save_div" style="padding-top:50px">\
  52. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  53. <div class="controls"><button class="btn_normal_long"\
  54. id="browser_sogou_btn_restart">重启搜狗输入法服务V4.0</button></div>\
  55. </div>\
  56. <div class="clearboth" id="browser_sogou_btn_fetch_div" style="padding-top:50px">\
  57. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  58. <div class="controls"><button class="btn_normal_long"\
  59. id="browser_sogou_btn_fetch">搜狗输入法信息快照</button></div>\
  60. </div>\
  61. <div class="clearboth" id="browser_screen_info_fetch_div" style="padding-top:50px">\
  62. <div class="control-label" style="margin-top: 8px;">&nbsp;</div>\
  63. <div class="controls"><button class="btn_normal_long"\
  64. id="browser_screen_info_fetch">屏幕显示信息获取</button></div>\
  65. </div>\
  66. </div>\
  67. <div id="browser_activation_content" class="page_prompt_info page_scenes_info_text hide">\
  68. </div>\
  69. </div>';
  70. $("#rightpagearea").prepend(page);
  71. if (typeof browserRenderPage == "function") {
  72. beforeRenderPage("browser");
  73. browserRenderPage();
  74. afterRenderPage("browser");
  75. }
  76. }
  77. var browserController = (function() {
  78. var gCurrentBrowserMode = '0';
  79. function updateBrowserCacheClearFlag() {
  80. let req = new Request();
  81. req.configType = 7; //GlobalCache
  82. req.section = 'Browser';
  83. req.option = true; //Write
  84. req.key = 'CacheClear';
  85. req.reserved1 = 0;
  86. req.reserved2 = 0;
  87. req.reserved3 = 'true';
  88. req.reserved4 = '';
  89. utilStartSubmitDialog();
  90. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  91. utilStopSubmitDialog();
  92. if (ret.errorCode === 0) {
  93. utilStartAlertDialog("清理指令已下发,请重启应用以执行浏览器缓存清理。");
  94. } else {
  95. RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
  96. }
  97. });
  98. }
  99. function restartSogouSrvRestartFlag() {
  100. let req = new Request();
  101. req.configType = 3; //RunConfig
  102. req.section = 'Browser';
  103. req.option = true; //Write
  104. req.key = 'SogouRestart';
  105. req.reserved1 = 0;
  106. req.reserved2 = 0;
  107. req.reserved3 = 'true';
  108. req.reserved4 = '';
  109. utilStartSubmitDialog();
  110. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  111. utilStopSubmitDialog();
  112. if (ret.errorCode === 0) {
  113. utilStartAlertDialog("重启指令已下发,请重启应用以执行该操作。");
  114. } else {
  115. RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
  116. }
  117. });
  118. }
  119. //V4.0
  120. function restartSogouProcess()
  121. {
  122. let req = new Request();
  123. req.type = 1; //搜狗输入法
  124. req.reserved1 = 0;
  125. req.reserved2 = 0;
  126. req.timeout = 65000;
  127. utilStartSubmitDialog();
  128. RVC.ResourceWatcherEntity.RestartThirdPartyProgram(req, function(ret) {
  129. utilStopSubmitDialog();
  130. if(ret.errorCode === 0) {
  131. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  132. if(result.result == 0) {
  133. utilStartAlertDialog("输入法重启成功,请退出当前页面,继续业务办理。");
  134. } else {
  135. utilStartAlertDialog("重启输入法失败:[" + result.result + "] " + result.msg);
  136. }
  137. } else {
  138. RVC.ResourceWatcherEntity.commErrorCallback(ret);
  139. }
  140. });
  141. }
  142. //V3.0
  143. function restartSogouSrv() {
  144. let req = new Request();
  145. req.configType = 0;
  146. req.timeout = 30000;
  147. req.section = 'SougouInput';
  148. req.option = false;
  149. req.key = 'SogouRestart';
  150. req.reserved1 = 0;
  151. req.reserved2 = 0;
  152. req.reserved3 = '';
  153. req.reserved4 = '';
  154. utilStartSubmitDialog();
  155. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  156. utilStopSubmitDialog();
  157. if (ret.errorCode === 0) {
  158. utilStartAlertDialog("输入法重启成功,请退出当前页面,继续业务办理。"
  159. + "<br><br><span style='color:red'>提示:重启后页面唤起输入法可能会耗时较长,请耐心多次点击内容输入框,如果长时间无响应,请再次进入此页面执行重启。</span>");
  160. } else {
  161. RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
  162. }
  163. });
  164. }
  165. function FetchScreenDisplayInfo() {
  166. let req = new Request();
  167. req.type = 1;//屏幕信息
  168. req.reserved1 = 0;
  169. req.reserved2 = 0;
  170. req.timeout = 20000;
  171. utilStartSubmitDialog();
  172. RVC.ResourceWatcherEntity.FetchSystemSnapshot(req, function(ret) {
  173. utilStopSubmitDialog();
  174. if(ret.errorCode === 0) {
  175. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  176. if(result.result == 0) {
  177. utilStartAlertDialog(result.msg);
  178. } else {
  179. utilStartAlertDialog("获取信息失败:[" + result.result + "] " + result.msg);
  180. }
  181. } else {
  182. RVC.ResourceWatcherEntity.commErrorCallback(ret);
  183. }
  184. });
  185. }
  186. function FetchSogouInputInfo() {
  187. let req = new Request();
  188. req.configType = 0;
  189. req.section = 'SougouInput';
  190. req.option = false;
  191. req.key = 'Snapshot';
  192. req.reserved1 = 0;
  193. req.reserved2 = 0;
  194. req.reserved3 = '';
  195. req.reserved4 = '';
  196. utilStartSubmitDialog();
  197. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  198. utilStopSubmitDialog();
  199. if (ret.errorCode === 0) {
  200. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  201. if(result.reserved3 === '') {
  202. utilStartAlertDialog("操作成功!");
  203. } else {
  204. utilStartAlertDialog(result.reserved3);
  205. }
  206. } else {
  207. RVC.DeviceControlEntityCtrl.commErrorCallback(ret);
  208. }
  209. });
  210. }
  211. function restartBrowser() {
  212. utilStartConfirmDialog("确认要重启浏览器(重启过程中当前页面也会一同消失,属正常现象,请观察业务界面是否正常即可)?", function() {
  213. let req = new Request();
  214. req.option = 1; //启动实体
  215. req.additional = 0;
  216. req.devId = 0;
  217. req.entityName = 'Chromium';
  218. req.force = true;
  219. req.param = '';
  220. req.reserved1 = 0;
  221. req.reserved2 = '';
  222. req.timeout = 60000;
  223. utilStartSubmitDialog('重启过程中此页面会消失,属正常现象,正在重启...');
  224. RVC.HealthmanagerEntityCtrl.ControlEntityLife(req, function(ret) {
  225. utilStopSubmitDialog();
  226. if(ret.errorCode === 0) {
  227. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  228. if(result.result == 0) {
  229. utilStartAlertDialog('重启浏览器成功,请稍后');
  230. } else {
  231. utilStartAlertDialog("重启浏览器失败:[" + result.result + "] " + result.msg);
  232. }
  233. } else {
  234. utilStartAlertDialog("请求失败:" + ErrorCodeStringfy(ret.errorCode));
  235. }
  236. });
  237. });
  238. }
  239. function saveButtonHandle() {
  240. utilStartConfirmDialog("确认要清理浏览器缓存吗?", function() {
  241. updateBrowserCacheClearFlag();
  242. });
  243. }
  244. function saveBrowserTypeSelect(usingUOS, failCallback) {
  245. let req = new Request();
  246. req.configType = 7; //GlobalCache
  247. req.section = 'BusinessBrowserType';
  248. req.option = true;
  249. req.key = 'FultureEx';
  250. req.reserved1 = 0;
  251. req.reserved2 = 0;
  252. if(!usingUOS) {
  253. req.reserved3 = '1';
  254. } else {
  255. req.reserved3 = '0';
  256. }
  257. req.reserved4 = '';
  258. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  259. if (ret.errorCode === 0) {
  260. utilShowToast('设置成功!请通过重启应用生效');
  261. } else {
  262. utilStartAlertDialog("设置失败! ErrorCode: " + ErrorCodeStringfy(ret.errorCode), function(){
  263. if(failCallback) {
  264. failCallback();
  265. }
  266. });
  267. }
  268. });
  269. }
  270. function selectBrowserUseMode() {
  271. $(document).on('click', "[name='browser_provider_radio']", function () {
  272. if ($('#cefclient_browser').hasClass('radio_btn_on')) {
  273. gCurrentBrowserMode = '0';
  274. console.log("cefclient!");
  275. saveBrowserTypeSelect(false);
  276. } else {
  277. gCurrentBrowserMode = '1';
  278. console.log("uos!");
  279. saveBrowserTypeSelect(true);
  280. }
  281. });
  282. }
  283. function initBrowserTypeSelect() {
  284. let req = new Request();
  285. req.configType = 7; //GlobalCache
  286. req.section = 'BusinessBrowserType';
  287. req.option = false;
  288. req.key = 'FultureEx';
  289. req.reserved1 = 0;
  290. req.reserved2 = 0;
  291. req.reserved3 = '';
  292. req.reserved4 = '';
  293. RVC.DeviceControlEntityCtrl.ReadConfigValue(req, function(ret) {
  294. if (ret.errorCode === 0) {
  295. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  296. if(result.value === '1') {
  297. $('#cefclient_browser').addClass('radio_btn_on').removeClass('radio_btn_off');
  298. $('#uos_browser').addClass('radio_btn_off').removeClass('radio_btn_on');
  299. } else {
  300. $('#uos_browser').addClass('radio_btn_on').removeClass('radio_btn_off');
  301. $('#cefclient_browser').addClass('radio_btn_off').removeClass('radio_btn_on');
  302. }
  303. } else {
  304. $('#cefclient_browser').addClass('radio_btn_off_disabled').removeClass('radio_btn_on').removeClass('radio_btn_off');
  305. $('#uos_browser').addClass('radio_btn_off_disabled').removeClass('radio_btn_on').removeClass('radio_btn_off');
  306. }
  307. });
  308. }
  309. function initSogouVersionInfo()
  310. {
  311. let req = new Request();
  312. req.mode = 1;
  313. RVC.ResourceWatcherEntity.GetThirdPartyInstallState(req, function(ret) {
  314. if (ret.errorCode === 0) {
  315. let result = JSON.parse(ret[RVC.EntityController.sigResponseUUID])
  316. if(result.status == 1) {
  317. const version = result.version;
  318. const path = result.path;
  319. const installTime = result.reserverd1;
  320. var value = "当前版本:" + version + "<br/>";
  321. value += "安装时间:" + installTime + "<br/>";
  322. console.log(value);
  323. $('#sogou_info_detail').html(value);
  324. } else {
  325. var value = "输入法未安装或未启动!!";
  326. $('#sogou_info_detail').html(value);
  327. }
  328. } else {
  329. var value = "获取输入法版本失败:" + ErrorCodeStringfy(ret.errorCode);
  330. $('#sogou_info_detail').html(value);
  331. }
  332. });
  333. }
  334. function initPage() {
  335. $(document).on('click', '#browser_btn_save', saveButtonHandle);
  336. $(document).on('click', '#btn_restart_chromium', restartBrowser);
  337. $(document).on('click', '#browser_sogou_btn_restart', restartSogouProcess);
  338. $(document).on('click', '#browser_sogou_btn_fetch', FetchSogouInputInfo);
  339. $(document).on('click', '#browser_screen_info_fetch', FetchScreenDisplayInfo);
  340. selectBrowserUseMode();
  341. initSogouVersionInfo();
  342. initBrowserTypeSelect();
  343. }
  344. var fistTime = true;
  345. function init() {
  346. if (fistTime) {
  347. fistTime = false;
  348. }
  349. initPage();
  350. }
  351. return { init: init };
  352. }());
  353. window.browserRenderPage = function () {
  354. browserController.init();
  355. };