{"id":23111829,"url":"https://github.com/dext7r/h7ml-live2d-widget","last_synced_at":"2025-04-03T23:44:10.678Z","repository":{"id":244897525,"uuid":"814738081","full_name":"dext7r/h7ml-live2d-widget","owner":"dext7r","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-14T11:05:15.000Z","size":677,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T00:36:46.164Z","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":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dext7r.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-13T15:47:10.000Z","updated_at":"2024-06-28T12:36:23.000Z","dependencies_parsed_at":"2024-06-18T06:25:55.163Z","dependency_job_id":"a4171e2c-6f08-4ff9-94af-dd3cf4c47c26","html_url":"https://github.com/dext7r/h7ml-live2d-widget","commit_stats":null,"previous_names":["h7ml/h7ml-live2d-widget"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dext7r%2Fh7ml-live2d-widget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dext7r%2Fh7ml-live2d-widget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dext7r%2Fh7ml-live2d-widget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dext7r%2Fh7ml-live2d-widget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dext7r","download_url":"https://codeload.github.com/dext7r/h7ml-live2d-widget/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247097972,"owners_count":20883127,"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-12-17T02:11:03.982Z","updated_at":"2025-04-03T23:44:10.657Z","avatar_url":"https://github.com/dext7r.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Live2D Widget\n\n![](https://forthebadge.com/images/badges/built-with-love.svg)\n![](https://forthebadge.com/images/badges/uses-html.svg)\n![](https://forthebadge.com/images/badges/made-with-javascript.svg)\n![](https://forthebadge.com/images/badges/contains-cat-gifs.svg)\n![](https://forthebadge.com/images/badges/powered-by-electricity.svg)\n![](https://forthebadge.com/images/badges/makes-people-smile.svg)\n\n## 特性 Feature\n\n在网页中添加 Live2D 看板娘。兼容 PJAX，支持无刷新加载。  \nAdd Live2D widget to web page. Compatible with PJAX.\n\n**警告：本项目使用了大量 ES6 语法，不支持 IE 11 等老旧浏览器。**  \n**WARNING: This project does not support legacy browsers such as IE 11.**\n\n## 示例 Demo\n\n在[米米的博客](https://zhangshuqiao.org)的左下角可查看效果。（注：以下人物模型仅供展示之用，本仓库并不包含任何模型。）\n\n\u003cimg src=\"assets/screenshot-2.png\" width=\"280\"\u003e\u003cimg src=\"assets/screenshot-3.png\" width=\"280\"\u003e\u003cimg src=\"assets/screenshot-1.png\" width=\"270\"\u003e\n\n你也可以在允许的范围内进行二次开发，这里有一些示例\n\n- [demo.html](https://mi.js.org/live2d-widget/demo/demo.html) ，展现基础效果\n- [login.html](https://mi.js.org/live2d-widget/demo/login.html) ，仿 NPM 的登陆界面\n\n## 依赖 Dependencies\n\n本插件需要 Font Awesome (v4 或 v5) 图标支持，请确保相关样式表已在页面中加载。以 Font Awesome v4 为例，请在 `\u003chead\u003e` 中加入：  \nFont Awesome (v4 or v5) is required for this plugin. Take Font Awesome v4 as an example, please add the following in `\u003chead\u003e`:\n```xml\n\u003clink rel=\"stylesheet\" href=\"https://cdn.jsdelivr.net/npm/font-awesome/css/font-awesome.min.css\"\u003e\n```\n否则图标将无法正常显示。（如果网页中已经加载了任何版本的 Font Awesome，就不要重复加载了）\n\n## 使用 Usage\n\n将这一行代码加入 `\u003chead\u003e` 或 `\u003cbody\u003e`，即可展现出效果：\n```xml\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/autoload.js\"\u003e\u003c/script\u003e\n```\n如果网站启用了 PJAX，由于看板娘不必每页刷新，因此要注意将相关脚本放到 PJAX 刷新区域之外。\n\n换句话说，如果你是小白，或者只需要最基础的功能，就只用把这一行代码，连同前面加载 Font Awesome 的一行代码，一起放到 html 的 `\u003chead\u003e` 中即可。  \n对于用各种模版引擎（例如 Nunjucks，Jinja 或者 PHP）生成的页面，也要自行修改，方法类似，只是可能略为麻烦。以 [Hexo](https://hexo.io) 为例，需要在主题相关的 ejs 或 njk 模版中正确配置路径，才可以加载。\n\n**但是！我们强烈推荐自己进行配置，否则很多功能是不完整的，并且可能产生问题！**  \n如果你有兴趣自己折腾的话，请看下面的详细说明。\n\n### Using CDN\n\n要自定义有关内容，可以把这个仓库 Fork 一份，然后进行修改。这时，使用方法对应地变为\n```xml\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/username/live2d-widget@latest/autoload.js\"\u003e\u003c/script\u003e\n```\n将此处的 `username` 替换为你的 GitHub 用户名。为了使 CDN 的内容正常刷新，需要创建新的 git tag 并推送至 GitHub 仓库中，否则此处的 `@latest` 仍然指向更新前的文件。此外 CDN 本身存在缓存，因此改动可能需要一定的时间生效。相关文档：\n- [Git Basics - Tagging](https://git-scm.com/book/en/v2/Git-Basics-Tagging)\n- [Managing releases in a repository](https://help.github.com/en/github/administering-a-repository/managing-releases-in-a-repository)\n\n### Self-host\n\n你也可以直接把这些文件放到服务器上，而不是通过 CDN 加载。\n\n- 如果你能够通过 `ssh` 访问你的主机，请把整个仓库克隆到服务器上。执行：\n  ```bash\n  cd /path/to/your/webroot\n  # Clone this repository\n  git clone https://github.com/stevenjoezhang/live2d-widget.git\n  ```\n- 如果你的主机无法用 `ssh` 连接（例如一般的虚拟主机），请选择 `Download ZIP`，然后通过 `ftp` 等方式上传到主机上，再解压到网站的目录下。\n- 如果你是通过 Hexo 等工具部署的静态博客，请在博客源文件（即 `source`）目录下，执行前述的 `git clone` 命令。重新部署博客时，相关文件就会自动上传到对应的路径下。为了避免这些文件被 Hexo 插件错误地修改，可能需要设置 `skip_render`。\n\n这样，整个项目就可以通过你的服务器 IP 或者域名从公网访问了。不妨试试能否正常地通过浏览器打开 `autoload.js` 和 `live2d.min.js` 等文件，并确认这些文件的内容是完整和正确的。  \n一切正常的话，接下来修改一些配置就行了。（需要通过服务器上的文本编辑器修改；你也可以先在本地完成这一步骤，再上传到服务器上）  \n修改 `autoload.js` 中的常量 `live2d_path` 为 `live2d-widget` 这一目录的 URL。比如说，如果你能够通过\n```\nhttps://example.com/path/to/live2d-widget/live2d.min.js\n```\n访问到 `live2d.min.js`，那么就把 `live2d_path` 的值修改为\n```\nhttps://example.com/path/to/live2d-widget/\n```\n路径末尾的 `/` 一定要加上。具体可以参考 `autoload.js` 内的注释。  \n完成后，在你要添加看板娘的界面加入\n```xml\n\u003cscript src=\"https://example.com/path/to/live2d-widget/autoload.js\"\u003e\u003c/script\u003e\n```\n就可以加载了。\n\n## 后端 API\n\n`initWidget` 方法接受名为 `apiPath` 和 `cdnPath` 的参数，两者设置其中一项即可。其中 `apiPath` 为后端 API 的 URL，可以自行搭建，并增加模型（需要修改的内容比较多，此处不再赘述）。而 `cdnPath` 则是通过 jsDelivr 这样的 CDN 服务加载资源，更加稳定。\n\n## 目录结构 Files\n\n- `waifu-tips.js` 包含了按钮和对话框的逻辑；\n- `waifu-tips.json` 中定义了触发条件（`selector`，CSS 选择器）和触发时显示的文字（`text`）；\n- `waifu.css` 是看板娘的样式表。\n\n源文件是对 Hexo 的 [NexT 主题](http://github.com/next-theme/hexo-theme-next)有效的，为了适用于你自己的网页，可能需要自行修改，或增加新内容。  \n**警告：作者不对包括但不限于 `waifu-tips.js` 和 `waifu-tips.json` 文件中的内容负责，请自行确保它们是合适的。**\n\n如果有任何疑问，欢迎提 Issue。如果有任何修改建议，欢迎提 Pull Request。\n\n## 鸣谢 Thanks\n\n\u003ca href=\"https://www.browserstack.com/\"\u003e\u003cimg height=\"80\" src=\"https://live.browserstack.com/images/opensource/browserstack-logo.svg\" alt=\"BrowserStack Logo\"\u003e\u003c/a\u003e\n\n\u003e 感谢 BrowserStack 容许我们在真实的浏览器中测试此项目。  \n\u003e Thanks to [BrowserStack](https://www.browserstack.com/) for providing the infrastructure that allows us to test in real browsers!\n\n\u003ca href=\"https://www.jsdelivr.com\"\u003e\u003cimg height=\"80\" src=\"https://raw.githubusercontent.com/jsdelivr/jsdelivr-media/master/default/svg/jsdelivr-logo-horizontal.svg\"\u003e\u003c/a\u003e\n\n\u003e 感谢 jsDelivr 提供的 CDN 服务。  \n\u003e Thanks jsDelivr for providing public CDN service.\n\n代码自这篇博文魔改而来：  \nhttps://www.fghrsh.net/post/123.html\n\n点击看板娘的纸飞机按钮时，会出现一个彩蛋，这来自于 [WebsiteAsteroids](http://www.websiteasteroids.com)。\n\n## 更多 More\n\n更多内容可以参考：  \nhttps://imjad.cn/archives/lab/add-dynamic-poster-girl-with-live2d-to-your-blog-02  \nhttps://github.com/xiazeyu/live2d-widget.js  \nhttps://github.com/summerscar/live2dDemo\n\n关于后端 API 模型：  \nhttps://github.com/fghrsh/live2d_api  \nhttps://github.com/xiazeyu/live2d-widget-models  \nhttps://github.com/xiaoski/live2d_models_collection\n\n除此之外，还有桌面版本：  \nhttps://github.com/amorist/platelet  \nhttps://github.com/akiroz/Live2D-Widget  \nhttps://github.com/zenghongtu/PPet  \nhttps://github.com/LikeNeko/L2dPetForMac\n\n以及 Wallpaper Engine：  \nhttps://github.com/guansss/nep-live2d\n\n## 许可证 License\n\nReleased under the GNU General Public License v3  \nhttp://www.gnu.org/licenses/gpl-3.0.html\n\n本仓库并不包含任何模型，用作展示的所有 Live2D 模型、图片、动作数据等版权均属于其原作者，仅供研究学习，不得用于商业用途。\n\nLive2D 官方网站：  \nhttps://www.live2d.com/en/  \nhttps://live2d.github.io\n\nLive2D Cubism Core は Live2D Proprietary Software License で提供しています。  \nhttps://www.live2d.com/eula/live2d-proprietary-software-license-agreement_en.html  \nLive2D Cubism Components は Live2D Open Software License で提供しています。  \nhttp://www.live2d.com/eula/live2d-open-software-license-agreement_en.html\n\n\u003e The terms and conditions do prohibit modification, but obfuscating in `live2d.min.js` would not be considered illegal modification.\n\nhttps://community.live2d.com/discussion/140/webgl-developer-licence-and-javascript-question\n\n## 更新 Update\n\n2018年10月31日，由 fghrsh 提供的原 API 停用，请更新至新地址。参考文章：  \nhttps://www.fghrsh.net/post/170.html\n\n2020年1月1日起，本项目不再依赖于 jQuery。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdext7r%2Fh7ml-live2d-widget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdext7r%2Fh7ml-live2d-widget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdext7r%2Fh7ml-live2d-widget/lists"}