@blocklet/launcher-workflow 2.5.1 → 2.5.3

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.
@@ -1,17 +1,8 @@
1
- import Img from '@arcblock/ux/lib/Img';
2
- import { getBaseURL, getSubscriptionLink } from '@blocklet/launcher-util/es/util';
3
- import ContentCopyIcon from '@mui/icons-material/ContentCopy';
4
- import DashboardIcon from '@mui/icons-material/Dashboard';
5
- import OpenInNewIcon from '@mui/icons-material/OpenInNew';
6
- import TaskAltIcon from '@mui/icons-material/TaskAlt';
7
- import { Alert, AlertTitle, alpha, Box, Button, LinearProgress, Typography, useTheme } from '@mui/material';
8
- import Chip from '@mui/material/Chip';
9
- import IconButton from '@mui/material/IconButton';
1
+ import { Alert, AlertTitle, Box, LinearProgress, Typography } from '@mui/material';
10
2
  import PropTypes from 'prop-types';
11
- import React, { useEffect, useMemo, useRef, useState } from 'react';
3
+ import React, { useEffect, useRef, useState } from 'react';
12
4
  import { joinURL } from 'ufo';
13
5
  import { useLocaleContext } from '../../../contexts/locale';
14
- import { checkUrlAccessible } from '../../../util';
15
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
7
  export function proxyUrl(url) {
17
8
  if (url.startsWith('/')) {
@@ -19,8 +10,8 @@ export function proxyUrl(url) {
19
10
  }
20
11
  return `${window.location.origin}/.well-known/service/proxy?url=${url}`;
21
12
  }
22
- const COMPONENT_BASE_TIME = 2; // 每个组件基础处理时间 4s
23
- const SIZE_TIME_RATIO = 0.2; // 每 1MB 增加 1s
13
+ const COMPONENT_BASE_TIME = 1; // 每个组件基础处理时间 1s
14
+ const SIZE_TIME_RATIO = 0.1; // 每 1MB 增加 0.2s
24
15
  // 计算预估安装时间
25
16
  export const calculateEstimatedTime = (components = []) => {
26
17
  if (!Array.isArray(components) || components.length === 0) {
@@ -282,289 +273,4 @@ export function ErrorDisplay({
282
273
  ErrorDisplay.propTypes = {
283
274
  error: PropTypes.string,
284
275
  onRetry: PropTypes.func
285
- };
286
- export function AppSuccessDisplay({
287
- accessibleUrl,
288
- sessionId,
289
- blockletInfo,
290
- urls,
291
- launchSession
292
- }) {
293
- const theme = useTheme();
294
- const {
295
- t
296
- } = useLocaleContext();
297
- const showUrl = useMemo(() => {
298
- return localStorage.getItem('show-url') === 'true';
299
- }, []);
300
-
301
- // 获取应用基本信息
302
- const appName = blockletInfo?.appName || t('startApp.unknownApp');
303
- const appVersion = blockletInfo?.version || launchSession.appInfo?.version || launchSession.blockletMeta?.version || '';
304
- const appLogo = blockletInfo?.appLogo || launchSession.appInfo?.appLogo || '';
305
- const description = blockletInfo?.appDescription || launchSession.metadata?.description;
306
- useEffect(() => {
307
- const stepActive = document.querySelector('.step-active');
308
- if (stepActive) {
309
- stepActive.classList.add('step-checked');
310
- }
311
- }, []);
312
- const [accessibleUrls, setAccessibleUrls] = useState([accessibleUrl]);
313
- useEffect(() => {
314
- const checkUrls = urls.filter(url => !accessibleUrls.includes(url));
315
- checkUrls.forEach(url => {
316
- checkUrlAccessible(url, 10 * 60 * 1000).then(res => {
317
- if (res) {
318
- setAccessibleUrls(prev => {
319
- const accessible = [...prev, url];
320
- return urls.filter(item => accessible.includes(item));
321
- });
322
- }
323
- });
324
- });
325
- }, [accessibleUrls, urls]);
326
- const appUrl = accessibleUrls[0] || urls[0];
327
- return /*#__PURE__*/_jsxs(Box, {
328
- sx: {
329
- width: '100%',
330
- maxWidth: 800,
331
- margin: '0 auto',
332
- p: {
333
- xs: 0,
334
- sm: 3
335
- }
336
- },
337
- children: [/*#__PURE__*/_jsxs(Box, {
338
- textAlign: "center",
339
- mb: 4,
340
- children: [/*#__PURE__*/_jsx(Box, {
341
- sx: {
342
- width: 80,
343
- height: 80,
344
- borderRadius: '50%',
345
- backgroundColor: alpha(theme.palette.success.main, 0.2),
346
- display: 'flex',
347
- alignItems: 'center',
348
- justifyContent: 'center',
349
- margin: '0 auto 16px'
350
- },
351
- children: /*#__PURE__*/_jsx(TaskAltIcon, {
352
- sx: {
353
- fontSize: 40,
354
- color: 'success.main'
355
- }
356
- })
357
- }), /*#__PURE__*/_jsxs(Typography, {
358
- variant: "h3",
359
- component: "h1",
360
- fontWeight: "bold",
361
- gutterBottom: true,
362
- children: ["\uD83C\uDF89 ", t('startApp.started')]
363
- }), /*#__PURE__*/_jsx(Typography, {
364
- variant: "body1",
365
- color: "text.secondary",
366
- children: t('startApp.startedDescription')
367
- })]
368
- }), /*#__PURE__*/_jsxs(Box, {
369
- sx: {
370
- p: 3,
371
- mb: 3,
372
- borderRadius: 2,
373
- border: '1px solid',
374
- borderColor: 'divider',
375
- backgroundColor: 'background.paper'
376
- },
377
- children: [/*#__PURE__*/_jsxs(Box, {
378
- display: "flex",
379
- alignItems: "center",
380
- gap: 2,
381
- mb: 2,
382
- flexWrap: "wrap",
383
- children: [/*#__PURE__*/_jsxs(Box, {
384
- flex: 1,
385
- display: "flex",
386
- alignItems: "center",
387
- gap: 2,
388
- children: [appLogo ? /*#__PURE__*/_jsx(Img, {
389
- src: joinURL(appUrl, appLogo),
390
- alt: appName,
391
- width: 48,
392
- height: 48,
393
- style: {
394
- borderRadius: 10,
395
- overflow: 'hidden'
396
- }
397
- }, appUrl) : null, /*#__PURE__*/_jsxs(Box, {
398
- flex: 1,
399
- textAlign: "left",
400
- children: [/*#__PURE__*/_jsx(Typography, {
401
- variant: "h6",
402
- color: "text.hint",
403
- mb: 1,
404
- children: t('startApp.projectName')
405
- }), /*#__PURE__*/_jsx(Typography, {
406
- variant: "body1",
407
- fontWeight: "medium",
408
- children: appName
409
- })]
410
- })]
411
- }), /*#__PURE__*/_jsxs(Box, {
412
- flex: 1,
413
- display: "flex",
414
- alignItems: "center",
415
- gap: 2,
416
- minWidth: {
417
- xs: '100%',
418
- sm: 'auto'
419
- },
420
- children: [appVersion ? /*#__PURE__*/_jsxs(Box, {
421
- flex: 1,
422
- textAlign: "left",
423
- children: [/*#__PURE__*/_jsx(Typography, {
424
- variant: "h6",
425
- color: "text.hint",
426
- mb: 1,
427
- children: t('startApp.version')
428
- }), /*#__PURE__*/_jsx(Chip, {
429
- label: `v${appVersion}`,
430
- size: "small",
431
- color: "primary",
432
- variant: "outlined"
433
- })]
434
- }) : null, /*#__PURE__*/_jsxs(Box, {
435
- flex: 1,
436
- textAlign: "left",
437
- children: [/*#__PURE__*/_jsx(Typography, {
438
- variant: "h6",
439
- color: "text.hint",
440
- mb: 1,
441
- children: t('startApp.status')
442
- }), /*#__PURE__*/_jsx(Chip, {
443
- label: t('startApp.running'),
444
- size: "small",
445
- color: "success"
446
- })]
447
- })]
448
- })]
449
- }), description && /*#__PURE__*/_jsx(Typography, {
450
- variant: "body2",
451
- color: "text.secondary",
452
- textAlign: "left",
453
- children: description
454
- }), showUrl && /*#__PURE__*/_jsxs(Box, {
455
- children: [/*#__PURE__*/_jsx(Typography, {
456
- variant: "h6",
457
- color: "text.hint",
458
- textAlign: "left",
459
- children: t('startApp.visitUrl')
460
- }), urls.map(url => /*#__PURE__*/_jsxs(Box, {
461
- display: "flex",
462
- alignItems: "center",
463
- mt: 1,
464
- gap: 1,
465
- sx: {
466
- backgroundColor: 'divider',
467
- borderRadius: 1,
468
- py: 0.5,
469
- px: 1.5,
470
- flex: 1
471
- },
472
- children: [/*#__PURE__*/_jsx(Box, {
473
- sx: {
474
- width: 8,
475
- height: 8,
476
- borderRadius: '50%',
477
- backgroundColor: accessibleUrls.includes(url) ? 'success.main' : 'error.main'
478
- }
479
- }), /*#__PURE__*/_jsx(Typography, {
480
- variant: "body2",
481
- textAlign: "left",
482
- sx: {
483
- flex: 1,
484
- fontSize: '0.875rem',
485
- wordBreak: 'break-all'
486
- },
487
- children: url
488
- }), /*#__PURE__*/_jsx(IconButton, {
489
- size: "small",
490
- onClick: () => navigator.clipboard.writeText(url),
491
- children: /*#__PURE__*/_jsx(ContentCopyIcon, {
492
- sx: {
493
- fontSize: 16
494
- }
495
- })
496
- })]
497
- }, url))]
498
- })]
499
- }), /*#__PURE__*/_jsxs(Box, {
500
- display: "flex",
501
- flexDirection: "column",
502
- gap: 2,
503
- mt: 4,
504
- children: [/*#__PURE__*/_jsxs(Box, {
505
- display: "flex",
506
- gap: 2,
507
- margin: "0 auto",
508
- flexDirection: {
509
- xs: 'column-reverse',
510
- md: 'row'
511
- },
512
- children: [/*#__PURE__*/_jsx(Button, {
513
- variant: "outlined",
514
- sx: {
515
- minWidth: 220
516
- },
517
- color: "primary",
518
- onClick: () => window.open(joinURL(getBaseURL(), `/api/launches/${sessionId}/redirect/dashboard?appUrl=${appUrl}`), '_blank'),
519
- startIcon: /*#__PURE__*/_jsx(DashboardIcon, {
520
- sx: {
521
- fontSize: 24,
522
- color: 'primary.main'
523
- }
524
- }),
525
- children: t('startApp.dashboard')
526
- }), /*#__PURE__*/_jsx(Button, {
527
- variant: "contained",
528
- color: "primary",
529
- sx: {
530
- minWidth: 220
531
- },
532
- onClick: () => window.open(joinURL(getBaseURL(), `/api/launches/${sessionId}/redirect/app?appUrl=${appUrl}`), '_blank'),
533
- startIcon: /*#__PURE__*/_jsx(OpenInNewIcon, {
534
- sx: {
535
- fontSize: 24,
536
- color: 'inherit'
537
- }
538
- }),
539
- children: t('startApp.visitApp')
540
- })]
541
- }), /*#__PURE__*/_jsxs(Typography, {
542
- variant: "body2",
543
- color: "text.secondary",
544
- sx: {
545
- margin: '0 auto',
546
- fontWeight: 400,
547
- cursor: 'pointer',
548
- display: 'flex',
549
- alignItems: 'center',
550
- gap: 0.5,
551
- opacity: 0.8
552
- },
553
- onClick: () => window.open(getSubscriptionLink(launchSession.subscriptionId), '_blank'),
554
- children: [/*#__PURE__*/_jsx(OpenInNewIcon, {
555
- sx: {
556
- fontSize: 14,
557
- color: 'inherit'
558
- }
559
- }), t('startApp.subscription')]
560
- })]
561
- })]
562
- });
563
- }
564
- AppSuccessDisplay.propTypes = {
565
- launchSession: PropTypes.object.isRequired,
566
- urls: PropTypes.arrayOf(PropTypes.string).isRequired,
567
- accessibleUrl: PropTypes.string.isRequired,
568
- sessionId: PropTypes.string.isRequired,
569
- blockletInfo: PropTypes.object.isRequired
570
276
  };