1
+ /*!
2
+ * Live2D Widget
3
+ * https://github.com/stevenjoezhang/live2d-widget
4
+ */
5
+
6
+ // Recommended to use absolute path for live2d_path parameter
1
7
// live2d_path 参数建议使用绝对路径
2
8
const live2d_path = 'https://fastly.jsdelivr.net/npm/live2d-widgets@1.0.0-rc.3/dist/' ;
3
9
// const live2d_path = '/dist/';
4
10
11
+ // Method to encapsulate asynchronous resource loading
5
12
// 封装异步加载资源的方法
6
13
function loadExternalResource ( url , type ) {
7
14
return new Promise ( ( resolve , reject ) => {
@@ -25,8 +32,12 @@ function loadExternalResource(url, type) {
25
32
} ) ;
26
33
}
27
34
28
- // 如果担心手机上显示效果不佳,可以通过 `if (screen.width >= 768)` 来判断是否加载
29
35
( 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
30
41
// 避免图片资源跨域问题
31
42
const OriginalImage = window . Image ;
32
43
window . Image = function ( ...args ) {
@@ -35,11 +46,13 @@ function loadExternalResource(url, type) {
35
46
return img ;
36
47
} ;
37
48
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
39
51
await Promise . all ( [
40
52
loadExternalResource ( live2d_path + 'waifu.css' , 'css' ) ,
41
53
loadExternalResource ( live2d_path + 'waifu-tips.js' , 'js' )
42
54
] ) ;
55
+ // For detailed usage of configuration options, see README.en.md
43
56
// 配置选项的具体用法见 README.md
44
57
initWidget ( {
45
58
waifuPath : live2d_path + 'waifu-tips.json' ,
0 commit comments