{"id":13497748,"url":"https://github.com/hjyker/web-watermark","last_synced_at":"2025-03-28T22:31:49.275Z","repository":{"id":33659413,"uuid":"155856020","full_name":"hjyker/web-watermark","owner":"hjyker","description":"Watermark for web page","archived":false,"fork":false,"pushed_at":"2023-01-05T16:36:17.000Z","size":2108,"stargazers_count":15,"open_issues_count":16,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-10T21:23:17.338Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hjyker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-02T11:20:47.000Z","updated_at":"2023-07-19T08:06:17.000Z","dependencies_parsed_at":"2023-01-15T02:00:57.085Z","dependency_job_id":null,"html_url":"https://github.com/hjyker/web-watermark","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjyker%2Fweb-watermark","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjyker%2Fweb-watermark/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjyker%2Fweb-watermark/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hjyker%2Fweb-watermark/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hjyker","download_url":"https://codeload.github.com/hjyker/web-watermark/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246110265,"owners_count":20725022,"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":[],"created_at":"2024-07-31T20:00:37.926Z","updated_at":"2025-03-28T22:31:48.923Z","avatar_url":"https://github.com/hjyker.png","language":"JavaScript","funding_links":[],"categories":["纯原生(HTML/CSS/JavaScript)"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003eweb-watermark\u003c/h1\u003e\n\u003cp\u003e\n\n[![npm](https://img.shields.io/npm/v/web-watermark)](https://www.npmjs.com/package/web-watermark) ![](https://img.shields.io/bundlephobia/minzip/web-watermark) ![](https://img.shields.io/npm/dt/web-watermark) \n\n\u003c/p\u003e\n  \u003cp\u003e网页水印\u003c/p\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n```bash\nnpm install web-watermark\nor\nyarn add web-watermark\n```\n\n\u003ch2 align=\"center\"\u003eFeatrue\u003c/h2\u003e\n\n1. 支持 Canvas 或 SVG 渲染水印；\n2. Canvas 支持 Retina 高清显示；\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n```javascript\nimport Watermark from 'web-watermark'\n\nnew Watermark({\n  mode: 'canvas', // default\n  container: document.body, // default\n  watch: true, // default\n  text: '敏感信息请勿泄漏', // default\n  x: 0, // default\n  y: 50, // default\n  width: 150, // default\n  height: 100, // default\n  color: '#000', // default\n  fontSize: 12, // default\n  fontStyle: 'normal', // default\n  fontFamily: 'sans-serif', // default\n  alpha: 0.15, // default\n  deg: -15, // default\n}).render()\n```\n\n\u003ch2 align=\"center\"\u003eConfig\u003c/h2\u003e\n\n| 参数 | 取值 | 说明 |\n| :----: | :----: | :---- |\n| mode       | String: 'canvas'           | 水印渲染的模式，可选 'canvas' 或 'svg' 渲染          |\n| container  | Node: document.body        | 需要渲染水印的元素，默认为 body，即整个页面渲染         |\n| watch      | Boolean: true              | 监听水印元素是否被篡改，被修改或者删除等操作，则重新渲染水印  |\n| text       | String: '敏感信息请勿泄漏'    | 水印信息                                             |\n| x          | Number: 0                  | 水印 x 轴偏移量，用于微调水印位置                    |\n| y          | Number: 50                 | 水印 y 轴偏移量，用于微调水印位置                    |\n| width      | Number: 150                | 水印图片的宽度                                       |\n| height     | Number: 100                | 水印图片的高度                                       |\n| color      | String: '#000'             | 水印字体颜色                                         |\n| fontSize   | Number: 12                 | 水印字体大小                                         |\n| fontFamily | String: 'sans-serif''      | 水印字体                                             |\n| fontStyle  | String: 'normal'           | 水印字体样式，可选值和 CSS font-style 相同           |\n| alpha      | Number: 0.15               | 水印透明度                                           |\n| deg        | Number: -15                | 水印的倾斜角度，顺时针方向角度增加，以9点钟方向为0度 |\n| debugger   | Boolean: false             | 是否开启调试模式 |\n\n\u003ch2 align=\"center\"\u003eMethods\u003c/h2\u003e\n\n| 实例方法 | 参数 | 说明 |\n| :----: | :----: | :---- |\n| render(options) | 配置参数，如果传递了配置参数，会合并最近的配置 | 渲染水印，调用此函数才会生成水印 |\n| destroy() | - | 销毁水印 |\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjyker%2Fweb-watermark","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhjyker%2Fweb-watermark","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhjyker%2Fweb-watermark/lists"}