{"id":16636573,"url":"https://github.com/nihaojob/popular-message","last_synced_at":"2025-04-05T15:09:55.904Z","repository":{"id":45583169,"uuid":"377190225","full_name":"nihaojob/popular-message","owner":"nihaojob","description":"轻量级的信息反馈组件","archived":false,"fork":false,"pushed_at":"2022-09-01T15:17:50.000Z","size":124,"stargazers_count":278,"open_issues_count":0,"forks_count":23,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-03-29T14:08:19.462Z","etag":null,"topics":["notification","notifications","toast","toastify"],"latest_commit_sha":null,"homepage":"https://nihaojob.github.io/popular-message","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nihaojob.png","metadata":{"files":{"readme":"README-zh.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["https://nihaojob.github.io/2021/08/05/pay/"]}},"created_at":"2021-06-15T14:24:02.000Z","updated_at":"2024-12-08T19:18:06.000Z","dependencies_parsed_at":"2022-09-05T09:51:30.962Z","dependency_job_id":null,"html_url":"https://github.com/nihaojob/popular-message","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihaojob%2Fpopular-message","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihaojob%2Fpopular-message/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihaojob%2Fpopular-message/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nihaojob%2Fpopular-message/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nihaojob","download_url":"https://codeload.github.com/nihaojob/popular-message/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353749,"owners_count":20925329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notification","notifications","toast","toastify"],"created_at":"2024-10-12T06:07:11.258Z","updated_at":"2025-04-05T15:09:55.877Z","avatar_url":"https://github.com/nihaojob.png","language":"JavaScript","funding_links":["https://nihaojob.github.io/2021/08/05/pay/"],"categories":[],"sub_categories":[],"readme":"中文 | [English](https://github.com/nihaojob/popular-message/blob/main/README.md)\n# popular-message\n[![travis-ci](https://api.travis-ci.com/nihaojob/popular-message.svg?branch=main)](https://travis-ci.com/github/nihaojob/popular-message)\n[![Coverage Status](https://coveralls.io/repos/github/nihaojob/popular-message/badge.svg)](https://coveralls.io/github/nihaojob/popular-message)\n[![license](https://img.shields.io/github/license/nihaojob/popular-message)](https://github.com/nihaojob/popular-message/blob/main/LICENSE)\n[![release](https://img.shields.io/github/release/nihaojob/popular-message)](https://github.com/nihaojob/popular-message/releases)\n\n轻量级的信息反馈组件，在顶部居中显示，并自动消失。有多种不同的提示状态可选择。\n\n[体验Demo](https://nihaojob.github.io/popular-message)\n\u003cp align=\"center\"\u003e\u003cimg width=\"492\" src=\"./examples.png\" /\u003e\u003c/p\u003e\n\n\n\n## 特点\n\n1. 与iview的$mesage组件的API保持一致。\n2. 无任何依赖，非常轻量，200 行左右的源码，压缩后更小。\n3. UI漂亮，参考iview UI样式。\n\n## Install\n1. 直接使用unpkg [在线链接](https://unpkg.com/browse/popular-message@1.0.0/index.js)\n\n```HTML\n\u003cscript src=\"https://unpkg.com/popular-message/index.js\"\u003e\u003c/script\u003e\n\u003clink rel=\"stylesheet\" href=\"https://unpkg.com/popular-message/index.css\"\u003e\n```\n2. 通过npm 或者 yarn安装\n```bash\n$ npm install popular-message\n$ yarn add popular-message\n```\n## Use\n通过 script 引用，会得到一个全局变量 `$message`。\n\n通过npm安装，需要import导入\n```js\nimport $message from 'popular-message';\nimport 'popular-message/index.css';\n```\n\n在页面中使用\n```js\n\u003c!-- 设置全局配置 --\u003e\n$message.config({ top:85, duration: 4})\n\n\u003c!-- 普通调用 --\u003e\n$message.info('这是一条普通的提示')\n$message.success('这是一条成功的提示')\n$message.warning('这是一条警告的提示')\n$message.error('这是一条格式错误的提示')\n$message.loading('正在加载中...')\n\n\u003c!-- 关闭按钮 --\u003e\n$message.info('这是一条带关闭按钮的消息', {\n    onClose:() =\u003e console.log('关闭'),\n    closable: true,\n    duration: 6\n})\n\n\u003c!-- 注销 --\u003e\n$message.destroy()\n```\n\n## API\n### Message instance\n通过直接调用以下方法来使用：\n- `$message.info(config)`\n- `$message.success(config)`\n- `$message.warning(config)`\n- `$message.error(config)`\n- `$message.loading(config)`\n\n参数 config 可以是字符串或对象，当为字符串时，直接显示内容，当为对象时，具体说明如下：\n\n|  属性 | 说明  | 类型|  默认值|\n|---    |---   |--- | ---   |\n|  content |  提示内容 |String | -|\n|  duration |  自动关闭的延时，单位秒，不关闭可以写 0 |Number | 2|\n|  onClose |  关闭时的回调\t |Function | -|\n|  closable |  是否显示关闭按钮\t |Boolean | false|\n\n另外提供了全局配置和全局销毁的方法：\n- `$message.config(options)`\n- `$message.destroy()`\n\n```JS\n$Message.config({\n    top: 50,\n    duration: 3\n});\n```\n\n|  属性 | 说明  | 类型|  默认值|\n|---    |---   |--- | ---   |\n|  top |  提示组件距离顶端的距离，单位像素 |Number | 24|\n|  duration |  默认自动关闭的延时，单位秒 |Number | 1.5|\n|  singleton |  消息框单例模式\t |Boolean | false|\n|  dangerUseHtml |  是否将 content属性作为 HTML 片段处理\t |Boolean | false|\n## License\nLicensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihaojob%2Fpopular-message","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnihaojob%2Fpopular-message","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnihaojob%2Fpopular-message/lists"}