# barkjs **Repository Path**: xieyuanbin1/barkjs ## Basic Information - **Project Name**: barkjs - **Description**: bark for js - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-09-03 - **Last Updated**: 2023-06-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # @xybin1990/barkjs ## 安装 ```shell npm install @xybin1990/barkjs ``` ## 使用 ```typescript import { Bark } from '@xybin1990/barkjs'; const bark = new Bark({ baseUrl: '', // 默认不传使用官方地址:https://api.day.app 或者可以设置自己部署的私有地址。 key: '' // Bark 软件中生成的 Key。 }) bark.push({ body: '' // 消息内容。 可以使用 '\n' 来达到换行的效果 }) ``` ## Push data | 字段 | 数据类型 | 是否必须 | 说明 | | :---------------: | :------: | :------: | :----------------------------------------: | | title | string | 否 | 标题 会加粗显示 | | body | string | 是 | 内容 | | category | string | 否 | 预留字段 暂时忽略 | | automaticallyCopy | boolean | 否 | 设置为 1 会自动将内容复制到剪切板 | | copy | string | 否 | 指定复制的内容 否则为实际消息 | | url | string | 否 | 点击推送跳转的 url | | isArchive | number | 否 | 是否保存推送记录 不指定则按照 APP 内的设定 | | group | string | 否 | 消息分组 | | icon | string | 否 | 指定消息图标 | | sound | string | 否 | 设定提示音 | | level | string | 否 | 设定时效性 | | badge | number | 否 | 设定 APP 角标 可以设定任意数字 | ## Sound Support ```typescript enum Sound { alarm = 'alarm', anticipate = 'anticipate', bell = 'bell', birdsong = 'birdsong', bloom = 'birdsong', calypso = 'birdsong', chime = 'chime', choo = 'choo', descent = 'descent', electronic = 'electronic', fanfare = 'fanfare', glass = 'glass', gotosleep = 'gotosleep', healthnotification = 'healthnotification', horn = 'horn', ladder = 'ladder', mailsent = 'mailsent', minuet = 'minuet', multiwayinvitation = 'multiwayinvitation', newmail = 'newmail', newsflash = 'newsflash', noir = 'noir', paymentsuccess = 'paymentsuccess', shake = 'shake', sherwoodforest = 'sherwoodforest', silence = 'silence', spell = 'spell', suspense = 'suspense', telegraph = 'telegraph', tiptoes = 'tiptoes', typewriters = 'typewriters', update = 'update', } ``` ## Level 时效性说明 - active: 不设置时的默认值,系统会立即亮屏显示通知。 - timeSensitive:时效性通知,可在专注状态下显示通知。 - passive: 仅将通知添加到通知列表,不会亮屏提醒