zl程序教程

您现在的位置是:首页 >  其他

当前栏目

轻量完善的网站在线客服系统源码实现-GOFLY实现浏览器通知栏

2023-02-18 15:36:16 时间

GOFLY在线客服,是一套可私有化部署的开源客服系统,安装过程不超过五分钟,基于Golang开发,二进制文件可直接使用无需搭开发环境,下载zip解压即可,仅依赖MySQL数据库,是一个开箱即用的网页在线客服系统,致力于帮助广大开发者/中小站长快速整合私有客服功能

 

实现浏览器通知提示的效果

 

 

浏览器通知栏js函数

function notify(title, options, callback) {
    // 先检查浏览器是否支持
    if (!window.Notification) {
        console.log("浏览器不支持notify");
        return;
    }
    var notification;
    // 检查用户曾经是否同意接受通知
    if (Notification.permission === 'granted') {
        notification = new Notification(title, options); // 显示通知
        console.log("浏览器禁止了notify");
    } else {
        Notification.requestPermission();
    }
    if (notification && callback) {
        notification.onclick = function(event) {
            callback(notification, event);
        }
        setTimeout(function () {
            notification.close();
        },3000);
    }
}

这样的效果必须在https下才能有效果

在本地服务器下http也能有效果