@@ -11,33 +11,33 @@ namespace BootstrapBlazor.Components;
11
11
public static class JSModuleExtensions
12
12
{
13
13
/// <summary>
14
- /// 导入 utility js 模块
14
+ /// Load utility js module
15
15
/// </summary>
16
- /// <param name="jsRuntime"></param>
17
- /// <param name="version"></param>
18
- /// <returns>A <see cref="Task"/><![CDATA[<]]><see cref="JSModule"/><![CDATA[>]]> 模块加载器 </returns>
16
+ /// <param name="jsRuntime">The <see cref="IJSRuntime"/> instance </param>
17
+ /// <param name="version">The version of the module </param>
18
+ /// <returns>A <see cref="Task"/><![CDATA[<]]><see cref="JSModule"/><![CDATA[>]]> module loader </returns>
19
19
public static Task < JSModule > LoadUtility ( this IJSRuntime jsRuntime , string ? version = null ) => LoadModuleByName ( jsRuntime , "utility" , version ) ;
20
20
21
21
/// <summary>
22
- /// 通过名称导入内置脚本模块
22
+ /// Load built-in script module by name
23
23
/// </summary>
24
- /// <param name="jsRuntime"></param>
25
- /// <param name="moduleName"></param>
26
- /// <param name="version"></param>
27
- /// <returns>A <see cref="Task"/><![CDATA[<]]><see cref="JSModule"/><![CDATA[>]]> 模块加载器 </returns>
24
+ /// <param name="jsRuntime">The <see cref="IJSRuntime"/> instance </param>
25
+ /// <param name="moduleName">The name of the module </param>
26
+ /// <param name="version">The version of the module </param>
27
+ /// <returns>A <see cref="Task"/><![CDATA[<]]><see cref="JSModule"/><![CDATA[>]]> module loader </returns>
28
28
public static Task < JSModule > LoadModuleByName ( this IJSRuntime jsRuntime , string moduleName , string ? version = null )
29
29
{
30
30
var fileName = $ "./_content/BootstrapBlazor/modules/{ moduleName } .js";
31
31
return LoadModule ( jsRuntime , fileName , version ) ;
32
32
}
33
33
34
34
/// <summary>
35
- /// IJSRuntime 扩展方法 动态加载脚本
35
+ /// IJSRuntime extension method to dynamically load scripts
36
36
/// </summary>
37
- /// <param name="jsRuntime"></param>
38
- /// <param name="fileName"></param>
39
- /// <param name="version"></param>
40
- /// <returns>A <see cref="Task"/><![CDATA[<]]><see cref="JSModule"/><![CDATA[>]]> 模块加载器 </returns>
37
+ /// <param name="jsRuntime">The <see cref="IJSRuntime"/> instance </param>
38
+ /// <param name="fileName">The file name of the script </param>
39
+ /// <param name="version">The version of the script </param>
40
+ /// <returns>A <see cref="Task"/><![CDATA[<]]><see cref="JSModule"/><![CDATA[>]]> module loader </returns>
41
41
public static async Task < JSModule > LoadModule ( this IJSRuntime jsRuntime , string fileName , string ? version = null )
42
42
{
43
43
if ( ! string . IsNullOrEmpty ( version ) )
@@ -64,10 +64,10 @@ public static async Task<JSModule> LoadModule(this IJSRuntime jsRuntime, string
64
64
}
65
65
66
66
/// <summary>
67
- /// 获得指定类型的加载 Module 名称
67
+ /// Get the module name of the specified type
68
68
/// </summary>
69
- /// <param name="type"></param>
70
- /// <returns></returns>
69
+ /// <param name="type">The type </param>
70
+ /// <returns>The module name </returns>
71
71
public static string GetTypeModuleName ( this Type type )
72
72
{
73
73
var name = type . Name ;
@@ -80,47 +80,47 @@ public static string GetTypeModuleName(this Type type)
80
80
}
81
81
82
82
/// <summary>
83
- /// 在新标签页打开指定网址
83
+ /// Open the specified URL in a new tab
84
84
/// </summary>
85
- /// <param name="module"><see cref="JSModule"/> 实例 </param>
86
- /// <param name="url">打开网页地址 </param>
87
- /// <param name="target">默认 _blank</param>
88
- /// <param name="features">默认 null</param>
85
+ /// <param name="module"><see cref="JSModule"/> instance </param>
86
+ /// <param name="url">The URL to open </param>
87
+ /// <param name="target">The target window, default is _blank</param>
88
+ /// <param name="features">The features of the new window, default is null</param>
89
89
/// <returns>A <see cref="ValueTask"/> that represents the asynchronous invocation operation.</returns>
90
90
public static ValueTask OpenUrl ( this JSModule module , string url , string ? target = "_blank" , string ? features = null ) => module . InvokeVoidAsync ( "openUrl" , url , target , features ) ;
91
91
92
92
/// <summary>
93
- /// 动态运行js代码
93
+ /// Dynamically run js code
94
94
/// </summary>
95
- /// <param name="module"><see cref="JSModule"/> 实例 </param>
96
- /// <param name="script"></param>
95
+ /// <param name="module"><see cref="JSModule"/> instance </param>
96
+ /// <param name="script">The script to run </param>
97
97
/// <returns>A <see cref="ValueTask"/> that represents the asynchronous invocation operation.</returns>
98
98
public static async ValueTask Eval ( this JSModule module , string script ) => await module . InvokeVoidAsync ( "runEval" , script ) ;
99
99
100
100
/// <summary>
101
- /// 通过 Eval 动态运行 JavaScript 代码
101
+ /// Dynamically run JavaScript code via Eval
102
102
/// </summary>
103
- /// <param name="module"><see cref="JSModule"/> 实例 </param>
104
- /// <param name="script"></param>
103
+ /// <param name="module"><see cref="JSModule"/> instance </param>
104
+ /// <param name="script">The script to run </param>
105
105
/// <returns>A <see cref="ValueTask"/> that represents the asynchronous invocation operation.</returns>
106
106
public static ValueTask < TValue ? > Eval < TValue > ( this JSModule module , string script ) => module . InvokeAsync < TValue ? > ( "runEval" , script ) ;
107
107
108
108
/// <summary>
109
- /// 通过 Function 动态运行 JavaScript 代码
109
+ /// Dynamically run JavaScript code via Function
110
110
/// </summary>
111
- /// <param name="module"><see cref="JSModule"/> 实例 </param>
112
- /// <param name="script"></param>
113
- /// <param name="args"></param>
111
+ /// <param name="module"><see cref="JSModule"/> instance </param>
112
+ /// <param name="script">The script to run </param>
113
+ /// <param name="args">The arguments to pass to the script </param>
114
114
/// <returns>A <see cref="ValueTask"/> that represents the asynchronous invocation operation.</returns>
115
115
public static ValueTask Function ( this JSModule module , string script , params object ? [ ] ? args ) => module . InvokeVoidAsync ( "runFunction" , script , args ) ;
116
116
117
117
/// <summary>
118
- /// 动态运行js代码
118
+ /// Dynamically run js code
119
119
/// </summary>
120
- /// <typeparam name="TValue"></typeparam>
121
- /// <param name="module"><see cref="JSModule"/> 实例 </param>
122
- /// <param name="script"></param>
123
- /// <param name="args"></param>
120
+ /// <typeparam name="TValue">The return type </typeparam>
121
+ /// <param name="module"><see cref="JSModule"/> instance </param>
122
+ /// <param name="script">The script to run </param>
123
+ /// <param name="args">The arguments to pass to the script </param>
124
124
/// <returns>A <see cref="ValueTask"/> that represents the asynchronous invocation operation.</returns>
125
125
public static async ValueTask < TValue ? > Function < TValue > ( this JSModule module , string script , params object ? [ ] ? args )
126
126
{
@@ -133,41 +133,49 @@ public static string GetTypeModuleName(this Type type)
133
133
}
134
134
135
135
/// <summary>
136
- /// 获取当前终端是否为移动设备
136
+ /// Check if the current terminal is a mobile device
137
137
/// </summary>
138
- /// <param name="module"><see cref="JSModule"/> 实例 </param>
138
+ /// <param name="module"><see cref="JSModule"/> instance </param>
139
139
/// <returns>A <see cref="ValueTask"/> that represents the asynchronous invocation operation.</returns>
140
140
public static ValueTask < bool > IsMobile ( this JSModule module ) => module . InvokeAsync < bool > ( "isMobile" ) ;
141
141
142
142
/// <summary>
143
- /// 获取一个页面上不重复的元素ID
143
+ /// Get a unique element ID on a page
144
144
/// </summary>
145
145
/// <param name="module">An instance of <see cref="JSModule"/></param>
146
146
/// <param name="prefix">A prefix of type <see cref="string"/></param>
147
147
/// <returns>Returns a <see cref="string"/> formatted element ID</returns>
148
148
public static ValueTask < string ? > GenerateId ( this JSModule module , string ? prefix = null ) => module . InvokeAsync < string ? > ( "getUID" , prefix ) ;
149
149
150
150
/// <summary>
151
- /// 获取一个页面内指定元素 Html 字符串
151
+ /// Get the HTML string of a specified element on a page
152
152
/// </summary>
153
153
/// <param name="module">An instance of <see cref="JSModule"/></param>
154
- /// <param name="id"></param>
155
- /// <param name="selector"></param>
154
+ /// <param name="id">The ID of the element </param>
155
+ /// <param name="selector">The selector of the element </param>
156
156
/// <returns>Returns a <see cref="string"/> formatted element ID</returns>
157
157
public static ValueTask < string ? > GetHtml ( this JSModule module , string ? id = null , string ? selector = null ) => module . InvokeAsync < string ? > ( "getHtml" , new { id , selector } ) ;
158
158
159
159
/// <summary>
160
- /// 设置主题方法
160
+ /// Set the theme method
161
161
/// </summary>
162
162
/// <param name="module">An instance of <see cref="JSModule"/></param>
163
- /// <param name="themeName">theme name</param>
163
+ /// <param name="themeName">The name of the theme </param>
164
164
/// <returns></returns>
165
165
public static ValueTask SetThemeAsync ( this JSModule module , string themeName ) => module . InvokeVoidAsync ( "setTheme" , themeName , true ) ;
166
166
167
167
/// <summary>
168
- /// 设置主题方法
168
+ /// Get the theme method
169
169
/// </summary>
170
170
/// <param name="module">An instance of <see cref="JSModule"/></param>
171
171
/// <returns></returns>
172
172
public static ValueTask < string ? > GetThemeAsync ( this JSModule module ) => module . InvokeAsync < string ? > ( "getTheme" ) ;
173
+
174
+ /// <summary>
175
+ /// Set memorial mode
176
+ /// </summary>
177
+ /// <param name="module">An instance of <see cref="JSModule"/></param>
178
+ /// <param name="isMemorial">Whether it is memorial mode</param>
179
+ /// <returns></returns>
180
+ public static ValueTask SetMemorialModeAsync ( this JSModule module , bool isMemorial ) => module . InvokeVoidAsync ( "setMemorialMode" , isMemorial ) ;
173
181
}
0 commit comments