From b8ee6bb4d4908015a0338cecb0623263cccacadd Mon Sep 17 00:00:00 2001 From: Rekord <1324596506@qq.com> Date: Thu, 27 Apr 2023 13:38:56 +0800 Subject: [PATCH 1/2] feat: support kanban musume --- package.json | 2 +- public/index.html | 17 +++++--- public/js/autoload.js | 92 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+), 7 deletions(-) create mode 100644 public/js/autoload.js diff --git a/package.json b/package.json index 9f60e46..a0a29ec 100644 --- a/package.json +++ b/package.json @@ -49,4 +49,4 @@ "last 2 versions", "not dead" ] -} \ No newline at end of file +} diff --git a/public/index.html b/public/index.html index 62cfe80..f56af78 100644 --- a/public/index.html +++ b/public/index.html @@ -1,17 +1,22 @@ - + + + chatting - - + + +
- - + + + \ No newline at end of file diff --git a/public/js/autoload.js b/public/js/autoload.js new file mode 100644 index 0000000..6b0a408 --- /dev/null +++ b/public/js/autoload.js @@ -0,0 +1,92 @@ +// live2d_path 参数建议使用绝对路径 +const live2d_path = + "https://fastly.jsdelivr.net/gh/stevenjoezhang/live2d-widget@latest/"; +//const live2d_path = "/live2d-widget/"; + +// 封装异步加载资源的方法 +function loadExternalResource(url, type) { + return new Promise((resolve, reject) => { + let tag; + + if (type === "css") { + tag = document.createElement("link"); + tag.rel = "stylesheet"; + tag.href = url; + } else if (type === "js") { + tag = document.createElement("script"); + tag.src = url; + } + if (tag) { + tag.onload = () => resolve(url); + tag.onerror = () => reject(url); + document.head.appendChild(tag); + } + }); +} + +function showLive2dWidget() { + console.log("show live2d widget"); + document.getElementById("waifu-toggle")?.click(); +} + +function quitLive2dWidget() { + console.log("quit live2d widget"); + document.getElementById("waifu-tool-quit")?.click(); +} + +// 加载 waifu.css live2d.min.js waifu-tips.js +if (screen.width >= 768) { + Promise.all([ + loadExternalResource(live2d_path + "waifu.css", "css"), + loadExternalResource(live2d_path + "live2d.min.js", "js"), + loadExternalResource(live2d_path + "waifu-tips.js", "js"), + ]) + .then(() => { + // 配置选项的具体用法见 README.md + initWidget({ + waifuPath: live2d_path + "waifu-tips.json", + // apiPath: "https://live2d.fghrsh.net/api/", + cdnPath: "https://fastly.jsdelivr.net/gh/fghrsh/live2d_api/", + tools: [ + "hitokoto", + "asteroids", + "switch-model", + "photo", + "info", + "quit", + ], + }); + }) + .then(() => { + document.addEventListener("keydown", (event) => { + if (event.ctrlKey && event.altKey) { + if (event.key === "o") { + showLive2dWidget(); + } else if (event.key === "q") { + quitLive2dWidget(); + } + } + }); + quitLive2dWidget(); + }); +} + +console.log(` + く__,.ヘヽ. / ,ー、 〉 + \ ', !-─‐-i / /´ + /`ー' L//`ヽ、 + / /, /| , , ', + イ / /-‐/ i L_ ハ ヽ! i + レ ヘ 7イ`ト レ'ァ-ト、!ハ| | + !,/7 '0' ´0iソ| | + |.从" _ ,,,, / |./ | + レ'| i>.、,,__ _,.イ / .i | + レ'| | / k_7_/レ'ヽ, ハ. | + | |/i 〈|/ i ,.ヘ | i | + .|/ / i: ヘ! \ | + kヽ>、ハ _,.ヘ、 /、! + !'〈//`T´', \ `'7'ーr' + レ'ヽL__|___i,___,ンレ|ノ + ト-,/ |___./ + 'ー' !_,.: +`); From 5b4c155b9f90ed5a5b1a177403834a93fe2b70f6 Mon Sep 17 00:00:00 2001 From: Rekord <1324596506@qq.com> Date: Thu, 27 Apr 2023 13:40:40 +0800 Subject: [PATCH 2/2] docs: update README --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1727658..156e7d0 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ - [VueRouter3](https://v3.router.vuejs.org/zh/guide/) - [Vuex3](https://v3.vuex.vuejs.org/zh/) - [Element](https://element.eleme.io/#/zh-CN/component/installation) -- [Vue-i18n@8] +- [Vue-i18n@8]() +- [Live2D Widget](https://github.com/stevenjoezhang/live2d-widget) ## Usage ### Project setup