@@ -5,82 +5,82 @@ namespace Masa.Stack.Components;
55
66public partial class SUploadImage : SUpload
77{
8- [ Parameter ]
9- public RenderFragment < List < string > > ? ChildContent { get ; set ; }
10-
11- [ Parameter ]
12- public string ? DefaultImage { get ; set ; }
13-
14- [ Parameter ]
15- public uint PreviewImageWith { get ; set ; }
16-
17- [ Parameter ]
18- public uint PreviewImageHeight { get ; set ; }
19-
20- [ Parameter ]
21- public string Icon { get ; set ; } = "./_content/Masa.Stack.Components/img/upload/upload.svg" ;
22-
23- [ Parameter ]
24- public bool Avatar { get ; set ; }
25-
26- [ Parameter ]
27- public uint Size { get ; set ; }
28-
29- [ Parameter ]
30- public bool IsOverlay { get ; set ; }
31-
32- [ Parameter ]
33- public int OverlayOpenDelay { get ; set ; }
34-
35- [ Parameter ]
36- public int OverlayCloseDelay { get ; set ; }
37-
38- [ Parameter ]
39- public string OverlayTips { get ; set ; } = string . Empty ;
40-
41- public override async Task SetParametersAsync ( ParameterView parameters )
42- {
43- Accept = "image/*" ;
44- OnInputFileChanged = "GetPreviewImageUrls" ;
45- MaximumFileSize = 1024 * 1024 * 2 ;
46- await base . SetParametersAsync ( parameters ) ;
47- }
48-
49- protected override async Task OnParametersSetAsync ( )
50- {
51- if ( string . IsNullOrEmpty ( DefaultImage ) is false && string . IsNullOrEmpty ( Value ) && MultipleValue . Count == 0 )
52- {
53- await SetValueAsync ( DefaultImage ) ;
54- }
55- }
56-
57- protected override async Task OnAfterRenderAsync ( bool firstRender )
58- {
59- if ( firstRender )
60- {
61- var module = await JS . InvokeAsync < IJSObjectReference > ( "import" , "./_content/Masa.Stack.Components/Shared/IntegrationComponents/Upload/SUploadImage.razor.js" ) ;
62- await module . InvokeVoidAsync ( "calculate" ) ;
63- }
64- await base . OnAfterRenderAsync ( firstRender ) ;
65- }
66-
67- string GetClass ( )
68- {
69- var css = Class ;
70- css += " mx-auto hover-misc-transition" ;
71- if ( Avatar ) css += " m-avatar" ;
72- return css ;
73- }
74-
75- string GetStyle ( )
76- {
77- var style = "" ;
78- if ( Size > 0 ) style += $ "height:{ Size } px;width:{ Size } px;";
79- else if ( PreviewImageWith > 0 ) style += $ "width:{ PreviewImageWith } px;";
80- else if ( PreviewImageHeight > 0 ) style += $ "height:{ PreviewImageHeight } px;";
81- if ( Avatar ) style += $ "border-radius: 50%;";
82- return $ "{ style } ;{ Style } ";
83- }
84-
85- List < string > getSrcList ( ) => MultipleValue . Count == 0 ? new List < string > { Icon } : MultipleValue ;
8+ [ Parameter ]
9+ public RenderFragment < List < string > > ? ChildContent { get ; set ; }
10+
11+ [ Parameter ]
12+ public string ? DefaultImage { get ; set ; }
13+
14+ [ Parameter ]
15+ public uint PreviewImageWith { get ; set ; }
16+
17+ [ Parameter ]
18+ public uint PreviewImageHeight { get ; set ; }
19+
20+ [ Parameter ]
21+ public string Icon { get ; set ; } = "./_content/Masa.Stack.Components/img/upload/upload.svg" ;
22+
23+ [ Parameter ]
24+ public bool Avatar { get ; set ; }
25+
26+ [ Parameter ]
27+ public uint Size { get ; set ; }
28+
29+ [ Parameter ]
30+ public bool IsOverlay { get ; set ; }
31+
32+ [ Parameter ]
33+ public int OverlayOpenDelay { get ; set ; }
34+
35+ [ Parameter ]
36+ public int OverlayCloseDelay { get ; set ; }
37+
38+ [ Parameter ]
39+ public string OverlayTips { get ; set ; } = string . Empty ;
40+
41+ public override async Task SetParametersAsync ( ParameterView parameters )
42+ {
43+ Accept = "image/*" ;
44+ OnInputFileChanged = "GetPreviewImageUrls" ;
45+ MaximumFileSize = 1024 * 1024 * 2 ;
46+ await base . SetParametersAsync ( parameters ) ;
47+ }
48+
49+ protected override async Task OnParametersSetAsync ( )
50+ {
51+ if ( string . IsNullOrEmpty ( DefaultImage ) is false && string . IsNullOrEmpty ( Value ) && MultipleValue . Count == 0 )
52+ {
53+ await SetValueAsync ( DefaultImage ) ;
54+ }
55+ }
56+
57+ protected override async Task OnAfterRenderAsync ( bool firstRender )
58+ {
59+ if ( firstRender )
60+ {
61+ var module = await JS . InvokeAsync < IJSObjectReference > ( "import" , "./_content/Masa.Stack.Components/Shared/IntegrationComponents/Upload/SUploadImage.razor.js" ) ;
62+ await module . InvokeVoidAsync ( "calculate" ) ;
63+ }
64+ await base . OnAfterRenderAsync ( firstRender ) ;
65+ }
66+
67+ string GetClass ( )
68+ {
69+ var css = Class ;
70+ css += " mx-auto hover-misc-transition" ;
71+ if ( Avatar ) css += " m-avatar" ;
72+ return css ;
73+ }
74+
75+ string GetStyle ( )
76+ {
77+ var style = "" ;
78+ if ( Size > 0 ) style += $ "height:{ Size } px;width:{ Size } px;";
79+ else if ( PreviewImageWith > 0 ) style += $ "width:{ PreviewImageWith } px;";
80+ else if ( PreviewImageHeight > 0 ) style += $ "height:{ PreviewImageHeight } px;";
81+ if ( Avatar ) style += $ "border-radius: 50%;";
82+ return $ "{ style } ;{ Style } ";
83+ }
84+
85+ List < string > getSrcList ( ) => MultipleValue . Count == 0 ? new List < string > { Icon } : MultipleValue ;
8686}
0 commit comments