election-egg 自定义通知弹窗兼容win7和win10

实现效果

多个相同类型消息(a,a-1)只会显示一个弹窗,然后叠加;不同类型消息(abc)显示多个弹窗,上下叠加,点击不同消息跳转不同页面

代码

notifi.html
<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
</head>

<body onclick="clickBody()">
  <image class="image_close" src="../../../public/images/ic_close.png" mode="scaleToFill" onclick="clickClose(event)" />
  <div class="content">
    <h3 id="title"></h3>
    <h4 id="subtitle" style="display: none;"></h4>
    <p id="content"></p>
  </div>
</body>
<style>
  body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
  }

  h1 {
    font-size: 24px;
    margin: 0 0 5px;
  }

  p {
    font-size: 16px;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .image_close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
  }
</style>
<script>
  const { ipcRenderer } = window.require('electron');

  // 解析查询字符串为对象的函数
  function getQueryParams() {
    const queryParams = {};
    // location.search 会返回 URL 的查询参数部分(以 '?' 开头)
    const queryStr = window.location.search.substring(1);
    const params = queryStr.split('&');
    for (let i = 0; i < params.length; i++) {
      const pair = params[i].split('=');
      // decodeURIComponent 用于处理编码后的组件,确保特殊字符被正确解析
      const key = decodeURIComponent(pair[0]);
      const value = decodeURIComponent(pair[1] || '');
      if (key) queryParams[key] = value;
    }
    return queryParams;
  }
  // 使用上面定义的函数来获取查询参数
  const params = this.getQueryParams();
  console.log('params', params);
  // 获取要替换内容的元素
  var titleElement = document.getElementById('title');
  var subtitleElement
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值