UNPKG

@plasosdk/plaso-electron-sdk

Version:

伯索课堂Electron SDK

226 lines (194 loc) 5.82 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> * { font-family: "Microsoft YaHei", sans-serif; } body { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; } #btn_reload { width: 120px; height: 40px; background: #02c8f2; border-radius: 4px; border: none; margin: 10px auto; font-size: 20px; display: block; color: #fff; cursor: pointer; } .contain { position: absolute; width: 80px; height: 80px; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 20px; } .animate { position: absolute; width: 100%; height: 100%; left: 0; top: -25%; border-radius: 10%; z-index: 1; transform: translateZ(0); background: #8EEFC7; animation: animate .6s -.1s linear infinite; } .shadow { position: absolute; left: 0; width: 100%; bottom: -9%; height: 10%; background: #DFE6EC; border-radius: 50%; -webkit-animation: shadow .6s -.1s linear infinite; -moz-animation: shadow .6s -.1s linear infinite; -o-animation: shadow .6s -.1s linear infinite; animation: shadow .6s -.1s linear infinite; } @keyframes animate { 17% { border-bottom-right-radius: 10%; } 25% { transform: translateY(25%) rotate(22.5deg); } 50% { border-bottom-right-radius: 100%; transform: translateY(50%) scale(1, .9) rotate(45deg); } 75% { transform: translateY(25%) rotate(67.5deg); } 100% { transform: translateY(0) rotate(90deg); } } @keyframes shadow { 50% { transform: scale(1.25, 1); } } </style> <title></title> </head> <body> <div id="react_body"> <div class="contain" id="loading" style="display:none"> <div class="animate"></div> <div class="shadow"></div> </div> </div> </body> <script type="text/javascript"> //配置文件,主要是 thrift 接口地址和一些标识字符串 var globalAppInfo = {}; function getElectronRemote() { let _remote; try { _remote = window.require('electron').remote; if (!_remote) _remote = window.require('@electron/remote'); } catch (e) { console.error(err); } return _remote; } const include = function (url) { url = globalAppInfo.rhost + url; let ele; if (/\.css$/.test(url)) { ele = document.createElement('link'); ele.rel = "stylesheet"; ele.type = "text/css"; ele.href = url; } else { ele = document.createElement('script'); ele.src = url; } document.head.appendChild(ele); } function init(classObj) { let query; if (classObj) { globalAppInfo = Object.assign({}, classObj) } globalAppInfo.needFullScreen = false; if (globalAppInfo.rhost && globalAppInfo.rhost.substring(globalAppInfo.rhost.length - 1) != '/') { globalAppInfo.rhost += "/"; } if (globalAppInfo.dhost && globalAppInfo.dhost.substring(globalAppInfo.dhost.length - 1) != '/') { globalAppInfo.dhost += "/"; } path = globalAppInfo.initjs || "js/all.js"; include(path); } if (typeof require == "function") { const { ipcRenderer } = window.require('electron'); const { CLASS_WINDOW_MESG_TYPE } = require('./js/macro'); const queryString = location.href.split('?')[1]; queryString.split('&').forEach((pair) => { const [key, value] = pair.split('='); if (key === 'openerId') openerId = Number(value); }); ipcRenderer.on(CLASS_WINDOW_MESG_TYPE.INIT_CLASS_OPTIONS, (_, classObj) => { if (classObj) init(classObj); }); if(openerId){ const remote = getElectronRemote(); const webContents = remote.getCurrentWebContents(); ipcRenderer.sendTo(openerId, CLASS_WINDOW_MESG_TYPE.CLASS_READY, {webContentId: webContents.id}); } } /* * 加载超时函数,立即执行 * param: timeLength :超时时间 */ (function timeOut(timeLength) { const timer = setTimeout( function () { var loading = document.getElementById('loading'); if (loading) { loading.style.width = "100%"; loading.style.textAlign = "center"; eval("loading.innerHTML = '加载超时!请点击重新加载<button id=\"btn_reload\" onclick=\"reload()\">重新加载</button>'"); if (typeof require == "function" && globalAppInfo.clientType === 'nw') { var gui = require('nw.gui'); var win = gui.Window.get(); win.removeAllListeners(); } } }, timeLength * 1000 ) })(30); function reload() { if (typeof require == "function" && globalAppInfo.clientType === 'electron') { var remote = getElectronRemote(); var curWindow = remote.getCurrentWindow(); curWindow.webContents.reloadIgnoringCache() } else { location.reload(); } } </script> <script type="text/javascript"> if (globalAppInfo.background) { document.body.style.background = globalAppInfo.background; document.documentElement.style.background = globalAppInfo.background; } if (!globalAppInfo.noLoading) { var loadingDom = document.getElementById("loading"); if (loadingDom) loadingDom.style.display = ""; } </script> </html>