vite-plugin-blocklet 0.12.5 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +113 -42
- package/index.js +18 -11
- package/libs/loading.js +95 -31
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -254,25 +254,19 @@ function createMetaPlugin() {
|
|
|
254
254
|
* @param {Object} options - The options for generating the HTML.
|
|
255
255
|
* @param {string} options.color - The color of the spinner. Defaults to "#333".
|
|
256
256
|
* @param {string} options.image - The URL of the image to display alongside the spinner.
|
|
257
|
+
* @param {boolean} [options.showDots=true] - Whether to show the loading dots animation.
|
|
258
|
+
* @param {boolean} options.showPoweredBy - Whether to show the "Powered by" text.
|
|
259
|
+
* @param {string} [options.poweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
257
260
|
* @return {string} The generated HTML string.
|
|
258
261
|
*/
|
|
259
|
-
function generateHtml({ color, image }) {
|
|
262
|
+
function generateHtml({ color, image, showDots = true, showPoweredBy, poweredByText = 'Powered by ArcBlock' }) {
|
|
260
263
|
return `<style>
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
flex-direction: column;
|
|
268
|
-
justify-content: center;
|
|
269
|
-
align-items: center;
|
|
270
|
-
margin: 0;
|
|
271
|
-
padding: 0;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
.spinner-wrapper {
|
|
275
|
-
width: 70px;
|
|
264
|
+
#loadingSpinnerWrapper {
|
|
265
|
+
position: fixed;
|
|
266
|
+
top: 0;
|
|
267
|
+
left: 0;
|
|
268
|
+
right: 0;
|
|
269
|
+
bottom: 0;
|
|
276
270
|
opacity: 0;
|
|
277
271
|
animation-name: fadeIn;
|
|
278
272
|
animation-duration: 500ms;
|
|
@@ -286,14 +280,18 @@ function generateHtml({ color, image }) {
|
|
|
286
280
|
align-items: center;
|
|
287
281
|
}
|
|
288
282
|
|
|
289
|
-
.spinner {
|
|
283
|
+
#loadingSpinnerWrapper .spinner {
|
|
290
284
|
width: 70px;
|
|
291
285
|
text-align: center;
|
|
286
|
+
margin-top: 16px;
|
|
292
287
|
}
|
|
293
288
|
|
|
294
|
-
.spinner
|
|
289
|
+
#loadingSpinnerWrapper .spinner>.bounce1,
|
|
290
|
+
#loadingSpinnerWrapper .spinner>.bounce2,
|
|
291
|
+
#loadingSpinnerWrapper .spinner>.bounce3 {
|
|
295
292
|
width: 18px;
|
|
296
293
|
height: 18px;
|
|
294
|
+
|
|
297
295
|
background-color: ${color};
|
|
298
296
|
|
|
299
297
|
border-radius: 100%;
|
|
@@ -302,26 +300,57 @@ function generateHtml({ color, image }) {
|
|
|
302
300
|
animation: sk-bouncedelay 1.4s infinite ease-in-out both;
|
|
303
301
|
}
|
|
304
302
|
|
|
305
|
-
.spinner .bounce1 {
|
|
303
|
+
#loadingSpinnerWrapper .spinner .bounce1 {
|
|
306
304
|
-webkit-animation-delay: -0.32s;
|
|
307
305
|
animation-delay: -0.32s;
|
|
308
306
|
}
|
|
309
307
|
|
|
310
|
-
.spinner .bounce2 {
|
|
308
|
+
#loadingSpinnerWrapper .spinner .bounce2 {
|
|
311
309
|
-webkit-animation-delay: -0.16s;
|
|
312
310
|
animation-delay: -0.16s;
|
|
313
311
|
}
|
|
312
|
+
|
|
313
|
+
#loadingImageWrapper {
|
|
314
|
+
width: 70px;
|
|
315
|
+
height: 70px;
|
|
316
|
+
display: flex;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
align-items: center;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
#loadingImageWrapper.loading-image {
|
|
322
|
+
border-radius: 4px;
|
|
323
|
+
background-color: oklch(87.2% 0.01 258.338);
|
|
324
|
+
animation: 2s ease-in-out 0.5s infinite none running skeleton;
|
|
325
|
+
}
|
|
326
|
+
|
|
314
327
|
#loadingImage {
|
|
315
|
-
|
|
328
|
+
display: inline-block;
|
|
329
|
+
width: 100%;
|
|
330
|
+
height: 100%;
|
|
316
331
|
object-fit: contain;
|
|
317
332
|
}
|
|
318
333
|
|
|
334
|
+
|
|
335
|
+
@-webkit-keyframes skeleton {
|
|
336
|
+
0% { opacity: 0.6; }
|
|
337
|
+
50% { opacity: 0.4; }
|
|
338
|
+
100% { opacity: 0.6; }
|
|
339
|
+
}
|
|
340
|
+
@keyframes skeleton {
|
|
341
|
+
0% { opacity: 0.6; }
|
|
342
|
+
50% { opacity: 0.4; }
|
|
343
|
+
100% { opacity: 0.6; }
|
|
344
|
+
}
|
|
345
|
+
|
|
319
346
|
@-webkit-keyframes fadeIn {
|
|
320
347
|
0% { opacity: 0; }
|
|
348
|
+
50% { opacity: 0.4; }
|
|
321
349
|
100% { opacity: 1; }
|
|
322
350
|
}
|
|
323
351
|
@keyframes fadeIn {
|
|
324
352
|
0% { opacity: 0; }
|
|
353
|
+
50% { opacity: 0.4; }
|
|
325
354
|
100% { opacity: 1; }
|
|
326
355
|
}
|
|
327
356
|
|
|
@@ -348,21 +377,37 @@ function generateHtml({ color, image }) {
|
|
|
348
377
|
transform: scale(1);
|
|
349
378
|
}
|
|
350
379
|
}
|
|
380
|
+
|
|
381
|
+
#loadingPoweredBy {
|
|
382
|
+
position: fixed;
|
|
383
|
+
color: oklch(70.7% 0.022 261.325);
|
|
384
|
+
bottom: 8px;
|
|
385
|
+
left: 0;
|
|
386
|
+
right: 0;
|
|
387
|
+
text-align: center;
|
|
388
|
+
font-size: 12px;
|
|
389
|
+
opacity: ${showPoweredBy ? 1 : 0.01};
|
|
390
|
+
}
|
|
391
|
+
|
|
351
392
|
</style>
|
|
352
|
-
<div
|
|
353
|
-
<
|
|
354
|
-
|
|
393
|
+
<div id="loadingSpinnerWrapper">
|
|
394
|
+
<div id="loadingImageWrapper" class="loading-image"></div>
|
|
395
|
+
${
|
|
396
|
+
showDots
|
|
397
|
+
? `<div class="spinner">
|
|
355
398
|
<div class="bounce1"></div>
|
|
356
399
|
<div class="bounce2"></div>
|
|
357
400
|
<div class="bounce3"></div>
|
|
358
|
-
</div
|
|
401
|
+
</div>`
|
|
402
|
+
: ''
|
|
403
|
+
}
|
|
359
404
|
</div>
|
|
405
|
+
<div id="loadingPoweredBy">${poweredByText}</div>
|
|
360
406
|
<script>
|
|
361
407
|
(() => {
|
|
362
|
-
const loadingImage = document.getElementById('loadingImage');
|
|
363
408
|
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
|
|
364
|
-
|
|
365
|
-
let logo = "${image}";
|
|
409
|
+
|
|
410
|
+
let logo = "${image}";
|
|
366
411
|
|
|
367
412
|
if (window?.blocklet) {
|
|
368
413
|
const { appLogo, appLogoDark } = window.blocklet;
|
|
@@ -370,8 +415,14 @@ function generateHtml({ color, image }) {
|
|
|
370
415
|
logo = isDark && appLogoDark ? appLogoDark : appLogo;
|
|
371
416
|
}
|
|
372
417
|
}
|
|
373
|
-
|
|
374
|
-
|
|
418
|
+
const img = document.createElement('img');
|
|
419
|
+
img.id = 'loadingImage';
|
|
420
|
+
img.src = logo;
|
|
421
|
+
img.onload = () => {
|
|
422
|
+
const loadingImageWrapper = document.getElementById('loadingImageWrapper');
|
|
423
|
+
loadingImageWrapper.appendChild(img);
|
|
424
|
+
loadingImageWrapper.classList.remove('loading-image');
|
|
425
|
+
};
|
|
375
426
|
})();
|
|
376
427
|
</script>`;
|
|
377
428
|
}
|
|
@@ -383,9 +434,19 @@ function generateHtml({ color, image }) {
|
|
|
383
434
|
* @param {string} [options.loadingElementId='app'] - The ID of the loading element.
|
|
384
435
|
* @param {string} [options.loadingColor='#8abaf0'] - The color of the loading animation.
|
|
385
436
|
* @param {string} [options.loadingImage='/.well-known/service/blocklet/logo?imageFilter=convert&f=png&w=80'] - The URL of the loading image.
|
|
437
|
+
* @param {boolean} [options.loadingShowDots=true] - Whether to show the loading dots animation.
|
|
438
|
+
* @param {boolean} [options.loadingShowPoweredBy=true] - Whether to show the "Powered by" text.
|
|
439
|
+
* @param {string} [options.loadingPoweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
386
440
|
* @return {Object} - The Vite plugin object.
|
|
387
441
|
*/
|
|
388
|
-
function createLoadingPlugin({
|
|
442
|
+
function createLoadingPlugin({
|
|
443
|
+
loadingElementId = 'app',
|
|
444
|
+
loadingColor = '#8abaf0',
|
|
445
|
+
loadingImage,
|
|
446
|
+
loadingShowDots = true,
|
|
447
|
+
loadingShowPoweredBy = true,
|
|
448
|
+
loadingPoweredByText = 'Powered by ArcBlock',
|
|
449
|
+
} = {}) {
|
|
389
450
|
if (!loadingImage) {
|
|
390
451
|
loadingImage = ufo.withQuery('/.well-known/service/blocklet/logo', {
|
|
391
452
|
imageFilter: 'convert',
|
|
@@ -396,6 +457,9 @@ function createLoadingPlugin({ loadingElementId = 'app', loadingColor = '#8abaf0
|
|
|
396
457
|
const injectHtml = generateHtml({
|
|
397
458
|
color: loadingColor,
|
|
398
459
|
image: loadingImage,
|
|
460
|
+
showDots: loadingShowDots,
|
|
461
|
+
showPoweredBy: loadingShowPoweredBy,
|
|
462
|
+
poweredByText: loadingPoweredByText,
|
|
399
463
|
});
|
|
400
464
|
|
|
401
465
|
return {
|
|
@@ -843,19 +907,26 @@ async function setupClient(app, options = {}) {
|
|
|
843
907
|
* @property {boolean} [disableLoading=false] - Disable loading plugin.
|
|
844
908
|
* @property {boolean} [disableDebug=false] - Disable debug plugin.
|
|
845
909
|
* @property {boolean} [disableEmbed=false] - Disable embed plugin.
|
|
910
|
+
*
|
|
846
911
|
* @property {import('vite-plugin-node-polyfills').PolyfillOptions} [nodePolyfillsOptions]
|
|
847
912
|
*
|
|
848
|
-
* @property {string} [loadingElementId]
|
|
849
|
-
* @property {string} [loadingColor]
|
|
850
|
-
* @property {string} [loadingImage]
|
|
851
|
-
* @property {
|
|
852
|
-
* @property {
|
|
853
|
-
* @property {
|
|
854
|
-
*
|
|
855
|
-
* @
|
|
856
|
-
* @
|
|
857
|
-
* @
|
|
858
|
-
* @
|
|
913
|
+
* @property {string} [loadingElementId='app'] - The ID of the loading element.
|
|
914
|
+
* @property {string} [loadingColor='#8abaf0'] - The color of the loading animation.
|
|
915
|
+
* @property {string} [loadingImage='/.well-known/service/blocklet/logo?imageFilter=convert&f=png&w=80'] - The URL of the loading image.
|
|
916
|
+
* @property {boolean} [loadingShowDots=true] - Whether to show the loading dots animation.
|
|
917
|
+
* @property {boolean} [loadingShowPoweredBy=true] - Whether to show the "Powered by" text.
|
|
918
|
+
* @property {string} [loadingPoweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
919
|
+
*
|
|
920
|
+
* @property {'all'|'mobile'|'desktop'} [debugPlatform='mobile'] - The platforms to enable debug mode for.
|
|
921
|
+
* @property {string} [debugScript] - The initialization code for the debug script.
|
|
922
|
+
* @property {number} [positionX=0] - The initialization positionX for entry button.
|
|
923
|
+
* @property {number} [positionY=0] - The initialization positionY for entry button.
|
|
924
|
+
*
|
|
925
|
+
* @property {object} [embeds={}] - The embeds to be built.
|
|
926
|
+
* @property {array} [embedExternals=['react', '@arcblock/ux/lib/Locale/context', '@arcblock/did-connect-react/lib/Session']] - The external modules to be used in the embeds.
|
|
927
|
+
* @property {array} [embedPlugins=[]] - The plugins to be used in the embeds.
|
|
928
|
+
* @property {number} [embedBuildConcurrency=0] - The plugins to be used in the embeds.
|
|
929
|
+
*
|
|
859
930
|
* @property {'middleware'|'client'|'server'|'wsUpgrade'} [hmrMode='middleware'] - 当未传入任何 option 参数时,会自动变为 middleware 模式
|
|
860
931
|
*/
|
|
861
932
|
|
package/index.js
CHANGED
|
@@ -20,19 +20,26 @@ import setupClient from './libs/client.js';
|
|
|
20
20
|
* @property {boolean} [disableLoading=false] - Disable loading plugin.
|
|
21
21
|
* @property {boolean} [disableDebug=false] - Disable debug plugin.
|
|
22
22
|
* @property {boolean} [disableEmbed=false] - Disable embed plugin.
|
|
23
|
+
*
|
|
23
24
|
* @property {import('vite-plugin-node-polyfills').PolyfillOptions} [nodePolyfillsOptions]
|
|
24
25
|
*
|
|
25
|
-
* @property {string} [loadingElementId]
|
|
26
|
-
* @property {string} [loadingColor]
|
|
27
|
-
* @property {string} [loadingImage]
|
|
28
|
-
* @property {
|
|
29
|
-
* @property {
|
|
30
|
-
* @property {
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
* @
|
|
34
|
-
* @
|
|
35
|
-
* @
|
|
26
|
+
* @property {string} [loadingElementId='app'] - The ID of the loading element.
|
|
27
|
+
* @property {string} [loadingColor='#8abaf0'] - The color of the loading animation.
|
|
28
|
+
* @property {string} [loadingImage='/.well-known/service/blocklet/logo?imageFilter=convert&f=png&w=80'] - The URL of the loading image.
|
|
29
|
+
* @property {boolean} [loadingShowDots=true] - Whether to show the loading dots animation.
|
|
30
|
+
* @property {boolean} [loadingShowPoweredBy=true] - Whether to show the "Powered by" text.
|
|
31
|
+
* @property {string} [loadingPoweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
32
|
+
*
|
|
33
|
+
* @property {'all'|'mobile'|'desktop'} [debugPlatform='mobile'] - The platforms to enable debug mode for.
|
|
34
|
+
* @property {string} [debugScript] - The initialization code for the debug script.
|
|
35
|
+
* @property {number} [positionX=0] - The initialization positionX for entry button.
|
|
36
|
+
* @property {number} [positionY=0] - The initialization positionY for entry button.
|
|
37
|
+
*
|
|
38
|
+
* @property {object} [embeds={}] - The embeds to be built.
|
|
39
|
+
* @property {array} [embedExternals=['react', '@arcblock/ux/lib/Locale/context', '@arcblock/did-connect-react/lib/Session']] - The external modules to be used in the embeds.
|
|
40
|
+
* @property {array} [embedPlugins=[]] - The plugins to be used in the embeds.
|
|
41
|
+
* @property {number} [embedBuildConcurrency=0] - The plugins to be used in the embeds.
|
|
42
|
+
*
|
|
36
43
|
* @property {'middleware'|'client'|'server'|'wsUpgrade'} [hmrMode='middleware'] - 当未传入任何 option 参数时,会自动变为 middleware 模式
|
|
37
44
|
*/
|
|
38
45
|
|
package/libs/loading.js
CHANGED
|
@@ -6,25 +6,19 @@ import { withQuery } from 'ufo';
|
|
|
6
6
|
* @param {Object} options - The options for generating the HTML.
|
|
7
7
|
* @param {string} options.color - The color of the spinner. Defaults to "#333".
|
|
8
8
|
* @param {string} options.image - The URL of the image to display alongside the spinner.
|
|
9
|
+
* @param {boolean} [options.showDots=true] - Whether to show the loading dots animation.
|
|
10
|
+
* @param {boolean} options.showPoweredBy - Whether to show the "Powered by" text.
|
|
11
|
+
* @param {string} [options.poweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
9
12
|
* @return {string} The generated HTML string.
|
|
10
13
|
*/
|
|
11
|
-
function generateHtml({ color, image }) {
|
|
14
|
+
function generateHtml({ color, image, showDots = true, showPoweredBy, poweredByText = 'Powered by ArcBlock' }) {
|
|
12
15
|
return `<style>
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
flex-direction: column;
|
|
20
|
-
justify-content: center;
|
|
21
|
-
align-items: center;
|
|
22
|
-
margin: 0;
|
|
23
|
-
padding: 0;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.spinner-wrapper {
|
|
27
|
-
width: 70px;
|
|
16
|
+
#loadingSpinnerWrapper {
|
|
17
|
+
position: fixed;
|
|
18
|
+
top: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
right: 0;
|
|
21
|
+
bottom: 0;
|
|
28
22
|
opacity: 0;
|
|
29
23
|
animation-name: fadeIn;
|
|
30
24
|
animation-duration: 500ms;
|
|
@@ -38,14 +32,18 @@ function generateHtml({ color, image }) {
|
|
|
38
32
|
align-items: center;
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
.spinner {
|
|
35
|
+
#loadingSpinnerWrapper .spinner {
|
|
42
36
|
width: 70px;
|
|
43
37
|
text-align: center;
|
|
38
|
+
margin-top: 16px;
|
|
44
39
|
}
|
|
45
40
|
|
|
46
|
-
.spinner
|
|
41
|
+
#loadingSpinnerWrapper .spinner>.bounce1,
|
|
42
|
+
#loadingSpinnerWrapper .spinner>.bounce2,
|
|
43
|
+
#loadingSpinnerWrapper .spinner>.bounce3 {
|
|
47
44
|
width: 18px;
|
|
48
45
|
height: 18px;
|
|
46
|
+
|
|
49
47
|
background-color: ${color};
|
|
50
48
|
|
|
51
49
|
border-radius: 100%;
|
|
@@ -54,26 +52,57 @@ function generateHtml({ color, image }) {
|
|
|
54
52
|
animation: sk-bouncedelay 1.4s infinite ease-in-out both;
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
.spinner .bounce1 {
|
|
55
|
+
#loadingSpinnerWrapper .spinner .bounce1 {
|
|
58
56
|
-webkit-animation-delay: -0.32s;
|
|
59
57
|
animation-delay: -0.32s;
|
|
60
58
|
}
|
|
61
59
|
|
|
62
|
-
.spinner .bounce2 {
|
|
60
|
+
#loadingSpinnerWrapper .spinner .bounce2 {
|
|
63
61
|
-webkit-animation-delay: -0.16s;
|
|
64
62
|
animation-delay: -0.16s;
|
|
65
63
|
}
|
|
64
|
+
|
|
65
|
+
#loadingImageWrapper {
|
|
66
|
+
width: 70px;
|
|
67
|
+
height: 70px;
|
|
68
|
+
display: flex;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
align-items: center;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
#loadingImageWrapper.loading-image {
|
|
74
|
+
border-radius: 4px;
|
|
75
|
+
background-color: oklch(87.2% 0.01 258.338);
|
|
76
|
+
animation: 2s ease-in-out 0.5s infinite none running skeleton;
|
|
77
|
+
}
|
|
78
|
+
|
|
66
79
|
#loadingImage {
|
|
67
|
-
|
|
80
|
+
display: inline-block;
|
|
81
|
+
width: 100%;
|
|
82
|
+
height: 100%;
|
|
68
83
|
object-fit: contain;
|
|
69
84
|
}
|
|
70
85
|
|
|
86
|
+
|
|
87
|
+
@-webkit-keyframes skeleton {
|
|
88
|
+
0% { opacity: 0.6; }
|
|
89
|
+
50% { opacity: 0.4; }
|
|
90
|
+
100% { opacity: 0.6; }
|
|
91
|
+
}
|
|
92
|
+
@keyframes skeleton {
|
|
93
|
+
0% { opacity: 0.6; }
|
|
94
|
+
50% { opacity: 0.4; }
|
|
95
|
+
100% { opacity: 0.6; }
|
|
96
|
+
}
|
|
97
|
+
|
|
71
98
|
@-webkit-keyframes fadeIn {
|
|
72
99
|
0% { opacity: 0; }
|
|
100
|
+
50% { opacity: 0.4; }
|
|
73
101
|
100% { opacity: 1; }
|
|
74
102
|
}
|
|
75
103
|
@keyframes fadeIn {
|
|
76
104
|
0% { opacity: 0; }
|
|
105
|
+
50% { opacity: 0.4; }
|
|
77
106
|
100% { opacity: 1; }
|
|
78
107
|
}
|
|
79
108
|
|
|
@@ -100,21 +129,37 @@ function generateHtml({ color, image }) {
|
|
|
100
129
|
transform: scale(1);
|
|
101
130
|
}
|
|
102
131
|
}
|
|
132
|
+
|
|
133
|
+
#loadingPoweredBy {
|
|
134
|
+
position: fixed;
|
|
135
|
+
color: oklch(70.7% 0.022 261.325);
|
|
136
|
+
bottom: 8px;
|
|
137
|
+
left: 0;
|
|
138
|
+
right: 0;
|
|
139
|
+
text-align: center;
|
|
140
|
+
font-size: 12px;
|
|
141
|
+
opacity: ${showPoweredBy ? 1 : 0.01};
|
|
142
|
+
}
|
|
143
|
+
|
|
103
144
|
</style>
|
|
104
|
-
<div
|
|
105
|
-
<
|
|
106
|
-
|
|
145
|
+
<div id="loadingSpinnerWrapper">
|
|
146
|
+
<div id="loadingImageWrapper" class="loading-image"></div>
|
|
147
|
+
${
|
|
148
|
+
showDots
|
|
149
|
+
? `<div class="spinner">
|
|
107
150
|
<div class="bounce1"></div>
|
|
108
151
|
<div class="bounce2"></div>
|
|
109
152
|
<div class="bounce3"></div>
|
|
110
|
-
</div
|
|
153
|
+
</div>`
|
|
154
|
+
: ''
|
|
155
|
+
}
|
|
111
156
|
</div>
|
|
157
|
+
<div id="loadingPoweredBy">${poweredByText}</div>
|
|
112
158
|
<script>
|
|
113
159
|
(() => {
|
|
114
|
-
const loadingImage = document.getElementById('loadingImage');
|
|
115
160
|
const isDark = document.documentElement.getAttribute('data-theme') === 'dark';
|
|
116
|
-
|
|
117
|
-
let logo = "${image}";
|
|
161
|
+
|
|
162
|
+
let logo = "${image}";
|
|
118
163
|
|
|
119
164
|
if (window?.blocklet) {
|
|
120
165
|
const { appLogo, appLogoDark } = window.blocklet;
|
|
@@ -122,8 +167,14 @@ function generateHtml({ color, image }) {
|
|
|
122
167
|
logo = isDark && appLogoDark ? appLogoDark : appLogo;
|
|
123
168
|
}
|
|
124
169
|
}
|
|
125
|
-
|
|
126
|
-
|
|
170
|
+
const img = document.createElement('img');
|
|
171
|
+
img.id = 'loadingImage';
|
|
172
|
+
img.src = logo;
|
|
173
|
+
img.onload = () => {
|
|
174
|
+
const loadingImageWrapper = document.getElementById('loadingImageWrapper');
|
|
175
|
+
loadingImageWrapper.appendChild(img);
|
|
176
|
+
loadingImageWrapper.classList.remove('loading-image');
|
|
177
|
+
};
|
|
127
178
|
})();
|
|
128
179
|
</script>`;
|
|
129
180
|
}
|
|
@@ -135,9 +186,19 @@ function generateHtml({ color, image }) {
|
|
|
135
186
|
* @param {string} [options.loadingElementId='app'] - The ID of the loading element.
|
|
136
187
|
* @param {string} [options.loadingColor='#8abaf0'] - The color of the loading animation.
|
|
137
188
|
* @param {string} [options.loadingImage='/.well-known/service/blocklet/logo?imageFilter=convert&f=png&w=80'] - The URL of the loading image.
|
|
189
|
+
* @param {boolean} [options.loadingShowDots=true] - Whether to show the loading dots animation.
|
|
190
|
+
* @param {boolean} [options.loadingShowPoweredBy=true] - Whether to show the "Powered by" text.
|
|
191
|
+
* @param {string} [options.loadingPoweredByText='Powered by ArcBlock'] - The text to display for "Powered by".
|
|
138
192
|
* @return {Object} - The Vite plugin object.
|
|
139
193
|
*/
|
|
140
|
-
export default function createLoadingPlugin({
|
|
194
|
+
export default function createLoadingPlugin({
|
|
195
|
+
loadingElementId = 'app',
|
|
196
|
+
loadingColor = '#8abaf0',
|
|
197
|
+
loadingImage,
|
|
198
|
+
loadingShowDots = true,
|
|
199
|
+
loadingShowPoweredBy = true,
|
|
200
|
+
loadingPoweredByText = 'Powered by ArcBlock',
|
|
201
|
+
} = {}) {
|
|
141
202
|
if (!loadingImage) {
|
|
142
203
|
loadingImage = withQuery('/.well-known/service/blocklet/logo', {
|
|
143
204
|
imageFilter: 'convert',
|
|
@@ -148,6 +209,9 @@ export default function createLoadingPlugin({ loadingElementId = 'app', loadingC
|
|
|
148
209
|
const injectHtml = generateHtml({
|
|
149
210
|
color: loadingColor,
|
|
150
211
|
image: loadingImage,
|
|
212
|
+
showDots: loadingShowDots,
|
|
213
|
+
showPoweredBy: loadingShowPoweredBy,
|
|
214
|
+
poweredByText: loadingPoweredByText,
|
|
151
215
|
});
|
|
152
216
|
|
|
153
217
|
return {
|