Skip to content

Commit 03abe1a

Browse files
Update autoload.js
1 parent f522b25 commit 03abe1a

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

dist/autoload.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1+
/*!
2+
* Live2D Widget
3+
* https://github.com/stevenjoezhang/live2d-widget
4+
*/
5+
6+
// Recommended to use absolute path for live2d_path parameter
17
// live2d_path 参数建议使用绝对路径
28
const live2d_path = 'https://fastly.jsdelivr.net/npm/live2d-widgets@1.0.0-rc.3/dist/';
39
// const live2d_path = '/dist/';
410

11+
// Method to encapsulate asynchronous resource loading
512
// 封装异步加载资源的方法
613
function loadExternalResource(url, type) {
714
return new Promise((resolve, reject) => {
@@ -25,8 +32,12 @@ function loadExternalResource(url, type) {
2532
});
2633
}
2734

28-
// 如果担心手机上显示效果不佳,可以通过 `if (screen.width >= 768)` 来判断是否加载
2935
(async () => {
36+
// If you are concerned about display issues on mobile devices, you can use screen.width to determine whether to load
37+
// 如果担心手机上显示效果不佳,可以根据屏幕宽度来判断是否加载
38+
// if (screen.width < 768) return;
39+
40+
// Avoid cross-origin issues with image resources
3041
// 避免图片资源跨域问题
3142
const OriginalImage = window.Image;
3243
window.Image = function(...args) {
@@ -35,11 +46,13 @@ function loadExternalResource(url, type) {
3546
return img;
3647
};
3748
window.Image.prototype = OriginalImage.prototype;
38-
// 加载 waifu.css waifu-tips.js
49+
// Load waifu.css and waifu-tips.js
50+
// 加载 waifu.css 和 waifu-tips.js
3951
await Promise.all([
4052
loadExternalResource(live2d_path + 'waifu.css', 'css'),
4153
loadExternalResource(live2d_path + 'waifu-tips.js', 'js')
4254
]);
55+
// For detailed usage of configuration options, see README.en.md
4356
// 配置选项的具体用法见 README.md
4457
initWidget({
4558
waifuPath: live2d_path + 'waifu-tips.json',

0 commit comments

Comments
 (0)