• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

14.29
/src/image/image.service.ts
1
import { Injectable, OnDestroy, inject } from '@angular/core';
2
import { ThyImagePreviewConfig, THY_IMAGE_DEFAULT_PREVIEW_OPTIONS } from './image.config';
3
import { ThyImageInfo, ThyImagePreviewOptions } from './image.class';
4
import { ThyImagePreview } from './preview/image-preview.component';
5
import { ThyDialog, ThyDialogSizes } from 'ngx-tethys/dialog';
6
import { ThyImagePreviewRef } from './preview/image-preview-ref';
7
import { Observable, Subject } from 'rxjs';
8
import { takeUntil } from 'rxjs/operators';
9

10
/**
11
 * 图片预览服务
12
 */
1✔
13
@Injectable()
UNCOV
14
export class ThyImageService implements OnDestroy {
×
UNCOV
15
    thyDialog = inject(ThyDialog);
×
UNCOV
16

×
UNCOV
17
    /**
×
UNCOV
18
     * 图片预览默认配置,外部可通过注入 THY_IMAGE_DEFAULT_PREVIEW_OPTIONS 进行配置
×
19
     */
20
    defaultConfig: ThyImagePreviewConfig;
21

22
    private downloadClicked$ = new Subject<ThyImageInfo>();
23

UNCOV
24
    private ngUnsubscribe$ = new Subject<void>();
×
UNCOV
25

×
26
    constructor() {
27
        const defaultConfig = inject(THY_IMAGE_DEFAULT_PREVIEW_OPTIONS, { optional: true })!;
28

×
29
        this.defaultConfig = defaultConfig;
30
    }
31

32
    /**
33
     * 图片预览方法
34
     */
35
    preview(images: ThyImageInfo[], options?: ThyImagePreviewOptions & { startIndex?: number }): ThyImagePreviewRef {
UNCOV
36
        const config = { ...this.defaultConfig, ...options };
×
UNCOV
37
        const dialogRef = this.thyDialog.open(ThyImagePreview, {
×
38
            initialState: {
39
                images,
40
                previewIndex: options?.startIndex >= 0 && options?.startIndex < images.length ? options.startIndex : 0,
UNCOV
41
                previewConfig: config
×
42
            },
UNCOV
43
            backdropClass: 'thy-image-preview-backdrop',
×
44
            panelClass: 'thy-image-preview-container',
45
            size: ThyDialogSizes.full,
UNCOV
46
            ...config
×
47
        });
48
        const imagePreviewRef = new ThyImagePreviewRef(dialogRef.componentInstance, { ...this.defaultConfig, ...options }, dialogRef);
UNCOV
49
        imagePreviewRef
×
UNCOV
50
            .downloadClicked()
×
51
            .pipe(takeUntil(this.ngUnsubscribe$))
52
            .subscribe(image => {
1✔
53
                this.downloadClicked$.next(image);
54
            });
1✔
55
        return imagePreviewRef;
56
    }
57

58
    downloadClicked(): Observable<ThyImageInfo> {
59
        return this.downloadClicked$.asObservable();
60
    }
61

62
    ngOnDestroy() {
63
        this.ngUnsubscribe$.next();
64
        this.ngUnsubscribe$.complete();
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc