当前位置: 首页 > news >正文

哪些大型网站有做互联网金融温江 网站建设

哪些大型网站有做互联网金融,温江 网站建设,百度推广需要多少钱,云南百度公司思路#xff1a;无论vue还是react打包都会有dist文件夹#xff0c;内部有index.html。我是想根据index.html中的script src地址是否改变#xff0c;判断项目是否有新内容。 具体代码如下 首先先拿到生产环境中index.html文本#xff0c;由于是单页面应用使用fetch(/?_st…思路无论vue还是react打包都会有dist文件夹内部有index.html。我是想根据index.html中的script src地址是否改变判断项目是否有新内容。 具体代码如下 首先先拿到生产环境中index.html文本由于是单页面应用使用fetch(/?_stampDate.now())来拿到html文本。并获取所有的src地址。 const scriptReg /\script.*src[](?src[^])/gm;async function getScriptSrcs() {const html await fetch(/?_timestamp Date.now()).then((res) res.text(),);scriptReg.lastIndex 0;let result [];let match;while ((match scriptReg.exec(html))) {result.push(match.groups.src);}return result; } 全局定义lastSrcs表示旧的地址数组然后和新的newScripts对比如果长度不同或者某一项不同则表示项目有新内容更新。 async function needUpdate() {const newScripts await getScriptSrcs();if (!lastSrcs) {lastSrcs newScripts;return false;}let result false;if (lastSrcs.length ! newScripts.length) {result true;}for (let i 0; i lastSrcs.length; i) {if (lastSrcs[i] ! newScripts[i]) {result true;break;}}lastSrcs newScripts;return result; } 最终我们使用轮询的方式监听是否变化。 const autoRefresh(){setTimeout(async(){const willUpdate await needUpdate();if (willUpdate) {const result confirm(页面有更新请刷新页面);if (result) {location.reload();}}autoRefresh();},5000); } 最后在main.ts中引入即可。有什么问题私信哦。 后续我想加一个可以自动关闭的功能但是使用window.confirm我无法实现尝试使用alert也无法成功然后就想到是不是可以重写这个alert,结果发现果然可以。代码如下直接复制即可使用需要在入口文件引入。 let lastSrcs; let timeoutId: any 0; let strHtml,time 5,timer null,timer1 null; const scriptReg /\script.*src[](?src[^])/gm;async function getScriptSrcs() {const html await fetch(/?_timestamp Date.now()).then((res) res.text(),);scriptReg.lastIndex 0;let result [];let match;while ((match scriptReg.exec(html))) {result.push(match.groups.src);}return result; } async function needUpdate() {const newScripts await getScriptSrcs();if (!lastSrcs) {lastSrcs newScripts;return false;}let result false;if (lastSrcs.length ! newScripts.length) {result true;}for (let i 0; i lastSrcs.length; i) {if (lastSrcs[i] ! newScripts[i]) {result true;break;}}lastSrcs newScripts;return result; }function createMask() {var shield document.createElement(DIV);shield.id shield;shield.style.position absolute;shield.style.left 0px;shield.style.top 0px;shield.style.width 100%;shield.style.height document.body.scrollHeight px;shield.style.background transparent;shield.style.textAlign center;shield.style.zIndex 10000;shield.style.filter alpha(opacity0);document.body.appendChild(shield);return shield; }function createAlert(txt) {var alertFram document.createElement(DIV);alertFram.id alertFram;alertFram.style.position absolute;alertFram.style.left 50%;alertFram.style.top 0;alertFram.style.background #fff;alertFram.style.transform translateX(-50%);alertFram.style.width 450px;alertFram.style.height 150px;alertFram.style.textAlign center;alertFram.style.lineHeight 150px;alertFram.style.zIndex 10001;strHtml ul stylelist-style:none;margin:0px;padding:0px;width:100%;border-radius:10px;overflow:hidden;box-shadow:0 0 5px 5px #ccc\n;strHtml li stylebackground:#1677ff;text-align:left;padding-left:20px;font-size:14px;font-weight:bold;height:40px;line-height:40px;color:#fff系统提示/li\n;strHtml li id_content stylebackground:#fff;text-align:center;font-size:14px;height:100px;line-height:100px; txt /li\n;strHtml li stylebackground:#fff;text-align:right;font-weight:bold;height:50px;line-height:25px;padding-bottom:10px ;padding-right:20px;input typebutton id_btn_click styleoutline:none;cursor:pointer;border:0;width:70px;height:40px;border-radius:20px;background:#1677ff;color:#fff value确 定//li\n;strHtml /ul\n;alertFram.innerHTML strHtml;document.body.appendChild(alertFram);return alertFram; }function removerDom(alertFram, mask) {document.body.removeChild(alertFram);document.body.removeChild(mask);window.location.reload(); }function controlTime(alertFram, mask) {timer1 setInterval(() {time - 1;document.getElementById(_content).textContent 页面有更新${time}秒后将强制刷新页面;if (time 0) {clearTimeout(timer1);removerDom(alertFram, mask);}}, 1000); }window.alert function (txt) {const alertFram createAlert(txt);const mask createMask();controlTime(alertFram, mask);const dom document.getElementById(_btn_click);dom.onclick () {removerDom(alertFram, mask);}; };const duration 5000;function autoRefresh() {timer setTimeout(async () {const willUpdate await needUpdate();let content 页面有更新${time}秒后将强制刷新页面;if (willUpdate) {clearTimeout(timer);alert(content);} else {autoRefresh();}}, duration); } const env process.env.UMI_ENV;env production autoRefresh();
http://www.zqtcl.cn/news/33120/

相关文章:

  • 咨询行业网站建设公司农业推广学
  • 为什么要学电商网站建设企业宣传推广怎么做
  • 企业网站营销常用的方法个人网站建设 实验报告
  • 产品网站建设公司酒店网站建设目标
  • 腾冲住房和城乡建设局网站企业网站导航菜单
  • 制作网页的模板的网站外贸网页制作公司
  • 浙江立鹏建设有限公司网站西安有没有网站建设和营销的培训
  • 2010网站建设管理网站不兼容怎么办
  • 河长制网站建设马鞍山网站建设电话
  • 湖南seo网站多少钱免费小程序开发报价
  • 哪个网站可以做3d网站语言编程
  • 六安做网站多少钱然后在亚马逊网站上做外贸
  • 网站开发需要做什么工作网站开发与数据库
  • 网站建设流程策划方案某网站安全建设方案
  • 成绩查询网站开发网站策划是干什么的
  • 建设网站前需考虑哪些问题建设彩票网站
  • 濮阳网站建设 公司名字wordpress软件
  • 淄博公司网站建设效果如何进行网络推广
  • 网站制作教程手机wordpress重新安装插件
  • 济南网站建设网站建设浙江省建设建材工会网站
  • 做公司网站计入什么会计科目知名高端网站建设报价
  • 国外教程 网站wordpress 菜单保存在哪
  • 网站开发公司挣钱吗WordPress更改logo插件
  • 局域网做网站 内网穿透男和女做暖暖网站
  • 微商城网站开发视频深圳设计公司品牌
  • 网站运营与推广方案QQ群消息同步到WordPress
  • 网站查询工具seo公司厦门
  • 网站 只收录首页梧州网站建设有哪些
  • 汇鑫科技网站建设重庆建工
  • 公司建多个网站php企业网站cms