更新记录

1.0.3(2024-03-21)

使用插件需要打自定义基座

1.0.2(2024-03-21)

新增UrlSchemes跳转功能

1.0.1(2024-03-15)

简单的音乐通知

查看更多

平台兼容性

Vue2 Vue3
App 快应用 微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序
HBuilderX 3.6.8,Android:5.0,iOS:不支持 × × × × × ×
钉钉小程序 快手小程序 飞书小程序 京东小程序
× × × ×
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
× × × × × × × × ×

tq-gt-notice

使用GT库源码开源项目

使用说明

名称 描述 参数 说明
notificationForNormal 普通通知 notification:NotificationInfo 返回值:void
notificationImg 大图通知 notification:NotificationInfo 返回值:void
notificationTexts 多文本通知 notification: NotificationTexts 返回值:NotificationCompat.Builder
addNotificationTexts 追加文本通知 builder: Builder,texts : string[] 返回值:void
notificationMsgs 聊天消息通知 notification: NotificationMsgs 返回值:NotificationCompat.Builder
addNotificationMsgs 追加聊天消息通知 builder: Builder,texts : ChatMsg[] 返回值:void
notificationProgress 下载进度通知 notification:NotificationInfo 返回值:NotificationCompat.Builder
updateNotificationProgress 更新下载进度通知 builder: Builder,progress : number 返回值:void
musicNotification 音乐通知 notification:NotificationInfo 返回值:void
<template>
    <view class="content">
        <image class="logo" src="/static/logo.png"></image>
        <view class="text-area">
            <text class="title">{{title}}</text>
        </view>
        <button @click="notice">普通通知</button>
        <button @click="notice2">多文本通知</button>
        <button @click="notice3">聊天消息通知</button>
        <button @click="notice4">下载进度通知</button>
        <button @click="notice5">大图通知</button>
        <button @click="notice6">音乐通知</button>
    </view>
</template>

<script>
    import {
        notificationForNormal,
        NotificationInfo,
        notificationTexts,
        notificationMsgs,
        notificationProgress,
        NotificationTexts,
        addNotificationTexts,
        NotificationMsgs,
        ChatMsg,
        addNotificationMsgs,
        updateNotificationProgress,
        notificationImg,
        musicNotification
    } from "@/uni_modules/tq-gt-notice";
    export default {
        data() {
            return {
                title: 'Hello'
            }
        },
        onLoad() {

        },
        methods: {
            notice() {
                let notice: NotificationInfo = {
                    title: "通知标题",
                    msg: "通知内容",
                    cancel: true,
                    lockShow: true,
                    url: "https://www.baidu.com" //lottieplu://pages/home/home   lottieplu://为scheme
                }
                notificationForNormal(notice)
            },
            notice2() {
                let notice: NotificationTexts = {
                    title: "通知标题",
                    cancel: true,
                    lockShow: true,
                    texts: [
                        "1.GT库在很早的版本里就有出",
                        "2.通知栏封装方法,但使用起来非常有局限性",
                        "3.接下来咋们来看看新版GT库里的8种通知栏"
                    ],
                    url: "https://www.baidu.com"
                }
                let builder = notificationTexts(notice)

                setTimeout(() => {
                    addNotificationTexts(builder,[
                        "4.GT库目前总共封装了8种通知栏,",
                        "5.每一个通知栏使用起来都特别简单的,",
                        "6.最主要的还支持完全自定义通知栏。",
                        "7.GT库不止这一个好用的库~"
                    ])
                },3000)
            },
            notice3() {
                let notice: NotificationMsgs = {
                    title: "通知标题",
                    cancel: true,
                    lockShow: true,
                    msgs: [
                        { name: "黄蓉",msg: "反对法士大夫发士大夫"},
                        { name: "郭靖",msg: "大夫发士大夫"},
                        { name: "杨康",msg: "反对法士大夫"},
                    ] as ChatMsg[],
                    url: "https://www.baidu.com"
                }
                let builder = notificationMsgs(notice)

                setTimeout(() => {
                    addNotificationMsgs(builder,[
                        { name: "杨康",msg: "反对法士大夫发士大夫"},
                        { name: "杨康",msg: "大夫发士大夫"},
                        { name: "杨康",msg: "反对法士大夫"},
                    ] as ChatMsg[])
                },3000)
            },
            notice4() {
                let notice: NotificationInfo = {
                    title: "检测到最新版本",
                    msg: "正在更新中,请稍后...",
                    cancel: true,
                    lockShow: true,
                    url: "https://www.baidu.com"
                }
                let builder = notificationProgress(notice)

                let progress = 1;

                setInterval(() => {
                    if(progress >= 100) {
                        return 
                    }
                    progress += 10;
                    updateNotificationProgress(builder,progress)
                },1000)
            },
            notice5() {
                let notice: NotificationInfo = {
                    title: "大图通知标题",
                    msg: "通知内容",
                    cancel: true,
                    lockShow: true,
                    url: "https://www.baidu.com"
                }
                notificationImg(notice)
            },
            notice6() {
                let notice: NotificationInfo = {
                    title: "通知标题",
                    msg: "通知内容",
                    cancel: false,
                    lockShow: true,
                    url: "https://www.baidu.com"
                }
                musicNotification(notice)
            },
        }
    }
</script>

<style>
    .content {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .logo {
        height: 200rpx;
        width: 200rpx;
        margin-top: 200rpx;
        margin-bottom: 50rpx;
    }

    .title {
        font-size: 36rpx;
        color: #8f8f94;
    }
</style>

注意

1、本插件包含原生第三方库需要配置gradle库和sdk库

Android UTS扩展开发

本人使用的gradle库为gradle-6.9.1-bin.zip,其他版本可使用官方推荐版本

2、运行demo项目需要打自定义基座

ps: 如果有问题可以咨询作者,本人QQ:1307905648,也可以在评论区留言截图配置环境和错误信息

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

许可协议

MIT协议

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问